diff --git a/day3/part1/main.d b/day3/part1/main.d index a6766f1..df48eda 100644 --- a/day3/part1/main.d +++ b/day3/part1/main.d @@ -5,14 +5,13 @@ void main() File("input", "r").byLineCopy.array.countTrees(3, 1).writeln; } -ulong countTrees(T)(T input, int angleX, int angleY) +ulong countTrees(const char[][] input, int angleX, int angleY) in(input.length > 0) { immutable width = input[0].length; - size_t count = 0; size_t x = 0; return input.stride(angleY).map!((row) { - auto result = row[x]; + immutable result = row[x]; x = (x + angleX) % width; return result; }) @@ -35,5 +34,4 @@ unittest .#..#...#.#`.byChar.splitter("\n").map!array.array; assert(input.countTrees(3, 1) == 7); - } diff --git a/day3/part2/main.d b/day3/part2/main.d index 76a1315..088c826 100644 --- a/day3/part2/main.d +++ b/day3/part2/main.d @@ -19,7 +19,7 @@ in(input.length > 0) immutable width = input[0].length; size_t x = 0; return input.stride(angleY).map!((row) { - auto result = row[x]; + immutable result = row[x]; x = (x + angleX) % width; return result; })