init
This commit is contained in:
7
problems/p112/Cargo.toml
Normal file
7
problems/p112/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "p112"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
rayon = "1.11.0"
|
||||
32
problems/p112/src/main.rs
Normal file
32
problems/p112/src/main.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
fn is_bou_num(num: u32) -> bool {
|
||||
if num < 100 {
|
||||
return false;
|
||||
}
|
||||
let str_num = num.to_string().chars().collect::<Vec<_>>();
|
||||
let prev_con = str_num[0] >= str_num[1];
|
||||
for window in str_num.windows(2).skip(1) {
|
||||
let a = window[0];
|
||||
let b = window[1];
|
||||
if prev_con != (a >= b) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
#[test]
|
||||
fn test() {
|
||||
assert!(is_bou_num(155349));
|
||||
assert!(!is_bou_num(123456));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut counter = 0;
|
||||
for i in 0..=21780 {
|
||||
if is_bou_num(i) {
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
todo!();
|
||||
let percentage = counter as f64 / 21780f64;
|
||||
println!("{percentage}")
|
||||
}
|
||||
Reference in New Issue
Block a user