Make tweaks to day 10 code to make it clearer
This commit is contained in:
parent
76705dc6fb
commit
efa81418eb
11
day10.chpl
11
day10.chpl
|
@ -13,11 +13,12 @@ iter ops() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const deltas = ops();
|
const deltas = ops(),
|
||||||
const states = + scan deltas;
|
cycles = deltas.size,
|
||||||
const indices = 20..220 by 40;
|
states: [1..cycles] int = + scan deltas,
|
||||||
writeln(+ reduce (states[indices-1] * indices));
|
interesting = 20..220 by 40;
|
||||||
|
writeln(+ reduce (states[interesting] * interesting));
|
||||||
|
|
||||||
const pixels = [(x, pc) in zip(states[0..<240], 0..)]
|
const pixels = [(x, pc) in zip(states[1..240], 0..)]
|
||||||
if abs((pc % 40) - x) <= 1 then "#" else " ";
|
if abs((pc % 40) - x) <= 1 then "#" else " ";
|
||||||
writeln(reshape(pixels, {1..6, 1..40}));
|
writeln(reshape(pixels, {1..6, 1..40}));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user