|
1 | | -# 🛤️ Unique Paths II Visualizer |
| 1 | +# 🧽 Unique Paths Visualizer |
2 | 2 |
|
3 | | -An interactive web application that visualizes the **Unique Paths II** dynamic programming problem with obstacle support. |
| 3 | +A visual, interactive React application to explore **dynamic programming (DP)** and **shortest path algorithms**. Easily toggle between **Leetcode-style Unique Paths II** and **Dijkstra's shortest path**, build your own grid, and visualize the paths with animations. |
4 | 4 |
|
5 | | -## ✨ Features |
| 5 | +### 🌐 Live Demo |
6 | 6 |
|
7 | | -- **🖱️ Click & Drag**: Paint obstacles by clicking and dragging across the grid |
8 | | -- **🎬 Path Animation**: Watch random valid paths being traced step-by-step |
9 | | -- **📊 DP Values**: Toggle display of dynamic programming computation values |
10 | | -- **📱 Responsive Design**: Works on desktop and mobile devices |
11 | | -- **⚡ Real-time Updates**: Instant recalculation as you modify the grid |
| 7 | +> _https://greenmarioh.github.io/unique-paths-visualizer/_ |
12 | 8 |
|
13 | | -## 🚀 Demo |
| 9 | +--- |
| 10 | + |
| 11 | +## 📌 Features |
14 | 12 |
|
15 | | -Visit the live demo: [https://GreenMarioh.github.io/unique-paths-visualizer/](https://GreenMarioh.github.io/unique-paths-visualizer/) |
| 13 | +- 🧠 **Unique Paths II (DP)**: Visualizes total valid paths using a dynamic programming table. Implements logic based on [LeetCode - Unique Paths II](https://leetcode.com/problems/unique-paths-ii/description/). |
| 14 | +- 📏 **Shortest Path Mode**: Uses a modified Dijkstra’s algorithm that supports 8-directional movement (diagonals included) for pathfinding. |
| 15 | +- 👡️ **Interactive Grid Editor**: |
| 16 | + - Click or drag to add/remove obstacles. |
| 17 | + - In shortest path mode, drag Start (🟩) and End (🟦) nodes freely. |
| 18 | +- 🧮 **DP Table Rendering**: Optionally display the number of ways to reach each cell in unique paths mode. |
| 19 | +- 🔁 **Path Animation**: Each cell in a computed path lights up sequentially to demonstrate traversal order. |
| 20 | +- 📀 **Resizable Grid**: Supports grids from 1×1 to 12×12 with smooth resets and state preservation. |
| 21 | +- ⚡ Fast and reactive UI thanks to React + Vite + Tailwind. |
| 22 | + |
| 23 | +--- |
16 | 24 |
|
17 | | -## 🎮 How to Use |
| 25 | +## 🚀 Getting Started |
18 | 26 |
|
19 | | -1. **Grid Setup**: Adjust rows and columns using the input fields |
20 | | -2. **Add Obstacles**: Click and drag to paint red obstacle cells |
21 | | -3. **Remove Obstacles**: Drag over existing obstacles to erase them |
22 | | -4. **Animate Path**: Click "Show Random Path" to see a path traced with smooth animation |
23 | | -5. **View DP Values**: Toggle "Show Path Counts" to see the computed values |
| 27 | +### 1. Clone the Repository |
24 | 28 |
|
25 | | -## 🧮 Algorithm |
| 29 | +```bash |
| 30 | +git clone https://github.com/GreenMarioh/unique-paths-visualizer.git |
| 31 | +cd unique-paths-visualizer |
| 32 | +``` |
26 | 33 |
|
27 | | -This visualizer demonstrates the **Unique Paths II** problem: |
| 34 | +### 2. Install Dependencies |
28 | 35 |
|
29 | | -- **Input**: An `m × n` grid with obstacles |
30 | | -- **Goal**: Count unique paths from top-left to bottom-right |
31 | | -- **Constraints**: Can only move right or down, obstacles block paths |
32 | | -- **Solution**: Dynamic programming with obstacle handling |
| 36 | +```bash |
| 37 | +npm install |
| 38 | +# or |
| 39 | +yarn install |
| 40 | +``` |
33 | 41 |
|
34 | | -## 🛠️ Technical Details |
| 42 | +### 3. Start Development Server |
35 | 43 |
|
36 | | -- **Frontend**: React with Hooks |
37 | | -- **Styling**: Tailwind CSS |
38 | | -- **Animations**: CSS transitions with JavaScript timing |
39 | | -- **Deployment**: GitHub Pages |
| 44 | +```bash |
| 45 | +npm run dev |
| 46 | +# or |
| 47 | +yarn dev |
| 48 | +``` |
| 49 | + |
| 50 | +Then open: [http://localhost:3000](http://localhost:3000) |
| 51 | + |
| 52 | +--- |
40 | 53 |
|
41 | | -## 📜 License |
| 54 | +## 🛠️ Built With |
42 | 55 |
|
43 | | -MIT License - feel free to use this code for educational purposes. |
| 56 | +- ⚛️ **[React](https://reactjs.org/)** — UI component library |
| 57 | +- 🔆 **[TypeScript](https://www.typescriptlang.org/)** — Typed JavaScript for safety and tooling |
| 58 | +- 🎨 **[Tailwind CSS](https://tailwindcss.com/)** — Utility-first CSS framework |
| 59 | +- ⚡ **[Vite](https://vitejs.dev/)** — Lightning-fast build tool and dev server |
| 60 | +- 📦 **Modular Architecture** — Reusable components (GridCell, InfoCard, etc.) |
| 61 | +- 📁 **Single-File Visualizer Component** — Main logic lives in `UniquePathsVisualizer.tsx` for simplicity and portability |
44 | 62 |
|
45 | 63 | --- |
46 | 64 |
|
47 | | -_Enhanced visualization of classic dynamic programming concept._ |
| 65 | +## 📄 License |
| 66 | + |
| 67 | +MIT License. Feel free to fork and improve! |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## 🚇️ Author |
| 72 | + |
| 73 | +Created with ❤️ by [@GreenMarioh](https://github.com/GreenMarioh) |
| 74 | + |
| 75 | +👉 View the source code: |
| 76 | +🔗 [https://github.com/GreenMarioh/unique-paths-visualizer](https://github.com/GreenMarioh/unique-paths-visualizer) |
0 commit comments