Skip to content

veerendra17788/R-Orange

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍊 R-Orange – Interactive BFS Visualization Web App

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.

🚀 Features

  • 🎮 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.

🧩 The Problem Statement

Given a grid of M x N where each cell can be:

  • 0 – empty cell
  • 1 – fresh orange
  • 2 – 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.

📸 Demo

alt text

🛠️ Tech Stack

  • HTML, CSS, JavaScript
  • No frameworks or external libraries used
  • Fully frontend – runs entirely in the browser

📂 File Structure

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

🧠 How It Works

  1. User selects matrix size (e.g., 5x5).
  2. User places oranges by selecting either fresh or rotten mode.
  3. Click Start Simulation to begin the rot spread.
  4. The app runs BFS level by level and updates the grid each second.
  5. Result shows total time taken to rot all oranges or an error if not all can rot.

🎯 Learning Objectives

  • Understand BFS traversal in 2D matrices
  • Grasp real-world problem solving using graph theory
  • Build interactive web apps with clean logic

📌 Future Enhancements

  • ⏸️ Pause & Resume simulation
  • 📈 Add statistics or step counters
  • 💾 Save/load grid state
  • 🔍 BFS traversal highlights with animation

🙌 Credits

Made with ❤️ by Veerendra Kumar
Part of my learning projects to explore DSA + Web Dev

📄 License

This project is open source under the MIT License. alt text

About

this is the project that demonstrate Rotten Orange problem

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors