Created
December 3, 2020 11:11
-
-
Save lennartb-/b42cc5a437fae951482de9e462d5ccf0 to your computer and use it in GitHub Desktop.
Advent Of Code 2020 - Day 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
..#..#......###.#...#......#..# | |
...#.....#...#...#..........#.. | |
....#.#...............#.#.#.... | |
.........#.......##............ | |
#.#....#.#####.##.#........#..# | |
.....#...##.#..#.##...#.#..#... | |
#.#..###.#........#....##...#.# | |
..###.....#..###.....##........ | |
#.#.#...........#.....#.#....## | |
...#.#.##.##.#.#......#...##.#. | |
.....##.#..#....#..#...##...### | |
...#.....#..#..#...#.#....##... | |
.#...##.#.........#...#.#...... | |
....#...#.....#......#...#..... | |
.#...#.....#....#......#...#... | |
#...#......####..##...###...... | |
....#..#......##.##.....#..#... | |
....#....#.......#..#...#....#. | |
...##..#.##..#.#...#..##....... | |
##.#..#.....#.##.#....#..##.... | |
#....#....#.....#..#.#.#.....#. | |
##...#.###.....#....#..#.#.#... | |
#..#.......#...#.#...#.#.....#. | |
....#.#.......#.....###..#..#.# | |
......####...#.#..#..#.#.#.#... | |
#...##.....#...#.#.........#.#. | |
......#...##.#..#.#........#... | |
..#.#...........#..##...###.##. | |
#......#.#......#.....#.....#.# | |
.#...............###.#.###..... | |
...#...........##..#...##..##.# | |
#......#.##.#............#.##.# | |
.#.#....#....###........#..#... | |
...##.#.#..#.##.#..##..#.##..## | |
.....#...#.#.#...#....#......#. | |
..............#...##........... | |
..............##........#..###. | |
.#.##.......#.....##.#......#.. | |
..#......#..#.#####..#.#....... | |
#.#..#...#.#..#....#..#.##..#.. | |
...##.......#.#............#... | |
...#....#..#.##.###.......#.### | |
..###..#....#..#.....##...#..#. | |
..#.###.##......###....#....##. | |
...#...##...###....##.....###.# | |
.....#.....#.#.#.........#..### | |
#.#......#.#..#.####..#........ | |
#....#.##.......##............. | |
..##...........#....#.....##..# | |
..#...#...........#....#...#... | |
...#...#...#.....#..#....#....# | |
#......##.........#.#...##...#. | |
.##..#...#.....#....#.##.####.# | |
#..##.##.#......#.............# | |
.#.....#..##.###.#.#.#......... | |
.###....###..#....#..#.#.#..##. | |
....#........#..#....##..#.#.#. | |
.....#..........#..........#... | |
.#.##..#..#...#..#.##.#.##..... | |
.#....#...#......#.#..##.##..#. | |
.###.#...#.#.##....#.....#..##. | |
......##.......#..#.......#.#.# | |
.##.#.#.#......#.......#....... | |
#..#...##......#.......#......# | |
...#..#...##.#...#..##......... | |
.....#..###...##...#..#.#...#.# | |
..#.#.#....##..#.#.#.#...#..... | |
.....#.#.#..#..#.#.#...#....... | |
#.#.#...#.#.....#.#.#.##.###... | |
.....#.#.....####..#........... | |
..#.#.#...........##..#.#....#. | |
.#..#......#..#...........###.. | |
..#...###.##......#..###...#..# | |
#.#..#.....#..#.##.#..#.#.....# | |
.....................#.#..#.... | |
...##..##...#.#..#..##.#....#.. | |
.#..#.#....#...#.#.##.......... | |
....##.....#..#..##.........##. | |
..##...##........#.#....#...### | |
.#...#............#.#.#.#...... | |
#...#........#..#..#...#.#..... | |
..#..........#.......###.##.... | |
#...........###..#....##..#.##. | |
##...#..#.##.....#...........#. | |
.#..##.....#..#.#.....##.#..#.# | |
..#..#.##....#.........#.#.#... | |
#..#...#...#..#...........##... | |
.....#.......#.#......#.#.#...# | |
..#.#..#..#.#.#.......#.#...#.. | |
......#.....##.....#.....##.##. | |
#.#..#......#......#.####.##... | |
.####...#####.#....#.#..##..... | |
............#....#....#....##.. | |
###.........#............#.#... | |
...#...#....#.##..#...#......## | |
...##.#.#.##.##.#.....#...#.#.. | |
...#.....#...#..##......#.#.##. | |
.##.#......##................## | |
......#.....#..##.............# | |
#.#...##..#..#..#.##.....#..#.. | |
#......###.....#....##...##...# | |
....#..#.....#.......####...##. | |
#.#...#.#...#..........#..##..# | |
....#..#....#................## | |
.####..#........#..#.#...#..... | |
##.###...#.##........#..##..... | |
..###..##...#...#..#...##.....# | |
......#..##.................... | |
.#...#......#.#.##..#........#. | |
..#...#####.....##.....#...#... | |
.#..#....#..#....##.#....#..##. | |
.#.....##..###.#.....#.#.#.##.. | |
#..##.....##...#.....#..#.#.... | |
#.##......#.#......#..........# | |
#####........#.............#... | |
.#..#..##..#....#.....#..####.. | |
...#..##.##...####....#.##...## | |
..........#....#...........##.# | |
#...##...#...##....#.....#..... | |
.......#..#.....#.#.#.#.#.....# | |
...#..##..####..#..##.#.##....# | |
#...#...#...........#.#.....#.# | |
..#.....##...###.........#..##. | |
.......##..#.......#.......##.. | |
#.#....#....#.###............#. | |
...#......#.#.............#.#.. | |
......#..#....#....#....#..#... | |
.....##..#...........##...#.##. | |
..#....#.##.#......#........... | |
#...#....#.#.#.#.#..#.......... | |
.#..#..........#..#.#.....#.... | |
.....##......##....#.#.....#.#. | |
.....#..#..........#....#.....# | |
....#..#..#.#...#.#..#..#..##.# | |
.#..##.#..##...###.#..........# | |
..###..#......#...##...#.#..... | |
..#...#...#.....#.......#....#. | |
#...##..#.##.#....##.....#..... | |
..#.#.....#...#...#............ | |
.......#.#.#..#.....###.#...##. | |
....##.......#####...##..##..#. | |
#...#.##.....#.#...##.........# | |
..#.##..........#..###.#....#.. | |
#......#.##...#...#.....###.... | |
................#.##........... | |
##.###.#.#.#.##......##..#....# | |
..#.#........##..#..##......... | |
###....#..#....#..##....#.....# | |
#......#..#...........#.#...##. | |
...###.......#...#......##..#.# | |
.......#...##.#.#...#.##......# | |
......##..#...##.#.#...##....#. | |
..#...#...#...#.#.....#..##..#. | |
..##...#.....#.....#..##....... | |
....#........#.#.##.......#.#.. | |
#...#..##..#..##..#...#......#. | |
...#..#.#.#..#..#..####...#.... | |
#..#..#......#......#..#.###### | |
#..#..#..#........#..#.#....### | |
#..##..#.#.##.....#..#......#.# | |
##.......##.#..#.............#. | |
..........#.#..#..#............ | |
....#.#.#.#...#......#......#.. | |
###.#.#.........#.......#...##. | |
#.............####..#...#.##... | |
....##.......#................# | |
###...#..#......##....#.####.#. | |
..##.##.#.#.#.#...#.......#...# | |
.....#.##......#.......##..#.#. | |
.#...#.##..#.......#.#....#.#.# | |
##...##..#....#..#...#....#.... | |
..........#...##.#..##.......## | |
#.#...#....#......#.#.......### | |
......#...#.##....#....##.#.##. | |
..#..#.......#.......#....##... | |
##..##.......##............#.#. | |
.#.#...#..#.#.###......#....... | |
#...#..##....#...###..#.#.....# | |
.#.....#........#..##.#.#.#.... | |
..#.##....#..#...........#...#. | |
.....#.#...#.##..###...#...#... | |
#....####.......#..#.#...#..... | |
....#.....#....##..#.##.....### | |
........#.#.....###....#.#..... | |
...#.....#.##.....#......#..... | |
.....#...####......###..#...##. | |
#.#......#..........#..##.#..#. | |
..##......###...#...#.......#.. | |
#...#.#...#.#.........#........ | |
....#..#.##.#.##.###..#.....#.. | |
.#.#.#......#.#........#.....#. | |
.....#.#..#....#...#.....#.#.## | |
##.............#..#.....#.#.... | |
#............#..#....##......## | |
#....#......#......#....##..#.. | |
.#....#............#......##..# | |
..#.#.#..#.#....##.#.......#.## | |
#.##.....#...#......#...#...... | |
.......#...........#..#.##..#.# | |
##.....##.#.....####..........# | |
...#.......#.#.............#..# | |
...##........##..#..#.#........ | |
.#.##...#.....##.#......#....#. | |
.#................#.#...#..#... | |
#....#.#.#......#.#.#.##....#.. | |
..#......#............#...#.... | |
###..#.##........#....##.#...#. | |
.#..#..#......##............... | |
....##.............#....##...## | |
..#.#..#.#####....##.......###. | |
......#...#..#.#....#.#..#...#. | |
.........#..##.##...#....##..## | |
.............#.##....###.#..... | |
..#................#..#.#..#... | |
...#........#......#..###...... | |
.#.#.#....#.........#...###.### | |
.........#..#.#......##.....#.. | |
#...##..#.#.###..###........... | |
...#.#.#..#......#..##.#.##.... | |
.....##.......#................ | |
.##....#.#.#.##.....#.##......# | |
...#........#...##.#.##..##...# | |
..#..........#.#......####..##. | |
............#.#.#.#.....#...... | |
..##.####.#..#....#..#..##..... | |
......#........#...#..#.#..###. | |
#.#..............#..#...#..#... | |
....#............#...#..#...##. | |
..##....#...##.##.#..........## | |
..#..#.........#..#.....#.#.... | |
#.....#.###...##...##...##..... | |
#.#...#..#####.#...#..#.....#.. | |
..#.....###...#.........#.#...# | |
....#.##.........#.#.....#.#.#. | |
..........##...#....#.#.#.....# | |
...#...........#.....###....... | |
#....#..#...#.....#.......#.... | |
.#.#.....#..##..##..#........#. | |
.#.#.....#....#...#.#.##....... | |
....###...#...###.##....#...... | |
...#.#.##....#...##......#...#. | |
#....#...##.....#.##.#.....#.## | |
.#.#.....##.##.##..###...#..... | |
.#.#......#..#..#........#.#..# | |
........#...##........##...#... | |
.#..#.#.#..#.....#....#...#.#.. | |
#......#...#.#...#..#.#..#..... | |
.#......#.....#.........###.#.. | |
#..#..........##..###.......#.. | |
#..#..#....#......#......#..... | |
......#.....##.........##....#. | |
#..#.#...#...#.##.#..#..##..... | |
....#.#....###..#.....#...##.#. | |
..##.....##.#..#..##..#.#...... | |
.........#..#....###...#.#....# | |
.........#...#...#...#......##. | |
.......#..#.....#.#.#...#...#.. | |
............#.....###......#..# | |
#....##..###.......#...##....## | |
..#.##..#####..##.#...#......#. | |
#.#..#...###.............#.#... | |
##...#..#..#.#....#.#.......#.. | |
.....#....##.....###.##..#..... | |
......##..##..#.#..####.#...... | |
..#...#.#....#...#.#.........#. | |
##.....#.#....#..#..##........# | |
...........#..#........##..#... | |
..##.#...#.#.#..##..#..#..#..## | |
..........#.###.....#..#.....#. | |
......#............###..##.##.. | |
.#.......#..#...........#.###.# | |
#...#..##............##.......# | |
.###..#...#.#....#....#......#. | |
..##.........##............#.#. | |
.##.......##....#.#.#....#..#.# | |
#.##........#.....#.##...#.#... | |
#......#....#.#......##....#..# | |
#.##..##..#...#.###......#..... | |
..........#.#....###.#.....##.. | |
#..##...#.###..#.............#. | |
.#.#......#.##.#...#....#.....# | |
.##...#..##...#...........#.##. | |
.##..#.#.#..#.....#.....###.... | |
.#...#.#.#..#..#....##...#..#.. | |
#.#.#....#.....#..#..##..#.#... | |
......#..#...####..#.........#. | |
.#.#..#......#...#..####.....#. | |
...#.#...#...#....##..#.#.#.##. | |
...#........##.............#.#. | |
...#...#...#.......#..#.#.#..## | |
.####.#...##......#.##.##.#.#.. | |
#..###...........#..#.#...#.#.# | |
###...#.#..#...#.#...#.#..#.#.# | |
#....#.....##...#.#...#..#.#... | |
.#........##.##....##..#..#.... | |
.#.#.#..#........#...#..#.#.#.# | |
#.##.....#.#...#....##...#..#.# | |
..#.......##.#.###............# | |
##....###..##.........##..#.#.. | |
...##...#...#..###.#.....##..#. | |
###.................#.#..#..... | |
....#......#.....#..###......## | |
.......#...##..#............... | |
.#.....#..#.....#...##...#...## | |
.....##....#.#..#.##.....#...#. | |
#..####.#....#..#.....#....#..# | |
..#..##.#.##......#..#.#....#.. | |
..#.#.#.#.....#...#...#..#..... | |
.#........#.#...#.#..#...##.... | |
.#...#.#...#..#.#...###...#.#.. | |
#.....#...##..#.....#...#.#..#. | |
...#....#................#.#... | |
......##.#.#..........#...#.... | |
.##..#.#.#...#..#...####.#..... | |
#......#....#..#.......#....... | |
.#........#.#.#....###.#..##... | |
....##......#.....##...#...#... | |
..#..#.#.#...#..#.####.##...... | |
...#........#.#.##.#..#.##.#... | |
.#..##...#...#...##.......##.#. | |
#...#.#......#................. | |
..#..#.....#....##...#..###.... | |
.#...#.........#.#.##.#........ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace adventofcode | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
var input = System.IO.File.ReadAllLines("input.txt"); | |
var lineLength = input[0].Length; | |
const int right = 3; | |
const int down = 1; | |
int trees = 0; | |
int positionCounter = 0; | |
Console.WriteLine(input[0]); | |
for (int i = 1; i < input.Length; i += down) | |
{ | |
var currentLine = input[i]; | |
var currentLineChars = currentLine.ToCharArray(); | |
var newPosition = positionCounter += right; | |
var currentChar = currentLineChars[newPosition]; | |
var isTree = currentChar == '#'; | |
if (isTree) trees++; | |
currentLineChars[newPosition] = isTree ? 'X' : 'O'; | |
Console.WriteLine(currentLineChars); | |
if ((positionCounter + right) >= lineLength) | |
{ | |
positionCounter -= lineLength; | |
} | |
} | |
Console.WriteLine(trees); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment