mic

Crates.iomic
lib.rsmic
version0.1.0
sourcesrc
created_at2021-10-09 09:00:46.635532
updated_at2021-10-09 09:00:46.635532
descriptionFacilitates answering to competitive programming problems.
homepage
repositoryhttps://github.com/qryxip/mic
max_upload_size
id462727
size21,760
Ryo Yamashita (qryxip)

documentation

README

mic

CI Rust 2018 1.42.0+ Crates.io Crates.io

Facilitates answering to competitive programming problems.

This crate is intended to be used with cargo-equip, which is a tool to bundle code into single .rs file.

Usage

See the documentation on Docs.rs.

Examples

use mic::{answer, solve};
#[answer]
fn main() -> _ {
    1
}
// 1 → println!("{}", 1)
#[answer(yn("Yes", "No"))]
fn main() -> _ {
    true
}
// true → "Yes"
//      → println!("{}", "Yes")
#[answer(tuple(" "))]
fn main() -> _ {
    (42, "foo")
}
// (42, "foo") → "42 foo".to_owned()
//             → println!("{}", "42 foo".to_owned())
#[answer(join("\n"))]
fn main() -> _ {
    1..=3
}
// 1..=3 → "1\n2\n3".to_owned()
//       → println!("{}", "1\n2\n3".to_owned())
#[answer(matrix(" "))]
fn main() -> _ {
    vec![vec![1, 2], vec![3, 4]]
}
// vec![vec![1, 2], vec![3, 4]] → "1 2\n3 4".to_owned()
//                              → println!("{}", "1 2\n3 4".to_owned())
#[answer(join(" "), map(add(1)))]
fn main() -> _ {
    vec![0, 2, 4] // 0-based graph node indices
}
// vec![0, 2, 4] → { impl Iterator } ([1, 3, 5])
//               → "1 3 5".to_owned()
//               → println!("{}", "1 3 5".to_owned())
#[solve(join(" "))]
fn solve() -> _ {
    1..=3
}
// 1..=3 → "1 2 3".to_owned()

assert_eq!("1 2 3", solve());

License

Licensed under CC0-1.0.

Commit count: 8

cargo fmt