| Crates.io | cliard24 |
| lib.rs | cliard24 |
| version | 0.1.0 |
| created_at | 2026-01-07 06:07:15.801356+00 |
| updated_at | 2026-01-07 06:07:15.801356+00 |
| description | cliard24 is a command-line 24-point card game. It provides two main functions: the game mode allows you to play the classic 24-point game interactively in the terminal, where you randomly draw 4 cards and use addition, subtraction, multiplication, division, and parentheses to reach 24; the solve mode lets you input any combination of numbers and a target value to calculate all possible expression solutions. The tool supports customizable attempt limits, endless mode, solution count limits, and mixed input of card letters (A/J/Q/K) and numbers. |
| homepage | |
| repository | https://github.com/Expien1/cliard24 |
| max_upload_size | |
| id | 2027595 |
| size | 343,675 |
The project name is a combination of CLI (Command Line Interface), Card, and 24 (game objective), indicating a 24-point game played through the command line.
cliard24 is a 24-point card game implemented in Rust that runs in the command line interface. It offers two modes:
๐ What is the 24-point game?
The 24-point game is a classic mathematical puzzle where players use addition, subtraction, multiplication, and division to combine the values of 4 playing cards to make 24.
cargo install cliard24
After successful installation, the executable will be placed in Cargo's binary directory (typically ~/.cargo/bin/)
git clone https://github.com/Expien1/cliard24.git
cd cliard24
cargo build --release
After successful compilation, the executable is located at ./target/release/cliard24
# Start interactive game (using default parameters)
cliard24
# Explicitly specify game mode
cliard24 play
# Endless mode (unlimited rounds, suitable for practice)
cliard24 play --endless
# Customize attempt limit and solution display limit
cliard24 play --max-attempts 5 --limit 3
Parameter Description:
--max-attempts or -a: Maximum attempts per round (default: 3, 0 means unlimited)--limit or -l: Limit on the number of solutions displayed (default: 1, 0 means display all)--endless or -e: Enable endless mode (default: false)# Solve classic 24-point puzzle (3,3,8,8)
cliard24 solve 3 3 8 8
# Custom target value (find expressions for 1,2,3,4 to reach 10)
cliard24 solve 1 2 3 4 --target 10
# Limit displayed solution count (avoid excessive output)
cliard24 solve 1 2 3 4 5 --limit 5
Parameter Description:
--target or -t: Target value (default: 24)--limit or -l: Limit on the number of solutions displayed (default: 0, display all)+), subtraction (-), multiplication (*), and division (/) are allowedIn game mode, the following expression types are supported:
| Type | Example | Description |
|---|---|---|
| Numbers Only | (3+3)*(2+2) |
Direct number input |
| Card Letters | (K-j)*Q*a |
Use card letters (case-insensitive) |
| Mixed Use | (13-j)*12*A |
Numbers + letters |
In game mode, in addition to entering expressions, the following commands are available:
| Command | Short | Function Description |
|---|---|---|
help |
h |
Display game rules and command help |
nosol |
n |
Declare no solution for current hand (system will verify correctness) |
stats |
s |
Display current game statistics |
pass |
p |
Skip current hand (surrender) |
quit |
q |
Exit game |
clap, rand, thiserror)cliard24/
โโโ src/
โ โโโ main.rs # Command line entry, parameter parsing and dispatch, depends on clap
โ โโโ expression/
โ โ โโโ mod.rs # Expression tree module exports
โ โ โโโ ast.rs # Expression tree data structure and basic operations (including evaluation)
โ โ โโโ parser.rs # Expression string parser
โ โ โโโ solver.rs # Expression solver (exhaustive search)
โ โ โโโ error.rs # Expression tree error type definitions, depends on thiserror
โ โโโ playing_cards/
โ โ โโโ mod.rs # Playing card simulation module exports
โ โ โโโ card.rs # Playing card data structure representation and ASCII rendering
โ โ โโโ generator.rs # Deck management and random card drawing, depends on rand
โ โโโ tui/
โ โโโ mod.rs # TUI interaction module exports
โ โโโ game_mode.rs # Interactive game main loop
โ โโโ solve_mode.rs # Solver mode input processing
โ โโโ error.rs # Game error type definitions, depends on thiserror
โโโ Cargo.toml # Project configuration and dependency declaration

After completing the code development for this project, I used AI to check code readability and generate English comments. The AI helped optimize some variable names, function names, and added detailed English comments. If you want to view the original version of the code comments, you can check the Git history.
I personally believe there are many benefits to using AI to help review code readability and write comments. First, it increases writing efficiency; second, AI's comment style and terminology are more consistent; and I found that the quality of comments written by AI is higher than my handwritten onesโit helps me express my design intentions more clearly.
Although AI-generated comments are useful, it's important to be cautious about AI-generated content. For complex or incorrect logic, AI might misunderstand or further deepen errors, so complex logic code and the generated comments still require manual review.
This project is a personal learning project, and my implementation represents just one feasible approach.