An interactive Terminal User Interface (TUI) for real-time algorithm and data structure visualization
Project description
๐ lastcode
A sleek, terminal-based interactive visualizer for tree, graph, grid, and array algorithms. Built with Python and the Textual framework.
lastcode allows you to trace, step-through, and animate classic coding interview problems directly in your terminal with beautiful ANSI visuals, real-time variable inspection, a code stepper, and step-by-step explanations.
โจ Features
- Interactive ASCII Renderers: Visualized trees, grids, and arrays respond dynamically as the algorithm executes.
- Trace-Driven Replay: Leverages Python's execution tracing (
sys.settrace) to record and reconstruct step-by-step algorithm states. - Variable Inspector & Legend Panel: Keeps track of current variables, recursions, pointers, and color-coded state transitions.
- Integrated Code Stepper: Highlights the exact line of Python code running at each step of execution.
- Custom Input Support: Modify tree structures, grid dimensions, and array contents live in the application using standard format notation.
- Hot-Reloading Dev Runner: Active development watcher watches
.pyand.cssfiles and restarts the TUI instantly on change.
๐จ Color Palette & Themes
The visualizer runs a sleek, modern Tokyonight-inspired aesthetic:
- ๐ Background:
#252836E2230 - โก Accent Blue:
#7AA2F7 - ๐ฟ Success Green:
#9ECE6A - ๐ธ Warning/Pointer Yellow:
#E0AF68 - ๐น Critical/Path Red:
#F7768E
๐ Installation & Getting Started
Prerequisites
- Python:
>=3.11 - Package Manager:
brew,pipx,pip, oruv
Option 1: macOS Homebrew (Recommended)
The cleanest way to install on macOS without interacting with system Python environments or virtual environments.
# 1. Tap the repository
brew tap sunil-kumarr/tap
# 2. Install the application cleanly
brew install lastcode-tui
Option 2: via PyPI (pipx or pip)
Because modern operating systems enforce environment protections (PEP 668), installing standalone global terminal applications via standard pip install will often fail. Use pipx to run the tool in an isolated sandbox.
# Recommended for global installation:
pipx install lastcode-tui
# Alternatively, run instantly using uv without permanent installation:
uvx lastcode-tui
Option 3: Local Development (Source Build)
If you are planning to contribute or modify the visualizer core:
-
Clone the repository:
git clone https://github.com/sunil-kumarr/lastcode.git cd lastcode
-
Create and activate a virtual environment:
python3 -m venv .venv source .venv/bin/activate
-
Install the package in editable mode:
pip install -e .
๐น๏ธ Usage
Run the Visualizer
Once installed via any option above, start the interactive engine from anywhere in your terminal:
lastcode
For a local source checkout, you can also run the module directly:
python -m lastcode
Hot-Reloading for Development
If you are modifying code, stylesheets, or adding new problems, run the watcher script inside your source directory. It will instantly reload the application in the terminal when changes are saved:
python dev.py
๐ฎ Keybindings & Controls
๐ Home / Menu Screen
| Key | Action |
|---|---|
โ / โ |
Navigate the problem list |
t |
Cycle topic filters (tree, grid, graph, array, string, dp) |
d |
Cycle difficulty filters (easy, medium, hard) |
Enter |
Launch the selected visualizer |
q |
Quit application |
๐ ๏ธ Visualizer Screen
| Key | Action |
|---|---|
โ / l |
Step Forward to the next execution frame |
โ / h |
Step Backward to the previous execution frame |
Space |
Play / Pause auto-playback animation |
i |
Edit Input (Focuses input field to provide custom data structures) |
Enter |
Submit custom input (Parses, validates, and runs the visualizer on your input) |
Escape |
Home / Cancel input edit and return to main menu |
q |
Quit application |
๐๏ธ Custom Input Formats
You can press i on any visualization screen to customize the input. Values are parsed securely using Python's ast.literal_eval.
๐ณ Binary Trees
Binary trees are represented using level-order lists.
- Simple Binary Tree:
[1, 2, 3, None, 4](representing a tree with root1, children2and3, and leaf4on the right of2). - Path-Sum Tree Problems:
([1, 2, 3], 4)(a tuple containing the tree array and target integer). - Note: Maximum tree size supported is 31 nodes.
๐บ๏ธ Grids (Count Islands)
Grids are parsed as 2D lists of 0s (water) and 1s (land).
- Format:
[[1, 1, 0], [0, 1, 0], [1, 0, 1]](all rows must have equal width).
๐ข Arrays & Strings
- Two Sum:
[2, 7, 11, 15], 9(the array part, followed by a comma and target sum). - Valid Parentheses:
(){}[](a simple string of bracket characters).
๐ Project Structure
lastcode/
โโโ dev.py # Hot-reloading watcher script
โโโ pyproject.toml # Project dependencies and script endpoints
โโโ lastcode/
โ โโโ main.py # Main entrypoint
โ โโโ app.py # Main visualizer screens and layout controllers
โ โโโ home.py # Home screen widgetry and filters
โ โโโ recorder.py # Core logic tracer (tracks call frames and values)
โ โโโ theme.py # Central design-system colors
โ โโโ problems/ # Interactive problems repository
โ โ โโโ registry.py # Problem metadata & path registration
โ โ โโโ bt_inorder.py # Binary Tree Inorder Traversal
โ โ โโโ count_islands.py # Count Islands
โ โ โโโ ... (20+ algorithm modules)
โ โโโ renderers/ # UI renderers
โ โ โโโ base.py # Renderer protocol definitions
โ โ โโโ tree.py # Tree structure layout & animation renderer
โ โ โโโ grid.py # 2D Grid DFS/BFS layout renderer
โ โ โโโ array.py # 1D Array tracker & stack renderer
โ โโโ widgets/ # Reusable textual widgets
โ โโโ ... # Scrubber bars, Legend keys, variable drawers
๐ License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lastcode_tui-0.1.2.tar.gz.
File metadata
- Download URL: lastcode_tui-0.1.2.tar.gz
- Upload date:
- Size: 142.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1997a3b376b6db6c952963770e7012c9b65df1955e4d2be071961b10f75d06c1
|
|
| MD5 |
f6131ff27ea4703ee2fab99efe08eb3b
|
|
| BLAKE2b-256 |
c738da4dd7605ff45fedf5fbb01f4532e8af4ce438e612b61a241fd35c26192f
|
Provenance
The following attestation bundles were made for lastcode_tui-0.1.2.tar.gz:
Publisher:
publish.yml on sunil-kumarr/lastcode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lastcode_tui-0.1.2.tar.gz -
Subject digest:
1997a3b376b6db6c952963770e7012c9b65df1955e4d2be071961b10f75d06c1 - Sigstore transparency entry: 1624478628
- Sigstore integration time:
-
Permalink:
sunil-kumarr/lastcode@017705e7f8b2b690cedb1ac6ed65f75dd012d669 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/sunil-kumarr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@017705e7f8b2b690cedb1ac6ed65f75dd012d669 -
Trigger Event:
release
-
Statement type:
File details
Details for the file lastcode_tui-0.1.2-py3-none-any.whl.
File metadata
- Download URL: lastcode_tui-0.1.2-py3-none-any.whl
- Upload date:
- Size: 229.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96cf7ca79be8bb5d5527864c230df35fc62889147e31fd7bb29503b252cf3131
|
|
| MD5 |
023e1a97485a93fcae8b60ac19f6ff86
|
|
| BLAKE2b-256 |
cf594f1736f4e20bfa933c363e3c8044e0633d002d24c8735437589679c3ec76
|
Provenance
The following attestation bundles were made for lastcode_tui-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on sunil-kumarr/lastcode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lastcode_tui-0.1.2-py3-none-any.whl -
Subject digest:
96cf7ca79be8bb5d5527864c230df35fc62889147e31fd7bb29503b252cf3131 - Sigstore transparency entry: 1624478677
- Sigstore integration time:
-
Permalink:
sunil-kumarr/lastcode@017705e7f8b2b690cedb1ac6ed65f75dd012d669 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/sunil-kumarr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@017705e7f8b2b690cedb1ac6ed65f75dd012d669 -
Trigger Event:
release
-
Statement type: