R-Orange is a fun and educational web-based simulation of the "Rotten Oranges" problem — a classic Breadth-First Search (BFS) problem in Data Structures and Algorithms (DSA). This interactive app allows users to visually experiment with the problem by placing fresh and rotten oranges on a grid and watching how the rotting process spreads over time.
- 🎮 Interactive Grid UI – Drag and drop fresh 🍊 and rotten oranges 💀 into the grid.
- 🧠 BFS Algorithm Visualization – Step-by-step real-time simulation of the BFS logic.
- 🛠️ Custom Matrix Size – Set your own rows and columns for the grid.
- ⏱️ Play & Reset Controls – Start the simulation or reset the grid anytime.
- ✨ Clean UI – Simple, colorful, and user-friendly design.
Given a grid of
M x Nwhere each cell can be:
0– empty cell1– fresh orange2– rotten orange
Every minute, any fresh orange adjacent (up/down/left/right) to a rotten one becomes rotten. Determine the minimum time required to rot all oranges, or return -1 if impossible.
- HTML, CSS, JavaScript
- No frameworks or external libraries used
- Fully frontend – runs entirely in the browser
r-orange/ │ ├── index.html # Main HTML structure ├── styles.css # Styling and layout ├── script.js # Core logic including BFS implementation └── README.md # Project documentation
pgsql Copy Edit
- User selects matrix size (e.g., 5x5).
- User places oranges by selecting either fresh or rotten mode.
- Click Start Simulation to begin the rot spread.
- The app runs BFS level by level and updates the grid each second.
- Result shows total time taken to rot all oranges or an error if not all can rot.
- Understand BFS traversal in 2D matrices
- Grasp real-world problem solving using graph theory
- Build interactive web apps with clean logic
- ⏸️ Pause & Resume simulation
- 📈 Add statistics or step counters
- 💾 Save/load grid state
- 🔍 BFS traversal highlights with animation
Made with ❤️ by Veerendra Kumar
Part of my learning projects to explore DSA + Web Dev
This project is open source under the MIT License.

