https://github.com/twil3akine/keta
A lightweight, zero-dependency Rust crate for digit operations (decomposition, sum, reverse, radix support), designed for competitive programming.
https://github.com/twil3akine/keta
algorithm atcoder competitive-programming digits math rust zero-dependency
Last synced: 13 days ago
JSON representation
A lightweight, zero-dependency Rust crate for digit operations (decomposition, sum, reverse, radix support), designed for competitive programming.
- Host: GitHub
- URL: https://github.com/twil3akine/keta
- Owner: Twil3akine
- License: mit
- Created: 2026-01-03T15:56:28.000Z (24 days ago)
- Default Branch: master
- Last Pushed: 2026-01-05T13:30:28.000Z (22 days ago)
- Last Synced: 2026-01-13T19:45:56.404Z (14 days ago)
- Topics: algorithm, atcoder, competitive-programming, digits, math, rust, zero-dependency
- Language: Rust
- Homepage: https://crates.io/crates/keta
- Size: 23.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Keta
A lightweight, zero-dependency Rust crate for digit operations, designed for competitive programming (AtCoder, etc.).
[](https://crates.io/crates/keta)
[](https://docs.rs/keta)
[](https://opensource.org/licenses/MIT)
## Features
- **Zero Dependencies**: Depends only on `std`. Fast compile times.
- **Digit Manipulation**: Easily decompose numbers into digits (`digits()`), sum them (`digit_sum()`), or reverse them (`reverse()`).
- **Radix Support**: Handle binary, octal, hexadecimal, or any base-N operations (`digits_radix(2)`).
- **Useful Utilities**: Product of digits (`digit_product()`), check digit existence (`contains_digit()`), or rearrange digits (`make_max()`, `make_min()`).
- **Competitive Programming Ready**: Optimized for speed, perfect for problems involving digit sums, palindromes, or base conversion.
## Installation
Add this to your `Cargo.toml`:
```toml
[dependencies]
keta = "0.3.3"
```
## Usage
```rust
use keta::Keta;
fn main() {
// 1. Decomposition (Decimal & Radix)
let n = 12345;
assert_eq!(n.digits(), vec![1, 2, 3, 4, 5]);
assert_eq!(6.digits_radix(2), vec![1, 1, 0]); // 6 in binary is 110
// 2. Aggregation (Sum & Product)
assert_eq!(n.digit_sum(), 15); // 1+2+3+4+5 = 15
assert_eq!(123.digit_product(), 6); // 1*2*3 = 6
assert_eq!(6.digit_sum_radix(2), 2); // 1+1+0 = 2
// 3. Rearrangement & Properties
assert_eq!(2026.make_max(), 6220);
assert_eq!(2026.make_min(), 226);
assert!(12345.contains_digit(3));
assert!(12321.is_palindrome());
assert_eq!(n.reverse(), 54321);
}
```
## License
This project is licensed under the [MIT LICENSE](LICENSE).