Add README and solution for day4
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
use itertools::Itertools;
|
||||
|
||||
fn main() {
|
||||
let passwords = (152_086_usize..670_282_usize)
|
||||
.map(|x| x.to_string().chars().collect::<Vec<char>>())
|
||||
.filter(|x| x.iter().zip(x.iter().skip(1)).all(|(x,y)| x <= y))
|
||||
.filter(|x| {
|
||||
for (_,g) in &x.iter().group_by(|&y| y) {
|
||||
if g.count() == 2 {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
})
|
||||
.count();
|
||||
|
||||
println!("Solution: {:?}", passwords);
|
||||
}
|
||||
Reference in New Issue
Block a user