master
Karl Spickermann 1 year ago
parent
commit
f3da58723c
  1. 40
      day3/day3.go
  2. 323
      day3/day3Input.txt
  3. 11
      day3/day3Test.txt

@ -0,0 +1,40 @@
package main
import (
"AoC2020/helper"
"fmt"
"os"
)
func main() {
args := os.Args[1:]
input, err := helper.GetInput(args[0])
if err != nil {
fmt.Println(err)
}
fmt.Println(day3(input, 3, 1))
fmt.Println(day3Part2(input, [][]int{{1, 1}, {3, 1}, {5, 1}, {7, 1}, {1, 2}}))
}
func day3Part2(input []string, slopes [][]int) int {
result := 1
for _, slope := range slopes {
result = result * day3(input, slope[0], slope[1])
}
return result
}
func day3(input []string, right int, down int) int {
count := 0
x := 0
y := 0
for y < len(input) {
if string(input[y][x]) == "#" {
count++
}
x = (x + right) % (len(input[0]))
y = y + down
}
return count
}

@ -0,0 +1,323 @@
.#.#....##.......#..........#..
...#...........##...#..#.......
#.####......##.#...#......#.#..
##.....#.#.#..#.#............#.
##.....#....#.........#...##...
###..#.....#....#..............
..........#..#.#..#.#....#.....
##.....#....#.#...#.##.........
#...#......#....##....#..#.#...
.##.##...#....##..#.#.....#...#
.....#.#..........##.#........#
.##..................#..#..##.#
#.#..........##....#.####......
.#......#.#......#.........#...
#....#..##.##..##........#.#...
##..#.##..#...#..####.#..#.....
###....#.###.##...........##..#
.....#.##.....##.#..#####....##
....#.###....#..##....##...#...
..###.#...##.....#.##..#..#.#..
#...#..#..#.........#..#.......
##..#.#.....#.#.#.......#...#.#
...#...##.#........#...#.......
..#..#.#..#...#...#...........#
........#.....#......#...##....
#........##.##.#.#...#...#.....
####.......#.##.###.#....#.....
...#...........#...#......#...#
##...#...#............#.......#
....#...........##.......#.....
###......#.....#....#...#.#...#
.....##..........#.......#.#...
##.##.##...#......#....#.......
##..#.#..#......#...#..#.......
....#....##.##............####.
..#.###..#.##.###..#.##.......#
#.##..#.#.....#..#.....##......
..##..#.....##.#.##........#...
.#..#.#......#..#............#.
.....#..#.#...#....#.##.#......
.#...##.#..#.#...##...##..##...
###............#.#..#..#...#...
..#..##.####.#.....#.....##.###
#....#.##..##....#..#...#.##.#.
.....#.##.........##...##......
.........####.#....#.#......#.#
.........#.#..#...#.#..#.#....#
.#.....#..##.##..##....#.......
..........##......#.##.###....#
.##...###..##.#...#........##..
..............#.#....#.#.###.##
..##.##.......#.#......##...#..
.#.....#..##..#.###...#..#.##.#
#.....#.#..#...#........#...#..
.#......#....#.#.....###...#..#
..##.#....#..##......#.....#...
..#.#.##..#.....#.####..###....
.........#......#..#...........
..#........#.##.#.....##.##..#.
.......#.........#....#...#.#..
.##.....#.#....#.#.......#.....
..........#.##........##...##..
###..###.#.#..#..#####.##.#.##.
..##..##.#.#...#..#.#.#......#.
#..#..#..#..##..#.....#......#.
..#....#.##..#......##.........
..#.##......#...##.#......#....
.......#..#.##.#.....#.........
.......#.#.#.###...##......#...
.....#.#..........#..#...#.....
....##..........#..........##..
..#......#.....#.##.#..#...#.#.
....#.....#..#...#..#.#.##..###
.####....#........#...#........
...##.#.##.#..#...##...#.##....
....#...#...#.#.#.#...#..#.....
.....#...#.#.....#.#........##.
..#.#.......###.#.....##.......
......#.........##....#....#..#
.............##.....##.........
.........##...##.......#.....#.
##.........#..........#.###..##
...#.....#......#....#..##.....
##..#...#...##.#.....#.#......#
..#...##.#.......#.#......#.##.
......#.......#.#...........#..
..........#.....##............#
#........#...#..#.......###.##.
.##...........#.#........#.#.#.
...#..##...#.#....#####.#......
.....##...###...#..#.##...####.
...#....#.....#..#.......#.....
#....#....#...#..#..#.######..#
#.###...........#......#...#..#
.#.#.#.#..#....#....#...##.#...
.#..#.........#.#....###...#...
......#..##.##..........#....##
.....#......##....##.....#...#.
.#...#.#.#....##....#..#....#.#
..................#..###.#..##.
..#.........#......#....#..###.
#.#.....#..#..#....###..###....
..##..##.#..##........##...##..
##..#........##..###..#.....#.#
..#..###..#......#....#...#...#
#..#.#..............##.#..#.#..
.....####....#...####.....#.#..
.....#....##.#......###........
##.##...#.#.#.#.......#....##..
.#......#...#.#....#..##.#.##.#
#.#.##.#.#......#..##........##
...##.....#.....#...#..###...#.
........###.....#.....#...##..#
.....#.##.##......#.#....#...#.
.#....##.......#..#.####.......
.#..#....#..........#......#.#.
.#.##.##.....###.#.#...........
.........#......#..##..........
....#...##.#.#.#..#.#.........#
..#.....#.##...#..#..#.###....#
...#.##......#.....##....#.....
###............#.#....#...#....
.......#.....#..#.#.#....#..#.#
...#......#.#..##..#....#...#.#
............##........##..##...
..#..#.##..#......###..#.......
........#.........#............
..#...#.#########.#...##..###..
#....#......#.......#.#.....#..
#.#..#....###.###....#...#.#...
#...###.#.#.......#.##......#..
.................#...#.#.#.....
##....#...#........#....#.#..#.
......#.....#...#..........#.#.
##..........#...#..........#.##
..#.#.##.#....#.#......#...##..
.....#.......#..#.....#........
#.##.#..##..#.......##.........
....#......#..#..#.#...#.......
...#....#................###...
.##.....#.#....#.#..........##.
...#..#....#.##.##......#......
..#.#....#.......#.#..##.......
....#.....#..........##.#.#####
#.....................##..#..#.
.###..#.##.......##.#...#..#...
...###.......#..#...#......#..#
#..#...#.#..#.#..#..#.##.......
#...##.......#..#..#.##..###...
......#....#.#.#........#.##..#
..##..#....#....#..#.#..#......
..##.#...#.#######..#...#.....#
..#....#..#.........#..##......
...#....#.#......#..#..#.#.....
#..#....#........#.#..##....###
#....#..##......##.##.....#.###
...#.#..........#..#.#.#.#.##..
......##..#.#..#.#....#....#...
##....#....#..#..#.##......#...
....#.#..##.#.#...###....##.#..
...#.......##..#.......#...#...
......##.......#..##.....#...#.
...#.#...#...........#...#.....
.#....#...#......##.##..###..#.
.#..........#...#...#...##.##..
.....###..#.....#..##....#.####
..#.###..#..##..##.....#.#.....
.............#.###...##.#.....#
....###.......###.#.....#..#.#.
........##.#.........#.....###.
.....###.#..#.....#...#..#.....
.#....#..##.#..#.#....#.......#
........#......#.#..#.#..#...##
...#.##.##......#..............
.#.....##.#.....#..#......##...
#..#..#.....#.....#.....###....
.##...........#..#.##.....#....
..#.#......#.#...#.##.#..#...##
...#..........#.....#..........
#.#.#.#.#...#....#...#.....##..
#......##...#...#..........#.#.
....##........#.#..............
#..#.#.#..#........##......#.##
........####...##.#.....#......
....#........#.#..#..##..#.#...
.#.....#..###...#..#.....#..#..
#......###.#..#....#..#.#......
....#.....##.##..#...#.#..##.#.
..##..#...#.#......#....#...#.#
#..##...##..#...###...#..#.....
.......#.....#...........##....
#..##....#........#....##..#.#.
.#........#..##...###.#..#.....
.#.#....#..##...#...##.#..###..
#.........#.......#.....#.#....
#..#.....#.#.###.#..#......#...
....#..#.#....#..##..###....###
###.##.#.#..#...........#.#.#..
..##.#.......#......#..##....#.
.....#.#.#.......##.......#...#
...........#.##....##.##....#.#
...#.......#..#.##..#......#..#
#.#.#...#......##.#...........#
##........#...........###.#..#.
..........#.#.#....#.#..##.#.#.
...#.#.#....#..........#..#....
#.#....###.#.#..#.......###...#
.#....#......#.#.#..#..#.......
......##.............#....#.#.#
.#..........#.........#.##.....
##....#....##....#..#.......#..
#.##.##.#..#..#.....#..#.##.#..
.#..#.......##..#.....##.##....
.......#..........#.#.##..#.##.
....#.....#.#...##....##.......
.......#.........#...##....##.#
#.....#......#..........#...#..
...#.#.......#.#..#....###..#..
.....#.#.#.........#...........
.#..###.#.#........#.#.........
.........#..#......##...##....#
...###..#.....##.....#.###....#
.##...#...#........###.#..#....
.##........#..#.###.######.##.#
##.#...#.#....#..##.#....##....
.......##.....##.#..###.#......
..##...##........#.......#....#
#..##...#.####...###......#...#
.##.....#.##.#.#.....###.#..##.
..###....#.#.###.#....#........
....#..###..#...#....#..#..#.#.
#.#.##....##...##.......#......
.........#...#....#..#.........
.............#...#..##.#.......
...#.##.......#...#.#..##.##...
.####.#.##..#.#......#.##...#.#
.#..#.#.....#.................#
..#.##..###....#...#......####.
..##..##...........#....#...#..
....#...#...#...#.......#....#.
#.#...###...#...#.#...#....##.#
......#...#.#.......#.....#...#
....##...#.#.#....#....#.#....#
.....#.....#...##..#...#....##.
#.....#....#......##.##....#...
...#.#....#...#....#.#....##..#
...#.#..#...##....###..#.......
...##......###...###.#...#..#..
##.......#.......###.......#..#
..##.##..###.#............#...#
#.....##..#..##....##..#.......
......#.#...#......#.....#.....
#...........#....#..##.##.#....
.......#..#......#...#....#...#
.#...##...........#......#...#.
#........#....##...###.#....#..
.....#.......##.........#.##...
.#.###..#....#..##.#..#.#..#...
#.......#.##.#.#....#.#..#....#
###.....#.#.......#..#......#.#
#..#.#.......#.#..##..##.#.#...
#..#.#.#.###........#.....#...#
#.#.#..#..##.....#...........#.
..#.#..#.....#...#...#...##....
...#.##......#...##.#...#.#.#.#
#..#.#.#.#.......####..........
..#......#.#......##.###.....##
..#...##..#.........##....#.##.
##.##.##.#.#.....#..........##.
.#.....###.#..#....#..#.###...#
#...##.......###....#.#..#.....
..#....##.........##.........##
......#....#.##.......#........
..#.#.#..#...#...#...##.#...#..
......#..##.#.#.#...##...#.#.##
#..#...##.#.....#...#.##.......
..#..#.........##.#...#.##...##
##.##.#....#.......#.##..#.....
.....##...##.##...##.........##
#......#...#.......#...#...#...
...##...........#...#..#.......
.#.##.#..#........#....#.......
#.#...#..#......##...#.#.##....
##........####..#.#...#.#.##.##
#..#.#.##......##.#.#..#.......
.....#.........#..#.####....#..
......##..#....#...#.#....#....
#...##........#.........#.....#
.#.#...#.#.#..#............##.#
.#..#....#....#.....#...#.....#
..###...#..#.....#.##.###...#.#
.#.###..#..#...#.#...#.#......#
#...#####......###........##...
.....#.....#..#.#....#..##.....
....##...#.#.##.#####...#....#.
.#.#.........##.#.......#..##..
.#...#.#...#...#....#.#...##.#.
.##...#..#.#..#......#.#.#..##.
..#.....#..#.....##.....#......
..#........#..##...#.......###.
.#....#.......#....#....#..#...
....#......#.#.#.........#.....
..##...#.#.#...#.#........#....
.#.....####...##.#..#...##.....
...#.....#...#...#....#....#...
.........#..#.#.....#..#.#..#..
.........##...........#.......#
......#..#.....##...#.##.#.....
.#......##........##...#.#.##..
.....#.#..##...........#..#..#.
...#.......#...#.#..#.##..#.##.
...#.......#.....#.#...#.##.#..
#.....#.............##.#..####.
.#...#......#...##.#....#.#....
.##..##.##....#.#.....#.......#
...#...#....#....##.#..#....##.
..............##....#.......#.#
.#.#.#...##..#..#...###.#..#...
.#.#...#.#..#.#..#...######..#.
........#......#.#..#.#....#...
..###.....###.#.##....#...##...
.##.#.....#.......##.......#...
..#..##...#..........#.#....#.#

@ -0,0 +1,11 @@
..##.......
#...#...#..
.#....#..#.
..#.#...#.#
.#...##..#.
..#.##.....
.#.#.#....#
.#........#
#.##...#...
#...##....#
.#..#...#.#
Loading…
Cancel
Save