Compare commits

...

2 Commits

Author SHA1 Message Date
Danila Fedorin 5f2cb7c7ee Cleaned up Chapel solution 2022-12-09 22:58:39 -08:00
Danila Fedorin e26f41cd68 Initial Chapel solution 2022-12-09 22:57:22 -08:00
1 changed files with 23 additions and 0 deletions

23
day10.chpl Normal file
View File

@ -0,0 +1,23 @@
use IO, Map;
iter ops() {
yield 1; // Initial state
for line in stdin.lines().strip() {
select line[0..3] {
when "noop" do yield 0;
when "addx" {
yield 0;
yield line[5..] : int;
}
}
}
}
const deltas = ops();
const states = + scan deltas;
const indices = 20..220 by 40;
writeln(+ reduce (states[indices-1] * indices));
const pixels = [(x, pc) in zip(states[0..<240], 0..)]
if abs((pc % 40) - x) <= 1 then "#" else " ";
writeln(reshape(pixels, {1..6, 1..40}));