Skip to content

Commit ce6101d

Browse files
committed
Add day10b
1 parent e7d8e2d commit ce6101d

File tree

4 files changed

+209
-0
lines changed

4 files changed

+209
-0
lines changed

day10b/Cargo.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

day10b/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "day10b"
3+
version = "0.1.0"
4+
authors = ["Tim Visee <3a4fb3964f@sinenomine.email>"]
5+
edition = "2021"
6+
7+
[lib]
8+
path = "src/main.rs"
9+
10+
[dependencies]
11+
atoi = "2"

day10b/input.txt

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
noop
2+
addx 26
3+
addx -21
4+
addx 2
5+
addx 3
6+
noop
7+
noop
8+
addx 23
9+
addx -17
10+
addx -1
11+
noop
12+
noop
13+
addx 7
14+
noop
15+
addx 3
16+
addx 1
17+
noop
18+
noop
19+
addx 2
20+
noop
21+
addx 7
22+
noop
23+
addx -12
24+
addx 13
25+
addx -38
26+
addx 5
27+
addx 34
28+
addx -2
29+
addx -29
30+
addx 2
31+
addx 5
32+
addx 2
33+
addx 3
34+
addx -2
35+
addx -1
36+
addx 8
37+
addx 2
38+
addx 6
39+
addx -26
40+
addx 23
41+
addx -26
42+
addx 33
43+
addx 2
44+
addx -37
45+
addx -1
46+
addx 1
47+
noop
48+
noop
49+
noop
50+
addx 5
51+
addx 5
52+
addx 3
53+
addx -2
54+
addx 2
55+
addx 5
56+
addx 5
57+
noop
58+
noop
59+
addx -2
60+
addx 4
61+
noop
62+
noop
63+
noop
64+
addx 3
65+
noop
66+
noop
67+
addx 7
68+
addx -1
69+
addx -35
70+
addx -1
71+
addx 5
72+
addx 3
73+
noop
74+
addx 4
75+
noop
76+
noop
77+
noop
78+
noop
79+
noop
80+
addx 5
81+
addx 1
82+
noop
83+
noop
84+
noop
85+
addx -7
86+
addx 12
87+
addx 2
88+
addx 7
89+
noop
90+
addx -2
91+
noop
92+
noop
93+
addx 7
94+
addx 2
95+
addx -39
96+
noop
97+
noop
98+
addx 5
99+
addx 2
100+
addx -4
101+
addx 25
102+
addx -18
103+
addx 7
104+
noop
105+
addx -2
106+
addx 5
107+
addx 2
108+
addx 6
109+
addx -5
110+
addx 2
111+
addx -22
112+
addx 29
113+
addx -21
114+
addx -7
115+
addx 31
116+
addx 2
117+
noop
118+
addx -36
119+
addx 1
120+
addx 5
121+
noop
122+
addx 1
123+
addx 4
124+
addx 5
125+
noop
126+
noop
127+
noop
128+
addx 3
129+
noop
130+
addx -13
131+
addx 15
132+
noop
133+
addx 5
134+
noop
135+
addx 1
136+
noop
137+
addx 3
138+
addx 2
139+
addx 4
140+
addx 3
141+
noop
142+
addx -3
143+
noop

day10b/src/main.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use std::io::{stdout, Write};
2+
3+
pub fn main() {
4+
let (mut c, mut x, mut t) = (0, 1, Vec::with_capacity(40 * 60));
5+
6+
for i in include_bytes!("../input.txt").split(|b| b == &b'\n') {
7+
t.push((x - 1 <= c % 40 && x + 1 >= c % 40) as u8 * 3 + 32);
8+
c += 1;
9+
if &i[0..4] == b"addx" {
10+
t.push((x - 1 <= c % 40 && x + 1 >= c % 40) as u8 * 3 + 32);
11+
c += 1;
12+
x += atoi::atoi::<isize>(&i[5..]).unwrap() as i32;
13+
}
14+
}
15+
16+
let mut stdout = stdout().lock();
17+
t.chunks(40).for_each(|l| {
18+
stdout.write_all(l).unwrap();
19+
stdout.write_all(b"\n").unwrap();
20+
});
21+
}

0 commit comments

Comments
 (0)