Skip to content

Instantly share code, notes, and snippets.

@devflow
Last active Jan 18, 2020
Embed
What would you like to do?
369game (three six nine game) with RUST!
//three six nine. 369 game
fn main() {
for n in 1..100 {
let mut cur_num: u32 = n;
let mut clap_cnt: u32 = 0;
while cur_num > 0 {
let cur_x:u32 = cur_num % 10;
clap_cnt += match cur_x {
3 | 6 | 9 => 1,
_ => 0
};
cur_num /= 10;
}
if clap_cnt > 0 {
for _c in 0..clap_cnt {
print!("clap! ");
}
print!("\n");
} else {
println!("{}", n);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment