ๅบไบ Vue 3 + Vite ๆๅปบ็ไบคไบๅผ็บฆ็ๅคซ้ฎ้ขๅฏ่งๅๅทฅๅ ท๏ผๆฏๆ้่กไปฃ็ ่ฐ่ฏๅๅจ็ปๆผ็คบใ
An interactive Josephus problem visualization tool built with Vue 3 + Vite, featuring line-by-line code debugging and animated demonstrations.
่งฃๅณๆฐๆๅญฆไน ็บฆ็ๅคซ้ฎ้ขๆถ "ๅชๆไปฃ็ ไธๆ้ป่พ" ็็็น
Solving the pain point of beginners learning the Josephus problem: "understanding code but not logic"
ๅพๅคๅๅญฆๅจๅญฆไน ็บฆ็ๅคซ้ฎ้ขๆถ๏ผ่ฝ็ๆไปฃ็ ็ๆฏไธ่ก๏ผไฝ่ๆตท้ๆณไธๅบๅฎ้ ่ฟ่ก็็ป้ขใ่ฟไธช้กน็ฎ้่ฟ "ๅทฆไพงไปฃ็ + ๅณไพง debug ๅผๅจ็ป" ็ๆนๅผ๏ผ่ฎฉไฝ ๏ผ
Many students can understand each line of code when learning the Josephus problem, but cannot visualize the actual execution. This project uses a "left code + right debug-style animation" approach to help you:
- ๐ ็ผ็ไปฃ็ / Watch Code: ๅทฆ่พน้ซไบฎๆพ็คบๅฝๅๆง่กๅฐๅชไธ่ก / Left side highlights the current execution line
- ๐ฌ ่่กฅ็ป้ข / Visualize Process: ๅณ่พนๅๆญฅๆผ็คบ้พ่กจ่็น็็งปๅจๅๅ ้ค / Right side synchronously demonstrates node movement and deletion
- ๐ ๅปบ็ซ่็ณป / Make Connections: ไปฃ็ ๅๅจ็ปๅฎๆถๅ ณ่๏ผ็่งฃๆฝ่ฑก้ป่พๅๅพ่ฝปๆพ / Real-time connection between code and animation makes abstract logic easy to understand
ไธ้่ฆๅฎ่ฃ ไปปไฝ่ฝฏไปถ๏ผๆๅผ็ฝ้กตๅฐฑ่ฝ็จ๏ผ
No installation required - just open the web page and start using it!
ๅจ็บฟๆผ็คบ / Live Demo: https://chhsiching.github.io/josephus-visualizer/
ๆฌ้กน็ฎๅทฒ้จ็ฝฒๅฐ GitHub Pages๏ผ็นๅปไธๆน้พๆฅๅณๅฏๆฅ็ๅฎ้ ่ฟ่กๆๆใ็้ขๅ ๅซ๏ผ
This project is deployed on GitHub Pages. Click the link above to see it in action. The interface includes:
- ๅทฆไพงไปฃ็ ้ขๆฟ / Left Code Panel: ๆพ็คบ C ่ฏญ่จไปฃ็ ๏ผ้ซไบฎๅฝๅๆง่ก่ก / Displays C code with current execution line highlighted
- ๅณไพงๅจ็ป้ขๆฟ / Right Animation Panel: ๅฑ็คบ็บฆ็ๅคซ็ฏๅจ็ป๏ผ่็น็งปๅจๅๅ ้ค / Shows Josephus ring animation with node movement and elimination
- ๅบ้จๆงๅถ้ขๆฟ / Bottom Control Panel: ๆญๆพใๆๅใๆญฅ่ฟใ้ๅบฆ่ฐ่ / Play, pause, step, and speed controls
- ๐ฏ ไบคไบๅผๅฏ่งๅ / Interactive Visualization: ๅบไบ SVG ็ๅๅๅพช็ฏ้พ่กจๅฏ่งๅ / SVG-based circular linked list visualization with bidirectional pointers
- ๐ ้่ก่ฐ่ฏ / Line-by-Line Debugging: GDB ้ฃๆ ผ็ C ไปฃ็ ๆง่กๆผ็คบ๏ผๅฎๆถ้ซไบฎ / GDB-style C code execution with real-time highlighting
- โฏ๏ธ ๅฎๆดๆญๆพๆงๅถ / Complete Playback Controls: ๆฏๆๆญๆพใๆๅใๆญฅ่ฟๅ้ๅบฆ่ฐ่ / Play, pause, step execution, and speed adjustment
- ๐ ๅฎๆถๅจ็ป / Real-time Animation: ๅฑ็คบ้พ่กจๆๅปบใ่ฎกๆฐใ่็นๅ ้ค็ๅฎๆด่ฟ็จ / Shows list construction, counting, and node elimination
- ๐จ ๅๅบๅผ่ฎพ่ฎก / Responsive Design: Gruvbox ๆ่ฒไธป้ข๏ผๆฏๆไธๅๅฑๅนๅฐบๅฏธ / Gruvbox dark theme with screen size support
- ๐ ่ฏฆ็ป็ถๆๆพ็คบ / Detailed Status Display: ๆพ็คบๅฝๅๅๅใๅทฒๅ ้ค่็นใๆง่กๆญฅ้ชค็ญ / Shows current round, eliminated nodes, execution steps
้กน็ฎๅทฒ้จ็ฝฒๅจ GitHub Pages๏ผๅฏ็ดๆฅ่ฎฟ้ฎ๏ผ
The project is deployed on GitHub Pages and can be accessed directly:
https://chhsiching.github.io/josephus-visualizer/
# Clone the project
git clone https://github.com/chhsiching/josephus-visualizer.git
cd josephus-visualizer
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview็บฆ็ๅคซ้ฎ้ขๆ่ฟฐ๏ผn ไธชไบบ็ซๆไธๅ๏ผไปๆๅฎ็ไบบๅผๅง้กบๆถ้ๆฅๆฐ๏ผๆฐๅฐ k ็ไบบ่ขซๆทๆฑฐ๏ผไธไธไธชไบบ้ๆฐไป 1 ๅผๅงๆฅๆฐใๅฆๆญคๅพช็ฏ๏ผ็ดๅฐๆๆไบบ่ขซๆทๆฑฐ๏ผ็กฎๅฎๆทๆฑฐ้กบๅบใ
The Josephus problem describes: n people stand in a circle, starting from a specified person and counting clockwise. The person who counts to k is eliminated, and the next person restarts counting from 1. This continues until all are eliminated, determining the elimination order.
ๆฌ้กน็ฎไฝฟ็จๅๅๅพช็ฏ้พ่กจๅฎ็ฐ็บฆ็ๅคซ้ฎ้ข๏ผ
This project implements the Josephus problem using a doubly circular linked list:
- ่็น็ปๆ / Node Structure: ๆฏไธชไบบ่กจ็คบไธบไธไธช่็น๏ผๅ
ๅซ
idใnextๅpreๆ้ / Each person as a node withid,next, andprepointers - ้พ่กจๆๅปบ / List Construction:
RingConstructๅฝๆฐๅๅปบ N ไธช่็น็ๅๅๅพช็ฏ้พ่กจ / Creates a doubly circular linked list with N nodes - ่ฎกๆฐๆจกๅผ / Counting Pattern: ไฝฟ็จ้ๅคๆจกๅผ [3, 5, 7, 13] ไฝไธบๆฏ่ฝฎๆทๆฑฐ็้ / Uses repeating pattern [3, 5, 7, 13] as elimination bounds
- ่ฎกๆฐๅฝๆฐ / Counting Function:
countๅฝๆฐไป่็นๅผๅง่ฎกๆฐ๏ผๆพๅฐ่ฆๆทๆฑฐ็่็น / Starts from a node and counts to find the elimination target - ่็น็งป้ค / Node Removal:
removeNodeๅฝๆฐ็งป้คๅฝๅ่็นๅนถ้ๆฐ่ฟๆฅ้พ่กจ / Removes current node and reconnects the list
- ๅ็ฏ็ฎญๅคด็ณป็ป / Dual-Ring Arrow System: ๅค็ฏๆพ็คบ next ๆ้๏ผ้กบๆถ้๏ผ๏ผๅ ็ฏๆพ็คบ prev ๆ้๏ผ้ๆถ้๏ผ / Outer ring shows next pointers (clockwise), inner ring shows prev pointers (counter-clockwise)
- ๅจ็ป้ถๆฎต / Animation Phases: ๅๅงๅ้ถๆฎตใ่ฎกๆฐ้ถๆฎตใ็งป้ค้ถๆฎตใๅฎๆ้ถๆฎต / Initialization, counting, removal, and completion phases
- ็ถๆๅๆญฅ / State Synchronization: ไปฃ็ ่กๅทไธๅจ็ป็ถๆ็ฒพ็กฎๅๆญฅ / Precise synchronization between code line numbers and animation states
- ๆญๆพ/ๆๅ / Play/Pause: ็นๅปๆญๆพๆ้ฎๅผๅง่ชๅจๆง่ก๏ผ็นๅปๆๅๅๆญข / Click play to start, pause to stop
- ๆญฅ่ฟๆง่ก / Step Execution: ไฝฟ็จๅ่ฟ/ๅ้ๆ้ฎ้ๆญฅๆฅ็็ฎๆณๆง่ก / Use forward/backward buttons to step through
- ้ๅบฆๆงๅถ / Speed Control: ๆฏๆ 1xใ2xใ4x ๆญๆพ้ๅบฆ / Supports 1x, 2x, 4x playback speeds
- ไปฃ็ ๅฏผ่ช / Code Navigation: ็นๅปๅทฆไพงไปฃ็ ้ขๆฟ็่กๅท่ทณ่ฝฌๅฐๅฏนๅบๆญฅ้ชค / Click line numbers to jump to steps
- ้็ฝฎ / Reset: ็นๅป้็ฝฎๆ้ฎ้ๆฐๅผๅงๆผ็คบ / Click reset to restart
- ๅทฆไพง้ขๆฟ / Left Panel: ๆพ็คบ C ไปฃ็ ๏ผ้ซไบฎๅฝๅๆง่ก่ก / Displays C code with current execution line highlighted
- ๅณไพง้ขๆฟ / Right Panel: ๅๅฝขๅฏ่งๅ๏ผๆพ็คบ่็น็ถๆๅๆ้ๅ ณ็ณป / Circular visualization showing node states and pointer relationships
- ๅบ้จๆงๅถๆ / Bottom Control Bar: ๆญๆพๆงๅถใ่ฟๅบฆๆพ็คบใ้ๅบฆ่ฐ่็ญ / Playback controls, progress display, speed adjustment
- ไธญๅฟไฟกๆฏ / Center Information: ๆพ็คบๅฝๅๆง่ก้ถๆฎตๅๅๅๆฐ / Shows current execution phase and round number
- ๅ็ซฏๆกๆถ / Frontend Framework: Vue 3 (Composition API)
- ๆๅปบๅทฅๅ ท / Build Tool: Vite
- ๆ ทๅผ / Styling: SCSS + Gruvbox dark theme
- ่ฏญๆณ้ซไบฎ / Syntax Highlighting: Shiki
- ๅฏ่งๅ / Visualization: SVG
- ้จ็ฝฒ / Deployment: GitHub Pages + GitHub Actions
josephus-visualizer/
โโโ src/
โ โโโ components/ # Vue components
โ โ โโโ App.vue # Main application component
โ โ โโโ CodeDisplay.vue # Code display component
โ โ โโโ CircleAnimation.vue # Animation component
โ โ โโโ ControlPanel.vue # Control panel component
โ โ โโโ CircleNode.vue # Node component
โ โ โโโ CircleLink.vue # Link component
โ โโโ utils/ # Utility functions
โ โ โโโ josephus-simulator.js # Algorithm simulator
โ โโโ styles/ # Style files
โ โโโ gruvbox-dark.scss # Theme styles
โโโ public/
โ โโโ joseph-ring-algorithm.c # C algorithm source code
โโโ .github/workflows/ # GitHub Actions configuration
โ โโโ deploy.yml # Auto-deployment configuration
โโโ README.md
- ่็นๆฐ้ / Node Count: ๅบๅฎ 20 ไธช่็น / Fixed at 20 nodes
- ่ฎกๆฐๆจกๅผ / Counting Pattern: ้ๅคๆจกๅผ [3, 5, 7, 13] / Repeating pattern [3, 5, 7, 13]
- ๅจ็ป้ๅบฆ / Animation Speed: ๆฏๆ 1xใ2xใ4x ้ๅบฆ่ฐ่ / Supports 1x, 2x, 4x speed adjustment
- ไธป้ข้ ็ฝฎ / Theme Configuration: Gruvbox ๆ่ฒไธป้ข / Gruvbox dark theme
ๆฌ้กน็ฎ้็จ MIT ่ฎธๅฏ่ฏใ
This project is licensed under the MIT License.
A: ๅทๆฐ้กต้ขๅณๅฏใๅฆๆ้ฎ้ขๆ็ปญ๏ผๅฐ่ฏ้ไฝๆญๆพ้ๅบฆ๏ผๅๆขๅฐ 1x๏ผใ
A: Refresh the page. If the issue persists, try reducing the playback speed (switch to 1x).
A: ๅฝๅ็ๆฌๅบๅฎไธบ 20 ไธชไบบ๏ผ่ฎกๆฐ่งๅๆฏ [3, 5, 7, 13] ๅพช็ฏใๆชๆฅๅฏ่ฝๆฏๆ่ชๅฎไน้ ็ฝฎใ
A: Current version is fixed at 20 people with [3, 5, 7, 13] counting pattern. Custom configuration may be supported in the future.
A: ้จๅไปฃ็ ่ก๏ผๅฆๆณจ้่กใๅฝๆฐๅฃฐๆ๏ผไธๅฏนๅบๅฎ้ ๆง่กๆญฅ้ชค๏ผๅชๆๅฎ้ ๆง่ก็ไปฃ็ ่กๆ่ฝ่ทณ่ฝฌใ
A: Some code lines (comments, function declarations) don't correspond to execution steps. Only actual execution lines are clickable.
A: ๅฏไปฅ๏ผไฝๆจ่ๅจ็ต่ไธไฝฟ็จไปฅ่ทๅพๆดๅฅฝ็ไฝ้ชใๆๆบๅฑๅน่พๅฐ๏ผๅทฆๅณๅๆ ๆพ็คบไผๆฏ่พๆฅๆคใ
A: Yes, but desktop is recommended for better experience. Mobile screens may feel cramped with the split-panel layout.
A: ๅปบ่ฎฎๆไปฅไธ้กบๅบ้ ่ฏป / Recommended reading order:
src/utils/josephus-simulator.js- ็ฎๆณๆจกๆๅจๆ ธๅฟ้ป่พ / Algorithm simulator core logicsrc/App.vue- ไธปๅบ็จ็ปไปถ๏ผ็่งฃๆดไฝ็ปๆ / Main application component to understand overall structuresrc/components/CircleAnimation.vue- ๅจ็ปๆธฒๆ้ป่พ / Animation rendering logicsrc/components/CodeDisplay.vue- ไปฃ็ ้ซไบฎๆพ็คบ / Code highlighting display
ๆฌข่ฟๆไบค Issue ๅ Pull Request ๆฅๆน่ฟ้กน็ฎ๏ผ
Issues and Pull Requests are welcome to improve the project!
- Git ๆไบคไฟกๆฏ้ตๅพช gitmoji ็บฆๅฎ / Git commit messages follow gitmoji convention
- ไปฃ็ ้ฃๆ ผ้ตๅพช Vue 3 ๅฎๆนๆจ่ / Code style follows Vue 3 official recommendations
- ๆไบคๅ่ฏท็กฎไฟไปฃ็ ้่ฟๆๆๆฃๆฅ / Please ensure code passes all checks before submitting
:gitmoji: [type](scope): message
็คบไพ / Examples:
โจ feat(visualization): add new animation feature
๐ fix(arrows): resolve arrow connection issues
๐ chore(docs): update README documentation
An interactive Josephus problem visualization tool built with Vue 3 + Vite, featuring line-by-line code debugging and animated demonstrations.
Solving the pain point of beginners learning the Josephus problem: "understanding code but not logic"
Many students can understand each line of code when learning the Josephus problem, but cannot visualize the actual execution in their minds. This project uses a "left code + right debug-style animation" approach to help you:
- ๐ Watch Code: Left side highlights the current execution line
- ๐ฌ Visualize Process: Right side synchronously demonstrates linked list node movement and deletion
- ๐ Make Connections: Real-time connection between code and animation makes understanding abstract logic easy
No installation required - just open the web page and start using it!
Live Demo: https://chhsiching.github.io/josephus-visualizer/
This project is deployed on GitHub Pages. Click the link above to see it in action. The interface includes:
- Left Code Panel: Displays C code with current execution line highlighted
- Right Animation Panel: Shows Josephus ring animation with node movement and elimination
- Bottom Control Panel: Play, pause, step, and speed controls
- ๐ฏ Interactive Visualization: SVG-based circular linked list visualization with bidirectional pointers
- ๐ Line-by-Line Debugging: GDB-style C code execution with real-time highlighting
- โฏ๏ธ Complete Playback Controls: Play, pause, step execution, and speed adjustment
- ๐ Real-time Animation: Shows list construction, counting, and node elimination
- ๐จ Responsive Design: Gruvbox dark theme with screen size support
- ๐ Detailed Status Display: Shows current round, eliminated nodes, execution steps
The project is deployed on GitHub Pages and can be accessed directly:
https://chhsiching.github.io/josephus-visualizer/
# Clone the project
git clone https://github.com/chhsiching/josephus-visualizer.git
cd josephus-visualizer
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run previewThe Josephus problem describes: n people stand in a circle, starting from a specified person and counting clockwise. The person who counts to k is eliminated, and the next person restarts counting from 1. This process continues until all people are eliminated, determining the elimination order.
This project implements the Josephus problem using a doubly circular linked list:
- Node Structure: Each person is represented as a node with
id,next, andprepointers - List Construction:
RingConstructfunction creates a doubly circular linked list with N nodes - Counting Pattern: Uses repeating pattern [3, 5, 7, 13] as elimination bounds for each round
- Counting Function:
countfunction starts from a node and counts to find the node to be eliminated - Node Removal:
removeNodefunction removes the current node and reconnects the list
- Dual-Ring Arrow System: Outer ring shows next pointers (clockwise), inner ring shows prev pointers (counter-clockwise)
- Animation Phases: Initialization phase, counting phase, removal phase, completion phase
- State Synchronization: Precise synchronization between code line numbers and animation states
- Play/Pause: Click the play button to start automatic execution, click pause to stop
- Step Execution: Use forward/backward buttons to view algorithm execution step by step
- Speed Control: Supports 1x, 2x, 4x playback speeds
- Code Navigation: Click line numbers in the left code panel to jump to corresponding steps
- Reset: Click the reset button to restart the demonstration
- Left Panel: Displays C code with current execution line highlighted
- Right Panel: Circular visualization showing node states and pointer relationships
- Bottom Control Bar: Playback controls, progress display, speed adjustment, etc.
- Center Information: Shows current execution phase and round number
- Frontend Framework: Vue 3 (Composition API)
- Build Tool: Vite
- Styling: SCSS + Gruvbox dark theme
- Syntax Highlighting: Shiki
- Visualization: SVG
- Deployment: GitHub Pages + GitHub Actions
josephus-visualizer/
โโโ src/
โ โโโ components/ # Vue components
โ โ โโโ App.vue # Main application component
โ โ โโโ CodeDisplay.vue # Code display component
โ โ โโโ CircleAnimation.vue # Animation component
โ โ โโโ ControlPanel.vue # Control panel component
โ โ โโโ CircleNode.vue # Node component
โ โ โโโ CircleLink.vue # Link component
โ โโโ utils/ # Utility functions
โ โ โโโ josephus-simulator.js # Algorithm simulator
โ โโโ styles/ # Style files
โ โโโ gruvbox-dark.scss # Theme styles
โโโ public/
โ โโโ joseph-ring-algorithm.c # C algorithm source code
โโโ .github/workflows/ # GitHub Actions configuration
โ โโโ deploy.yml # Auto-deployment configuration
โโโ README.md
- Node Count: Fixed at 20 nodes
- Counting Pattern: Repeating pattern [3, 5, 7, 13]
- Animation Speed: Supports 1x, 2x, 4x speed adjustment
- Theme Configuration: Gruvbox dark theme
This project is licensed under the MIT License.
A: Refresh the page. If the issue persists, try reducing the playback speed (switch to 1x).
A: Current version is fixed at 20 people with [3, 5, 7, 13] counting pattern. Custom configuration may be supported in the future.
A: Some code lines (comments, function declarations) don't correspond to actual execution steps. Only actual execution lines are clickable.
A: Yes, but desktop is recommended for better experience. Mobile screens may feel cramped with the split-panel layout.
A: Recommended reading order:
src/utils/josephus-simulator.js- Algorithm simulator core logicsrc/App.vue- Main application component to understand overall structuresrc/components/CircleAnimation.vue- Animation rendering logicsrc/components/CodeDisplay.vue- Code highlighting display
Issues and Pull Requests are welcome to improve the project!
- Git commit messages follow gitmoji convention
- Code style follows Vue 3 official recommendations
- Please ensure code passes all checks before submitting
:gitmoji: [type](scope): message
Examples:
โจ feat(visualization): add new animation feature
๐ fix(arrows): resolve arrow connection issues
๐ chore(docs): update README documentation