1
0
This commit is contained in:
2026-02-04 11:15:03 +08:00
commit 8b20a5dd21
125 changed files with 4177 additions and 0 deletions

7
problems/p112/Cargo.toml Normal file
View 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
View 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}")
}