Skip to content

hmZa-Sfyn/CollatzVisualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Collatz Visualizer

A C++ application that simulates the Collatz (3x+1) conjecture, stores results in JSON files, and provides a web interface to visualize sequences in real time.


📦 Description

CollatzVisualizer is a C++ web server that:

  • Computes the Collatz sequence for a given number.
  • Saves it to ./computated/<number>.json.
  • Serves a live webpage with a Chart.js line graph and output data.

🧰 Prerequisites

✅ OS

  • Linux (tested on Ubuntu; adaptable)

✅ Dependencies

  • g++ (C++17-compatible compiler)
  • libboost-all-dev
  • git, curl

✅ Libraries

  • Crow (v1.2.0) — single header web framework
  • nlohmann/json (v3.11.3)

🛠️ Installation

🔁 Clone the Repository

git clone https://github.com/your-username/CollatzVisualizer.git cd CollatzVisualizer

⚙️ Run the Setup Script

chmod +x setup_and_run.sh ./setup_and_run.sh --install

This will:

  • Install packages and dependencies
  • Download headers
  • Compile the server
  • Create computated/ output folder

🧪 Example Output

File: ./computated/6.json

{ "number": 6, "sequence": [6, 3, 10, 5, 16, 8, 4, 2, 1], "steps": 8, "max_value": 16 }

🧑‍💻 Running the App

▶️ Start Web Server

./setup_and_run.sh --run

Open your browser and go to:
http://localhost:8080

🧮 Interface Features

  • Input any number.
  • Visualize the sequence steps.
  • See chart and JSON output.
  • JSON is saved to ./computated/.

📋 Usage Options

./setup_and_run.sh --help
  • --install : Install and compile
  • --run : Start the web server
  • --clean : Remove the compiled binary

❓ Troubleshooting

curl (23) error:

sudo chmod -R u+w include

Or download manually:

mkdir -p include/nlohmann curl -L https://github.com/nlohmann/json/releases/download/v3.11.3/json.hpp -o include/nlohmann/json.hpp

asio.hpp missing?

sudo apt-get install -y libboost-all-dev


📂 Project Structure

CollatzVisualizer/ ├── collatz_webserver.cpp ├── setup_and_run.sh ├── computated/ ├── include/ │ ├── crow.h │ └── nlohmann/ │ └── json.hpp

🤝 Contributing

PRs and issues welcome on GitHub.


📄 License

MIT License.

About

A C++ application that simulates the Collatz conjecture, stores sequences in JSON files, and provides a web interface to visualize sequences in real time and test new numbers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors