Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub fn aoc3_1() -> u32 {
- (|num| num * (!num & 0b111111111111))(read_file(&Path::new("inputs/aoc3/input.txt")).fold(
- vec![0; 12],
- |acc, line| acc.into_iter()
- .zip(line.chars())
- .map(|(acc, ch)| if ch == '0' { acc as i32 - 1 } else { acc as i32 + 1 })
- .collect())
- .into_iter()
- .zip(0..)
- .map(|(a, pow)| ((a.signum() + 1) / 2) as u32 * 2_u32.pow(pow))
- .sum())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement