-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
103 lines (84 loc) · 4.34 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package main
import (
"fmt"
)
func main() {
// http.HandleFunc("/1", func(w http.ResponseWriter, r *http.Request) {
// var lines []int = readFileAsNumbers("input/day01.txt")
// fmt.Fprintln(w, "highest: ", calcCalories(lines))
// fmt.Fprintln(w, "top3: ", calcCaloriesTop3(lines))
// })
// http.HandleFunc("/2", func(w http.ResponseWriter, r *http.Request) {
// var lines []string = readFileAsStringArray("input/day02.txt")
// fmt.Fprintln(w, "score: ", calcRPC(lines, false))
// fmt.Fprintln(w, "score2: ", calcRPC(lines, true))
// })
// http.HandleFunc("/3", func(w http.ResponseWriter, r *http.Request) {
// var lines []string = readFileAsStringArray("input/day03.txt")
// fmt.Fprintln(w, "score: ", calcRucksack(lines))
// fmt.Fprintln(w, "score of 3: ", calcRucksackOf3(lines))
// })
// http.HandleFunc("/4", func(w http.ResponseWriter, r *http.Request) {
// var lines []string = readFileAsStringArray("input/day04.txt")
// fmt.Fprintln(w, "score: ", calcCoverage(lines))
// fmt.Fprintln(w, "score singles: ", calcCoverageSingle(lines))
// })
// http.HandleFunc("/5", func(w http.ResponseWriter, r *http.Request) {
// var lines []string = readFileAsStringArray("input/day05.txt")
// fmt.Fprintln(w, "crates: ", moveCrates(lines, false))
// fmt.Fprintln(w, "crates after crane 9001: ", moveCrates(lines, true))
// })
// http.HandleFunc("/6", func(w http.ResponseWriter, r *http.Request) {
// var lines []string = readFileAsStringArray("input/day06.txt")
// fmt.Fprintln(w, "4 char package: ", findStartOfPacket(lines[0], 4))
// fmt.Fprintln(w, "14 char package: ", findStartOfPacket(lines[0], 14))
// })
// http.HandleFunc("/7", func(w http.ResponseWriter, r *http.Request) {
// var lines []string = readFileAsStringArray("input/day07.txt")
// fmt.Fprintln(w, "folders sum below 1kk: ", calcDirectorySize(lines))
// fmt.Fprintln(w, "deleteFolder size: ", findDeleteFolder(lines))
// })
// http.HandleFunc("/8", func(w http.ResponseWriter, r *http.Request) {
// treemap := readFileAsIntMap("input/day08.txt")
// trees, scenicScore := findTrees(treemap)
// fmt.Fprintln(w, "visible trees: ", trees)
// fmt.Fprintln(w, "highest scenic score: ", scenicScore)
// })
// http.HandleFunc("/9", func(w http.ResponseWriter, r *http.Request) {
// lines := readFileAsStringArray("input/day09.txt")
// fmt.Fprintln(w, "coverage small snek: ", calcMapCoverage(lines, 1))
// fmt.Fprintln(w, "coverage big snek: ", calcMapCoverage(lines, 9))
// })
// http.HandleFunc("/10", func(w http.ResponseWriter, r *http.Request) {
// lines := readFileAsStringArray("input/day10.txt")
// cycles := [6]int{20, 60, 100, 140, 180, 220}
// fmt.Fprintln(w, "x sum: ", runCycles(lines, cycles[:], w))
// })
// http.HandleFunc("/11", func(w http.ResponseWriter, r *http.Request) {
// lines := readFileAsStringArray("input/day11.txt")
// fmt.Fprintln(w, "monkees after 20: ", chaseMonkyes(lines, 20))
// fmt.Fprintln(w, "monkees after 10000: ", chaseMonkyes(lines, 10000))
// })
// http.HandleFunc("/12", func(w http.ResponseWriter, r *http.Request) {
// fmt.Fprintln(w, "shortestPath start from S", findShortestPath(readFileAsStringArray("input/day12.txt"), 'S'))
// fmt.Fprintln(w, "shortestPath start from a", findShortestPath(readFileAsStringArray("input/day12.txt"), 'a'))
// })
// http.HandleFunc("/13", func(w http.ResponseWriter, r *http.Request) {
// sum, decoderKey := calcSumOfIndicese(readFileAsStringArray("input/day13.txt"))
// fmt.Fprintln(w, "sum of indices ", sum)
// fmt.Fprintln(w, "decoder key", decoderKey)
// })
// http.HandleFunc("/14", func(w http.ResponseWriter, r *http.Request) {
// fmt.Fprintln(w, "landed sand ", calcSandAtRest(readFileAsStringArray("input/day14.txt"), false))
// fmt.Fprintln(w, "landed sand with floor", calcSandAtRest(readFileAsStringArray("input/day14.txt"), true))
// })
// http.HandleFunc("/15", func(w http.ResponseWriter, r *http.Request) {
// fmt.Fprintln(w, "distress amount: ", calcDistress(readFileAsStringArray("input/day15.txt")))
// start := time.Now()
// fmt.Fprintln(w, "Lost Beacon tuning: ", findMissingBeacon(readFileAsStringArray("input/day15.txt")))
// elapsed := time.Since(start)
// fmt.Fprintln(w, "took ", elapsed)
// })
// log.Fatal(http.ListenAndServe(":8081", nil))
fmt.Println("highest Pressure ", calcPressure(readFileAsStringArray("input/day16.txt")))
}