From 825cf4489400b0d63942e39f3552fb6fc78dff51 Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Fri, 4 Dec 2020 09:27:43 +0100 Subject: [PATCH] day3: cleanup --- day3/part1/main.d | 6 ++---- day3/part2/main.d | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) 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; })