import std.algorithm; import std.format; import std.range; import std.stdio; import std.uni; void run(string[] args) { ulong count = stdin.byLine.countTrees; writeln(count); } ulong countTrees(Range)(Range lines) if (isInputRange!Range) { return lines.enumerate.filter!(x => (x.value[x.index * 3 % x.value.length] == '#')).count; } unittest { string[] field = [ "..##.........##.........##.........##.........##.........##.......", "#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..#...#...#..", ".#....#..#..#....#..#..#....#..#..#....#..#..#....#..#..#....#..#.", "..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#..#.#...#.#", ".#...##..#..#...##..#..#...##..#..#...##..#..#...##..#..#...##..#.", "..#.##.......#.##.......#.##.......#.##.......#.##.......#.##.....", ".#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#.#.#.#....#", ".#........#.#........#.#........#.#........#.#........#.#........#", "#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...#.##...#...", "#...##....##...##....##...##....##...##....##...##....##...##....#", ".#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#.#..#...#.#" ]; assert(field.countTrees == 7); }