[rs] Solve 2022_10 part 2

This commit is contained in:
Joscha 2022-12-10 15:16:06 +01:00
parent 745a205492
commit 1b2128d709
3 changed files with 26 additions and 2 deletions

View file

@ -1,2 +1,8 @@
Part 1: 12880
Part 2: ???
Part 2:
####..##....##..##..###....##.###..####.
#....#..#....#.#..#.#..#....#.#..#.#....
###..#.......#.#..#.#..#....#.#..#.###..
#....#.......#.####.###.....#.###..#....
#....#..#.#..#.#..#.#....#..#.#.#..#....
#.....##...##..#..#.#.....##..#..#.####.

View file

@ -44,4 +44,16 @@ pub fn solve(input: String) {
.map(|i| run.history[i - 1].x * i as i32)
.sum::<i32>();
println!("Part 1: {part1}");
println!("Part 2:");
for chunk in run.history.chunks(40) {
for (x, state) in chunk.iter().enumerate() {
if (x as i32).abs_diff(state.x) <= 1 {
print!("#");
} else {
print!(".");
}
}
println!();
}
}

View file

@ -1,2 +1,8 @@
Part 1: 13140
Part 2: ???
Part 2:
##..##..##..##..##..##..##..##..##..##..
###...###...###...###...###...###...###.
####....####....####....####....####....
#####.....#####.....#####.....#####.....
######......######......######......####
#######.......#######.......#######.....