Browse Source

Solve 2020/3/first

master
Garrit Franke 3 years ago
parent
commit
c657016c82
  1. 3
      2020/3/go.mod
  2. 323
      2020/3/input.txt
  3. 52
      2020/3/main.go

3
2020/3/go.mod

@ -0,0 +1,3 @@
module 3
go 1.15

323
2020/3/input.txt

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

52
2020/3/main.go

@ -0,0 +1,52 @@
package main
import (
"fmt"
"io/ioutil"
"strings"
)
func main() {
data, err := ioutil.ReadFile("input.txt")
if err != nil {
fmt.Println("File reading error", err)
return
}
lines := strings.Split(string(data), "\n")
fmt.Println("First result:", first(lines))
fmt.Println("Second result:", second(lines))
}
func first(lines []string) interface{} {
currentX := 0
numTrees := 0
for i, line := range lines {
if i == 0 {
continue
}
currentX += 3
objects := strings.Split(line, "")
if currentX >= len(objects) {
currentX %= len(objects)
}
if objects[currentX] == "#" {
numTrees++
}
}
return numTrees
}
func second(lines []string) interface{} {
result := 0
return result
}
Loading…
Cancel
Save