public static void Main()
treeCount = CountTrees(new StringReader(input), 1, 1);
Console.WriteLine("{0} trees", treeCount);
treeCount = CountTrees(new StringReader(input), 3, 1);
Console.WriteLine("{0} trees", treeCount);
treeCount = CountTrees(new StringReader(input), 5, 1);
Console.WriteLine("{0} trees", treeCount);
treeCount = CountTrees(new StringReader(input), 7, 1);
Console.WriteLine("{0} trees", treeCount);
treeCount = CountTrees(new StringReader(input), 1, 2);
Console.WriteLine("{0} trees", treeCount);
Console.WriteLine("{0} trees total", total);
private static int CountTrees(StringReader inputReader, int dx, int dy)
while((currentLine = inputReader.ReadLine()) != null)
if(currentLine[hPos].Equals('#'))
hPos = (hPos + dx) % currentLine.Length;
private static string input = @"..#..#......###.#...#......#..#
...#.....#...#...#..........#..
....#.#...............#.#.#....
.........#.......##............
#.#....#.#####.##.#........#..#
.....#...##.#..#.##...#.#..#...
#.#..###.#........#....##...#.#
..###.....#..###.....##........
#.#.#...........#.....#.#....##
...#.#.##.##.#.#......#...##.#.
.....##.#..#....#..#...##...###
...#.....#..#..#...#.#....##...
.#...##.#.........#...#.#......
....#...#.....#......#...#.....
.#...#.....#....#......#...#...
#...#......####..##...###......
....#..#......##.##.....#..#...
....#....#.......#..#...#....#.
...##..#.##..#.#...#..##.......
##.#..#.....#.##.#....#..##....
#....#....#.....#..#.#.#.....#.
##...#.###.....#....#..#.#.#...
#..#.......#...#.#...#.#.....#.
....#.#.......#.....###..#..#.#
......####...#.#..#..#.#.#.#...
#...##.....#...#.#.........#.#.
......#...##.#..#.#........#...
..#.#...........#..##...###.##.
#......#.#......#.....#.....#.#
.#...............###.#.###.....
...#...........##..#...##..##.#
#......#.##.#............#.##.#
.#.#....#....###........#..#...
...##.#.#..#.##.#..##..#.##..##
.....#...#.#.#...#....#......#.
..............#...##...........
..............##........#..###.
.#.##.......#.....##.#......#..
..#......#..#.#####..#.#.......
#.#..#...#.#..#....#..#.##..#..
...##.......#.#............#...
...#....#..#.##.###.......#.###
..###..#....#..#.....##...#..#.
..#.###.##......###....#....##.
...#...##...###....##.....###.#
.....#.....#.#.#.........#..###
#.#......#.#..#.####..#........
#....#.##.......##.............
..##...........#....#.....##..#
..#...#...........#....#...#...
...#...#...#.....#..#....#....#
#......##.........#.#...##...#.
.##..#...#.....#....#.##.####.#
#..##.##.#......#.............#
.#.....#..##.###.#.#.#.........
.###....###..#....#..#.#.#..##.
....#........#..#....##..#.#.#.
.....#..........#..........#...
.#.##..#..#...#..#.##.#.##.....
.#....#...#......#.#..##.##..#.
.###.#...#.#.##....#.....#..##.
......##.......#..#.......#.#.#
.##.#.#.#......#.......#.......
#..#...##......#.......#......#
...#..#...##.#...#..##.........
.....#..###...##...#..#.#...#.#
..#.#.#....##..#.#.#.#...#.....
.....#.#.#..#..#.#.#...#.......
#.#.#...#.#.....#.#.#.##.###...
.....#.#.....####..#...........
..#.#.#...........##..#.#....#.
.#..#......#..#...........###..
..#...###.##......#..###...#..#
#.#..#.....#..#.##.#..#.#.....#
.....................#.#..#....
...##..##...#.#..#..##.#....#..
.#..#.#....#...#.#.##..........
....##.....#..#..##.........##.
..##...##........#.#....#...###
.#...#............#.#.#.#......
#...#........#..#..#...#.#.....
..#..........#.......###.##....
#...........###..#....##..#.##.
##...#..#.##.....#...........#.
.#..##.....#..#.#.....##.#..#.#
..#..#.##....#.........#.#.#...
#..#...#...#..#...........##...
.....#.......#.#......#.#.#...#
..#.#..#..#.#.#.......#.#...#..
......#.....##.....#.....##.##.
#.#..#......#......#.####.##...
.####...#####.#....#.#..##.....
............#....#....#....##..
###.........#............#.#...
...#...#....#.##..#...#......##
...##.#.#.##.##.#.....#...#.#..
...#.....#...#..##......#.#.##.
.##.#......##................##
......#.....#..##.............#
#.#...##..#..#..#.##.....#..#..
#......###.....#....##...##...#
....#..#.....#.......####...##.
#.#...#.#...#..........#..##..#
....#..#....#................##
.####..#........#..#.#...#.....
##.###...#.##........#..##.....
..###..##...#...#..#...##.....#
......#..##....................
.#...#......#.#.##..#........#.
..#...#####.....##.....#...#...
.#..#....#..#....##.#....#..##.
.#.....##..###.#.....#.#.#.##..
#..##.....##...#.....#..#.#....
#.##......#.#......#..........#
#####........#.............#...
.#..#..##..#....#.....#..####..
...#..##.##...####....#.##...##
..........#....#...........##.#
#...##...#...##....#.....#.....
.......#..#.....#.#.#.#.#.....#
...#..##..####..#..##.#.##....#
#...#...#...........#.#.....#.#
..#.....##...###.........#..##.
.......##..#.......#.......##..
#.#....#....#.###............#.
...#......#.#.............#.#..
......#..#....#....#....#..#...
.....##..#...........##...#.##.
..#....#.##.#......#...........
#...#....#.#.#.#.#..#..........
.#..#..........#..#.#.....#....
.....##......##....#.#.....#.#.
.....#..#..........#....#.....#
....#..#..#.#...#.#..#..#..##.#
.#..##.#..##...###.#..........#
..###..#......#...##...#.#.....
..#...#...#.....#.......#....#.
#...##..#.##.#....##.....#.....
..#.#.....#...#...#............
.......#.#.#..#.....###.#...##.
....##.......#####...##..##..#.
#...#.##.....#.#...##.........#
..#.##..........#..###.#....#..
#......#.##...#...#.....###....
................#.##...........
##.###.#.#.#.##......##..#....#
..#.#........##..#..##.........
###....#..#....#..##....#.....#
#......#..#...........#.#...##.
...###.......#...#......##..#.#
.......#...##.#.#...#.##......#
......##..#...##.#.#...##....#.
..#...#...#...#.#.....#..##..#.
..##...#.....#.....#..##.......
....#........#.#.##.......#.#..
#...#..##..#..##..#...#......#.
...#..#.#.#..#..#..####...#....
#..#..#......#......#..#.######
#..#..#..#........#..#.#....###
#..##..#.#.##.....#..#......#.#
##.......##.#..#.............#.
..........#.#..#..#............
....#.#.#.#...#......#......#..
###.#.#.........#.......#...##.
#.............####..#...#.##...
....##.......#................#
###...#..#......##....#.####.#.
..##.##.#.#.#.#...#.......#...#
.....#.##......#.......##..#.#.
.#...#.##..#.......#.#....#.#.#
##...##..#....#..#...#....#....
..........#...##.#..##.......##
#.#...#....#......#.#.......###
......#...#.##....#....##.#.##.
..#..#.......#.......#....##...
##..##.......##............#.#.
.#.#...#..#.#.###......#.......
#...#..##....#...###..#.#.....#
.#.....#........#..##.#.#.#....
..#.##....#..#...........#...#.
.....#.#...#.##..###...#...#...
#....####.......#..#.#...#.....
....#.....#....##..#.##.....###
........#.#.....###....#.#.....
...#.....#.##.....#......#.....
.....#...####......###..#...##.
#.#......#..........#..##.#..#.
..##......###...#...#.......#..
#...#.#...#.#.........#........
....#..#.##.#.##.###..#.....#..
.#.#.#......#.#........#.....#.
.....#.#..#....#...#.....#.#.##
##.............#..#.....#.#....
#............#..#....##......##
#....#......#......#....##..#..
.#....#............#......##..#
..#.#.#..#.#....##.#.......#.##
#.##.....#...#......#...#......
.......#...........#..#.##..#.#
##.....##.#.....####..........#
...#.......#.#.............#..#
...##........##..#..#.#........
.#.##...#.....##.#......#....#.
.#................#.#...#..#...
#....#.#.#......#.#.#.##....#..
..#......#............#...#....
###..#.##........#....##.#...#.
.#..#..#......##...............
....##.............#....##...##
..#.#..#.#####....##.......###.
......#...#..#.#....#.#..#...#.
.........#..##.##...#....##..##
.............#.##....###.#.....
..#................#..#.#..#...
...#........#......#..###......
.#.#.#....#.........#...###.###
.........#..#.#......##.....#..
#...##..#.#.###..###...........
...#.#.#..#......#..##.#.##....
.....##.......#................
.##....#.#.#.##.....#.##......#
...#........#...##.#.##..##...#
..#..........#.#......####..##.
............#.#.#.#.....#......
..##.####.#..#....#..#..##.....
......#........#...#..#.#..###.
#.#..............#..#...#..#...
....#............#...#..#...##.
..##....#...##.##.#..........##
..#..#.........#..#.....#.#....
#.....#.###...##...##...##.....
#.#...#..#####.#...#..#.....#..
..#.....###...#.........#.#...#
....#.##.........#.#.....#.#.#.
..........##...#....#.#.#.....#
...#...........#.....###.......
#....#..#...#.....#.......#....
.#.#.....#..##..##..#........#.
.#.#.....#....#...#.#.##.......
....###...#...###.##....#......
...#.#.##....#...##......#...#.
#....#...##.....#.##.#.....#.##
.#.#.....##.##.##..###...#.....
.#.#......#..#..#........#.#..#
........#...##........##...#...
.#..#.#.#..#.....#....#...#.#..
#......#...#.#...#..#.#..#.....
.#......#.....#.........###.#..
#..#..........##..###.......#..
#..#..#....#......#......#.....
......#.....##.........##....#.
#..#.#...#...#.##.#..#..##.....
....#.#....###..#.....#...##.#.
..##.....##.#..#..##..#.#......
.........#..#....###...#.#....#
.........#...#...#...#......##.
.......#..#.....#.#.#...#...#..
............#.....###......#..#
#....##..###.......#...##....##
..#.##..#####..##.#...#......#.
#.#..#...###.............#.#...
##...#..#..#.#....#.#.......#..
.....#....##.....###.##..#.....
......##..##..#.#..####.#......
..#...#.#....#...#.#.........#.
##.....#.#....#..#..##........#
...........#..#........##..#...
..##.#...#.#.#..##..#..#..#..##
..........#.###.....#..#.....#.
......#............###..##.##..
.#.......#..#...........#.###.#
#...#..##............##.......#
.###..#...#.#....#....#......#.
..##.........##............#.#.
.##.......##....#.#.#....#..#.#
#.##........#.....#.##...#.#...
#......#....#.#......##....#..#
#.##..##..#...#.###......#.....
..........#.#....###.#.....##..
#..##...#.###..#.............#.
.#.#......#.##.#...#....#.....#
.##...#..##...#...........#.##.
.##..#.#.#..#.....#.....###....
.#...#.#.#..#..#....##...#..#..
#.#.#....#.....#..#..##..#.#...
......#..#...####..#.........#.
.#.#..#......#...#..####.....#.
...#.#...#...#....##..#.#.#.##.
...#........##.............#.#.
...#...#...#.......#..#.#.#..##
.####.#...##......#.##.##.#.#..
#..###...........#..#.#...#.#.#
###...#.#..#...#.#...#.#..#.#.#
#....#.....##...#.#...#..#.#...
.#........##.##....##..#..#....
.#.#.#..#........#...#..#.#.#.#
#.##.....#.#...#....##...#..#.#
..#.......##.#.###............#
##....###..##.........##..#.#..
...##...#...#..###.#.....##..#.
###.................#.#..#.....
....#......#.....#..###......##
.......#...##..#...............
.#.....#..#.....#...##...#...##
.....##....#.#..#.##.....#...#.
#..####.#....#..#.....#....#..#
..#..##.#.##......#..#.#....#..
..#.#.#.#.....#...#...#..#.....
.#........#.#...#.#..#...##....
.#...#.#...#..#.#...###...#.#..
#.....#...##..#.....#...#.#..#.
...#....#................#.#...
......##.#.#..........#...#....
.##..#.#.#...#..#...####.#.....
#......#....#..#.......#.......
.#........#.#.#....###.#..##...
....##......#.....##...#...#...
..#..#.#.#...#..#.####.##......
...#........#.#.##.#..#.##.#...
.#..##...#...#...##.......##.#.
#...#.#......#.................
..#..#.....#....##...#..###....
.#...#.........#.#.##.#........";