mirror of
https://github.com/Noettore/AdventOfCode.git
synced 2025-10-15 03:36:39 +02:00
7
.gitignore
vendored
7
.gitignore
vendored
@@ -10,3 +10,10 @@
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
#VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
959
2018/day_01/input
Normal file
959
2018/day_01/input
Normal file
@@ -0,0 +1,959 @@
|
||||
+12
|
||||
-10
|
||||
-4
|
||||
-8
|
||||
+18
|
||||
-1
|
||||
-13
|
||||
+10
|
||||
-13
|
||||
+5
|
||||
+7
|
||||
+6
|
||||
+14
|
||||
-9
|
||||
-8
|
||||
+7
|
||||
+18
|
||||
-11
|
||||
+13
|
||||
-1
|
||||
+20
|
||||
+11
|
||||
+13
|
||||
-2
|
||||
+3
|
||||
-8
|
||||
-16
|
||||
+4
|
||||
-6
|
||||
-3
|
||||
-9
|
||||
-12
|
||||
+16
|
||||
+17
|
||||
-5
|
||||
-11
|
||||
+2
|
||||
-20
|
||||
-15
|
||||
+5
|
||||
+3
|
||||
+11
|
||||
-13
|
||||
-18
|
||||
-13
|
||||
-6
|
||||
-19
|
||||
+6
|
||||
-15
|
||||
-11
|
||||
+16
|
||||
+1
|
||||
+15
|
||||
+5
|
||||
-18
|
||||
+14
|
||||
-5
|
||||
-15
|
||||
-3
|
||||
+11
|
||||
-17
|
||||
+19
|
||||
+12
|
||||
+5
|
||||
+8
|
||||
-2
|
||||
+10
|
||||
+13
|
||||
+8
|
||||
+19
|
||||
+8
|
||||
+17
|
||||
-6
|
||||
+8
|
||||
+4
|
||||
-9
|
||||
+19
|
||||
+13
|
||||
+11
|
||||
-2
|
||||
+20
|
||||
+3
|
||||
-16
|
||||
-18
|
||||
+3
|
||||
-5
|
||||
-15
|
||||
+18
|
||||
+18
|
||||
+9
|
||||
-18
|
||||
-19
|
||||
+17
|
||||
-16
|
||||
+15
|
||||
-12
|
||||
+2
|
||||
-20
|
||||
+7
|
||||
-3
|
||||
-9
|
||||
+10
|
||||
+4
|
||||
+20
|
||||
-13
|
||||
-17
|
||||
-23
|
||||
+7
|
||||
+18
|
||||
+21
|
||||
+16
|
||||
+17
|
||||
+5
|
||||
-14
|
||||
+19
|
||||
-18
|
||||
-10
|
||||
+7
|
||||
+1
|
||||
-13
|
||||
+16
|
||||
-21
|
||||
+12
|
||||
+19
|
||||
+11
|
||||
-5
|
||||
+14
|
||||
+11
|
||||
-9
|
||||
+19
|
||||
-2
|
||||
-7
|
||||
+3
|
||||
-20
|
||||
+9
|
||||
-16
|
||||
+9
|
||||
+10
|
||||
+17
|
||||
-18
|
||||
-12
|
||||
-11
|
||||
-11
|
||||
+20
|
||||
-18
|
||||
-12
|
||||
-5
|
||||
-7
|
||||
+15
|
||||
+20
|
||||
+18
|
||||
+23
|
||||
+17
|
||||
-7
|
||||
+5
|
||||
-7
|
||||
+8
|
||||
-2
|
||||
-15
|
||||
+5
|
||||
-17
|
||||
+1
|
||||
-5
|
||||
-8
|
||||
+7
|
||||
+15
|
||||
+5
|
||||
+1
|
||||
+15
|
||||
-11
|
||||
-1
|
||||
+17
|
||||
+15
|
||||
+18
|
||||
+7
|
||||
-3
|
||||
-16
|
||||
-7
|
||||
+18
|
||||
-6
|
||||
+17
|
||||
-2
|
||||
+20
|
||||
-2
|
||||
-7
|
||||
-17
|
||||
+20
|
||||
-1
|
||||
+8
|
||||
-16
|
||||
-12
|
||||
-6
|
||||
-3
|
||||
+19
|
||||
+19
|
||||
+18
|
||||
-7
|
||||
+17
|
||||
+5
|
||||
+19
|
||||
-15
|
||||
-13
|
||||
+2
|
||||
+14
|
||||
+2
|
||||
+1
|
||||
+13
|
||||
-7
|
||||
+2
|
||||
-10
|
||||
-10
|
||||
-15
|
||||
+9
|
||||
+9
|
||||
+14
|
||||
+7
|
||||
+4
|
||||
-15
|
||||
-5
|
||||
-17
|
||||
-5
|
||||
-9
|
||||
+13
|
||||
+6
|
||||
+2
|
||||
-15
|
||||
-11
|
||||
+17
|
||||
-19
|
||||
+14
|
||||
-13
|
||||
+3
|
||||
+1
|
||||
-18
|
||||
-15
|
||||
-17
|
||||
-12
|
||||
+13
|
||||
-17
|
||||
+5
|
||||
-9
|
||||
+2
|
||||
+5
|
||||
-8
|
||||
-8
|
||||
-19
|
||||
+11
|
||||
+20
|
||||
+11
|
||||
+16
|
||||
-7
|
||||
+20
|
||||
+3
|
||||
-21
|
||||
-8
|
||||
-11
|
||||
-9
|
||||
+8
|
||||
-15
|
||||
-20
|
||||
-20
|
||||
-17
|
||||
+24
|
||||
+17
|
||||
-12
|
||||
-20
|
||||
-12
|
||||
-3
|
||||
+14
|
||||
-18
|
||||
+13
|
||||
-74
|
||||
-19
|
||||
-13
|
||||
+2
|
||||
+23
|
||||
-13
|
||||
+24
|
||||
-17
|
||||
-5
|
||||
+14
|
||||
-10
|
||||
-2
|
||||
-10
|
||||
-7
|
||||
-6
|
||||
-23
|
||||
-10
|
||||
-3
|
||||
+9
|
||||
-11
|
||||
+8
|
||||
+16
|
||||
-8
|
||||
-28
|
||||
-10
|
||||
+17
|
||||
-9
|
||||
-10
|
||||
-9
|
||||
-8
|
||||
+2
|
||||
+5
|
||||
-19
|
||||
+11
|
||||
-16
|
||||
+8
|
||||
-14
|
||||
-5
|
||||
+8
|
||||
+4
|
||||
-3
|
||||
+8
|
||||
-7
|
||||
+4
|
||||
+1
|
||||
-2
|
||||
-7
|
||||
+15
|
||||
+3
|
||||
+10
|
||||
+4
|
||||
+1
|
||||
-14
|
||||
-18
|
||||
+15
|
||||
-21
|
||||
+3
|
||||
+14
|
||||
-15
|
||||
-13
|
||||
-14
|
||||
-6
|
||||
+15
|
||||
+1
|
||||
+11
|
||||
+26
|
||||
+19
|
||||
-16
|
||||
+5
|
||||
-2
|
||||
-9
|
||||
+12
|
||||
+19
|
||||
-11
|
||||
+23
|
||||
-3
|
||||
+15
|
||||
-13
|
||||
+14
|
||||
-9
|
||||
-26
|
||||
+17
|
||||
+63
|
||||
-4
|
||||
-20
|
||||
-10
|
||||
-39
|
||||
-55
|
||||
-6
|
||||
-15
|
||||
-9
|
||||
-16
|
||||
-17
|
||||
-14
|
||||
-12
|
||||
+21
|
||||
+1
|
||||
-2
|
||||
-16
|
||||
-13
|
||||
-21
|
||||
+26
|
||||
+27
|
||||
+17
|
||||
+6
|
||||
+2
|
||||
-18
|
||||
+1
|
||||
+18
|
||||
+25
|
||||
-3
|
||||
+19
|
||||
-35
|
||||
-26
|
||||
+4
|
||||
-48
|
||||
-3
|
||||
+1
|
||||
+20
|
||||
+8
|
||||
-27
|
||||
-25
|
||||
-8
|
||||
-10
|
||||
-24
|
||||
+3
|
||||
-61
|
||||
+64
|
||||
+17
|
||||
+21
|
||||
+84
|
||||
+49
|
||||
+4
|
||||
-233
|
||||
-2
|
||||
+535
|
||||
+55053
|
||||
-1
|
||||
-12
|
||||
+2
|
||||
-19
|
||||
+13
|
||||
+10
|
||||
+10
|
||||
+15
|
||||
-12
|
||||
+13
|
||||
+15
|
||||
+8
|
||||
-15
|
||||
-13
|
||||
+10
|
||||
-7
|
||||
+3
|
||||
-10
|
||||
+16
|
||||
+12
|
||||
-6
|
||||
+4
|
||||
+3
|
||||
+19
|
||||
+14
|
||||
+2
|
||||
+10
|
||||
+4
|
||||
+16
|
||||
-2
|
||||
-8
|
||||
+18
|
||||
-14
|
||||
-1
|
||||
+4
|
||||
-1
|
||||
+15
|
||||
+10
|
||||
-6
|
||||
+17
|
||||
+17
|
||||
+15
|
||||
+8
|
||||
+15
|
||||
+6
|
||||
+9
|
||||
+19
|
||||
-2
|
||||
+13
|
||||
-19
|
||||
-15
|
||||
-6
|
||||
-15
|
||||
-4
|
||||
-10
|
||||
-1
|
||||
-4
|
||||
-18
|
||||
+15
|
||||
-2
|
||||
+3
|
||||
+13
|
||||
+5
|
||||
+14
|
||||
+15
|
||||
-19
|
||||
+7
|
||||
+13
|
||||
-14
|
||||
-11
|
||||
+10
|
||||
+8
|
||||
+13
|
||||
-16
|
||||
+5
|
||||
-13
|
||||
-16
|
||||
+10
|
||||
-5
|
||||
-9
|
||||
-1
|
||||
+2
|
||||
+15
|
||||
-4
|
||||
-19
|
||||
-7
|
||||
+19
|
||||
+12
|
||||
+24
|
||||
+10
|
||||
+10
|
||||
+18
|
||||
+15
|
||||
+12
|
||||
-5
|
||||
-11
|
||||
+5
|
||||
+10
|
||||
-12
|
||||
-7
|
||||
-14
|
||||
+12
|
||||
-17
|
||||
-13
|
||||
-20
|
||||
+14
|
||||
-13
|
||||
+11
|
||||
-16
|
||||
+15
|
||||
+15
|
||||
+18
|
||||
-8
|
||||
+10
|
||||
+17
|
||||
+1
|
||||
-10
|
||||
+19
|
||||
+8
|
||||
+7
|
||||
+4
|
||||
+11
|
||||
+11
|
||||
-15
|
||||
-13
|
||||
+18
|
||||
-17
|
||||
+19
|
||||
+5
|
||||
-6
|
||||
-9
|
||||
+6
|
||||
+18
|
||||
-10
|
||||
+9
|
||||
-18
|
||||
-17
|
||||
-2
|
||||
-14
|
||||
-19
|
||||
-1
|
||||
-8
|
||||
-10
|
||||
-7
|
||||
-18
|
||||
+3
|
||||
+14
|
||||
+6
|
||||
+14
|
||||
-17
|
||||
+18
|
||||
+10
|
||||
+23
|
||||
+4
|
||||
-14
|
||||
+12
|
||||
-4
|
||||
-19
|
||||
+15
|
||||
+20
|
||||
-5
|
||||
+15
|
||||
+16
|
||||
-21
|
||||
+14
|
||||
-15
|
||||
-17
|
||||
-15
|
||||
+7
|
||||
+10
|
||||
+18
|
||||
+21
|
||||
+14
|
||||
+6
|
||||
+4
|
||||
+6
|
||||
+17
|
||||
-18
|
||||
-14
|
||||
-18
|
||||
-8
|
||||
+24
|
||||
+10
|
||||
+8
|
||||
-13
|
||||
+18
|
||||
+3
|
||||
-18
|
||||
-2
|
||||
-3
|
||||
-8
|
||||
-1
|
||||
-1
|
||||
-16
|
||||
+9
|
||||
-4
|
||||
+10
|
||||
+20
|
||||
+18
|
||||
+9
|
||||
-1
|
||||
+17
|
||||
-2
|
||||
+16
|
||||
+16
|
||||
-17
|
||||
+13
|
||||
+5
|
||||
-6
|
||||
-15
|
||||
-19
|
||||
+11
|
||||
-17
|
||||
-8
|
||||
+10
|
||||
-1
|
||||
+10
|
||||
-22
|
||||
-15
|
||||
+11
|
||||
+20
|
||||
-14
|
||||
+2
|
||||
+11
|
||||
+17
|
||||
+17
|
||||
+18
|
||||
-8
|
||||
+7
|
||||
+8
|
||||
-14
|
||||
+19
|
||||
-6
|
||||
+2
|
||||
+10
|
||||
+6
|
||||
+5
|
||||
+10
|
||||
+3
|
||||
-8
|
||||
-4
|
||||
-13
|
||||
-15
|
||||
-16
|
||||
-5
|
||||
-19
|
||||
+16
|
||||
-15
|
||||
+5
|
||||
-27
|
||||
-18
|
||||
+3
|
||||
-7
|
||||
+21
|
||||
-8
|
||||
-15
|
||||
-4
|
||||
-5
|
||||
-8
|
||||
+3
|
||||
+22
|
||||
+6
|
||||
+8
|
||||
+12
|
||||
-27
|
||||
+32
|
||||
-4
|
||||
+2
|
||||
+4
|
||||
-5
|
||||
+26
|
||||
-5
|
||||
-3
|
||||
-4
|
||||
+21
|
||||
+34
|
||||
+4
|
||||
-6
|
||||
+17
|
||||
-6
|
||||
+7
|
||||
+7
|
||||
+10
|
||||
-19
|
||||
+20
|
||||
+2
|
||||
+14
|
||||
+14
|
||||
+17
|
||||
+5
|
||||
+16
|
||||
-17
|
||||
+11
|
||||
-13
|
||||
-5
|
||||
+15
|
||||
+7
|
||||
-18
|
||||
-9
|
||||
-13
|
||||
-2
|
||||
-14
|
||||
-2
|
||||
-4
|
||||
-3
|
||||
-7
|
||||
+12
|
||||
+14
|
||||
-9
|
||||
+20
|
||||
+7
|
||||
+7
|
||||
+15
|
||||
+12
|
||||
-3
|
||||
-14
|
||||
-1
|
||||
+4
|
||||
-16
|
||||
+14
|
||||
-3
|
||||
-16
|
||||
-8
|
||||
+14
|
||||
+18
|
||||
+14
|
||||
-5
|
||||
-6
|
||||
+7
|
||||
+14
|
||||
+16
|
||||
-22
|
||||
-16
|
||||
-13
|
||||
-9
|
||||
-13
|
||||
-1
|
||||
-15
|
||||
-9
|
||||
-6
|
||||
+20
|
||||
+17
|
||||
+1
|
||||
-3
|
||||
+44
|
||||
+17
|
||||
+17
|
||||
+21
|
||||
+9
|
||||
+20
|
||||
-17
|
||||
+11
|
||||
+10
|
||||
-15
|
||||
+10
|
||||
+3
|
||||
+4
|
||||
+16
|
||||
+8
|
||||
-7
|
||||
+17
|
||||
+8
|
||||
+15
|
||||
-9
|
||||
+4
|
||||
+28
|
||||
+8
|
||||
-1
|
||||
-6
|
||||
-10
|
||||
-65
|
||||
+4
|
||||
-42
|
||||
-14
|
||||
-14
|
||||
-24
|
||||
-15
|
||||
+6
|
||||
+13
|
||||
-72
|
||||
-1
|
||||
-17
|
||||
-5
|
||||
+7
|
||||
-27
|
||||
+19
|
||||
-21
|
||||
-2
|
||||
+20
|
||||
-2
|
||||
+3
|
||||
-34
|
||||
+30
|
||||
+23
|
||||
-30
|
||||
-5
|
||||
+20
|
||||
-27
|
||||
+11
|
||||
-27
|
||||
-7
|
||||
-23
|
||||
+39
|
||||
-225
|
||||
+15
|
||||
+60
|
||||
+472
|
||||
+54569
|
||||
+1
|
||||
+15
|
||||
+13
|
||||
+6
|
||||
-10
|
||||
-13
|
||||
-2
|
||||
-6
|
||||
+13
|
||||
+2
|
||||
+5
|
||||
-10
|
||||
-5
|
||||
-11
|
||||
-1
|
||||
+18
|
||||
-12
|
||||
-15
|
||||
-7
|
||||
-1
|
||||
+13
|
||||
-18
|
||||
-1
|
||||
-5
|
||||
-2
|
||||
-14
|
||||
-5
|
||||
-4
|
||||
-16
|
||||
-10
|
||||
+8
|
||||
-1
|
||||
+20
|
||||
+11
|
||||
+15
|
||||
-3
|
||||
-17
|
||||
+8
|
||||
+11
|
||||
-6
|
||||
-9
|
||||
-8
|
||||
-11
|
||||
-1
|
||||
-13
|
||||
-3
|
||||
-8
|
||||
+12
|
||||
+18
|
||||
-11
|
||||
-17
|
||||
-12
|
||||
+6
|
||||
-7
|
||||
-3
|
||||
+15
|
||||
+9
|
||||
+13
|
||||
-14
|
||||
+18
|
||||
+20
|
||||
-6
|
||||
-12
|
||||
+2
|
||||
+20
|
||||
-12
|
||||
-23
|
||||
-17
|
||||
-7
|
||||
+1
|
||||
-24
|
||||
-17
|
||||
-7
|
||||
-18
|
||||
+3
|
||||
-13
|
||||
+14
|
||||
+2
|
||||
-12
|
||||
-16
|
||||
+2
|
||||
-35
|
||||
-3
|
||||
+2
|
||||
-18
|
||||
-14
|
||||
-13
|
||||
+10
|
||||
-3
|
||||
-17
|
||||
+4
|
||||
+23
|
||||
+16
|
||||
-7
|
||||
-30
|
||||
+29
|
||||
-19
|
||||
+18
|
||||
-3
|
||||
+20
|
||||
-7
|
||||
-3
|
||||
+77
|
||||
+1
|
||||
+42
|
||||
+18
|
||||
+9
|
||||
-1
|
||||
+23
|
||||
+57
|
||||
+8
|
||||
-12
|
||||
+1
|
||||
+5
|
||||
+12
|
||||
+3
|
||||
+10
|
||||
-1
|
||||
+14
|
||||
+20
|
||||
-7
|
||||
-3
|
||||
-14
|
||||
-12
|
||||
+9
|
||||
+16
|
||||
+16
|
||||
+12
|
||||
+14
|
||||
+11
|
||||
+11
|
||||
+2
|
||||
+1
|
||||
+19
|
||||
-10
|
||||
+18
|
||||
-17
|
||||
-9
|
||||
-11
|
||||
-8
|
||||
+10
|
||||
-1
|
||||
-110292
|
62
2018/day_01/main.go
Normal file
62
2018/day_01/main.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//count to maintain the total sum of the frequence changes
|
||||
count := 0
|
||||
//current to maintain the partial frequence at a stage
|
||||
current := 0
|
||||
//freqChange to store the individual frequence changes
|
||||
var freqChange []int
|
||||
//freqList to store all the stage frequences
|
||||
freqList := map[int]bool{0: true}
|
||||
|
||||
//We open the input file
|
||||
file, err := os.Open("./input")
|
||||
if err != nil {
|
||||
//If there is an error we print it in the stderr and exit(1)
|
||||
log.Fatal(err)
|
||||
}
|
||||
//We defer the closure of the file
|
||||
defer file.Close()
|
||||
|
||||
//We create a scanner to the file
|
||||
scan := bufio.NewScanner(file)
|
||||
|
||||
//We iterate throught the file line
|
||||
for scan.Scan() {
|
||||
//We convert each line into an int
|
||||
num, err := strconv.Atoi(scan.Text())
|
||||
if err != nil {
|
||||
//If the conversion generate an error we print it to stderr
|
||||
log.Printf("Error converting line to int: %v", err)
|
||||
} else {
|
||||
//Otherwise we add the current freq change to count
|
||||
count += num
|
||||
//And we append it to freqChange
|
||||
freqChange = append(freqChange, num)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("Part One: %v\n", count)
|
||||
|
||||
for {
|
||||
for _, freqMod := range freqChange {
|
||||
current += freqMod
|
||||
_, found := freqList[current]
|
||||
if found {
|
||||
fmt.Printf("Part Two: %v\n", current)
|
||||
os.Exit(0)
|
||||
} else {
|
||||
freqList[current] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
250
2018/day_02/input
Normal file
250
2018/day_02/input
Normal file
@@ -0,0 +1,250 @@
|
||||
xrecqmdonskvzupalfkwhjctdb
|
||||
xrlgqmavnskvzupalfiwhjctdb
|
||||
xregqmyonskvzupalfiwhjpmdj
|
||||
areyqmyonskvzupalfiwhjcidb
|
||||
xregqpyonskvzuaalfiwhjctdy
|
||||
xwegumyonskvzuphlfiwhjctdb
|
||||
xregumymnskvzupalfiwhjctib
|
||||
xregqmyonjkvzupalfvwijctdb
|
||||
xrmgqmyonsdvzupalfiwhjcthb
|
||||
xrpgqmyonskvzupalfiwhcitdb
|
||||
xregvmysnsjvzupalfiwhjctdb
|
||||
xregqsyonskvzupgqfiwhjctdb
|
||||
qreuqmyonskvzupalfiwyjctdb
|
||||
xrecqmyenskvzupalyiwhjctdb
|
||||
xmegqmyonskvzhpalfcwhjctdb
|
||||
xiegqmyonskvzupalfkwhjjtdb
|
||||
xreaqmyofskfzupalfiwhjctdb
|
||||
xregqmypnskvzupalmiwhjltdb
|
||||
xretqmmonskvzupalfiwhwcfdb
|
||||
xrexqmkonskvzupalfiwjjctdb
|
||||
xrigqmyonskvgupplfiwhjctdb
|
||||
xregqmyotskvzupalfywhjctdm
|
||||
xcegmmyonsvvzupalfiwhjctdb
|
||||
xrezqmypnskvznpalfiwhjctdb
|
||||
xragqmyonskvzupblfiwajctdb
|
||||
xregqmyonskvzwpapfiwhjctqb
|
||||
xoegqmyoyskvzupaufiwhjctdb
|
||||
xrcgqmyjnskvzupalfcwhjctdb
|
||||
xregqmyonskvzudalfipajctdb
|
||||
xsegqmyonsklzupalwiwhjctdb
|
||||
xregqmyocskvduaalfiwhjctdb
|
||||
xhegqmyfnskvzupalflwhjctdb
|
||||
xregqmymnykvzupalfiwhjctdm
|
||||
xregqmybnskvzupacfiwdjctdb
|
||||
xaegqmlonskvzfpalfiwhjctdb
|
||||
xoegtmyonskvzupalfiwhwctdb
|
||||
xregqmyohskvzupaqfiwhjccdb
|
||||
xoegqmyonstvzupalfiwhjctbb
|
||||
mregnmyonskszupalfiwhjctdb
|
||||
xreoqmycnskvzupalfiphjctdb
|
||||
xregqmyocskvdupacfiwhjctdb
|
||||
xregqmyonskvzupajqiahjctdb
|
||||
xregqmyonslvwupalfiwhjcfdb
|
||||
xregqmyonskvzapalfiwhqcthb
|
||||
xrerqmyonskwzupalfiwhjctdt
|
||||
xrefqmfonskvzupalfiwcjctdb
|
||||
xregqmyonskvzupadfiwhjxedb
|
||||
iregqhyonskvzupaliiwhjctdb
|
||||
iregqmyotskvzucalfiwhjctdb
|
||||
xrbgqmaonrkvzupalfiwhjctdb
|
||||
xregqmyonskvzupalfixhdctdf
|
||||
xrehqmyonskvzupalfiwijctdd
|
||||
xvegqmyonskvzupaleuwhjctdb
|
||||
xregqmyiyskvzupalfiwqjctdb
|
||||
hregqmyonskvzupaxfiwhjptdb
|
||||
xregamyznskbzupalfiwhjctdb
|
||||
xreyqmyonskvgupalziwhjctdb
|
||||
xregqmysnskvzupalfiwhgctdu
|
||||
xojgqmyonskvzupalfiwbjctdb
|
||||
xrkgqmyonskvlupalfiwhjcwdb
|
||||
xregqmyonwkvxupalfiwajctdb
|
||||
xregqmyonsuvzupalfjwhjcxdb
|
||||
xregqmyonskgzucalfiwhjstdb
|
||||
xaegqmyonfkvzupalfiwhjcttb
|
||||
xlegqmyonskvzupazfiwhjctqb
|
||||
xrejqmyonskvzqpaldiwhjctdb
|
||||
xreguryonskvzupalfiwhjctdz
|
||||
xregqsyoeskvzupalfiwhjctdt
|
||||
xregqmyonskvzubalfirhjctdp
|
||||
xrepqmymnskvzupadfiwhjctdb
|
||||
xregqayonskvzuoalfichjctdb
|
||||
xreqqmyonskvzunalfiwojctdb
|
||||
xregqmyonsivzufalciwhjctdb
|
||||
xregqqeonskvzupanfiwhjctdb
|
||||
xoegqmyunskvzppalfiwhjctdb
|
||||
xregqmyonskvzupalfqwhnftdb
|
||||
xregqmyonskvzuralkiwhjcudb
|
||||
xrwgqmymnskvzupalfiwhjcgdb
|
||||
xvrgqmyonskvzupalfiwhjcthb
|
||||
xregemyonskkzupalfiwhjctbb
|
||||
xregqmyonsevzupalfiwhjjtdl
|
||||
xregqmyonckvcupajfiwhjctdb
|
||||
xregqmysnskvzunalfnwhjctdb
|
||||
xreowmyonskvkupalfiwhjctdb
|
||||
xregqmyonskvjupalfiwhjytdr
|
||||
xregqmyonskyzupaffiwhmctdb
|
||||
xrsgqmyonszvzupmlfiwhjctdb
|
||||
xzegqmyonskvnupalfiwfjctdb
|
||||
qregqmyonskvzupalfiwhrctjb
|
||||
xpegqmyonsivzupqlfiwhjctdb
|
||||
xregqmyoyskrzupalfiwhjctdx
|
||||
xregqmyonsqvzupalfiwhjdndb
|
||||
xregjmyonskvzppalfiwhjcgdb
|
||||
xregqmyziskvzupalfiwhjctib
|
||||
xregqmyonmkvbupalfiwhjckdb
|
||||
xtegamyonskvzupalniwhjctdb
|
||||
xregqpyonskvzhpwlfiwhjctdb
|
||||
xvegqmfonskvzupalfiwhjcadb
|
||||
xregqmyonskvzupaysiwhjctxb
|
||||
xrejqmyonudvzupalfiwhjctdb
|
||||
llegqmyonskvzbpalfiwhjctdb
|
||||
tcegqmbonskvzupalfiwhjctdb
|
||||
lregqmyohskvzupalfiwhjcttb
|
||||
xrngqmcfnskvzupalfiwhjctdb
|
||||
xregqmyonspvzuuplfiwhjctdb
|
||||
xrxgqmyonslvzupalfiwhjctdo
|
||||
xregqmyonskvzulalfuwhjdtdb
|
||||
xregqmnonskvzupalfvwhjckdb
|
||||
xregqbyfnskvzupaltiwhjctdb
|
||||
xregqmyodsovzwpalfiwhjctdb
|
||||
xregomyonskvhrpalfiwhjctdb
|
||||
xregqmfdnskvzupalliwhjctdb
|
||||
xregqmyonskvzupaabithjctdb
|
||||
xrngamyonskvzupalfiwhjcttb
|
||||
xrhgqmyonskvzupaldifhjctdb
|
||||
xrygzmyonskvzupatfiwhjctdb
|
||||
xregqmyonskvzupiqtiwhjctdb
|
||||
xregqmyonfkvzupalfiwxjcsdb
|
||||
xregqsyunskvzupalfiwhjctde
|
||||
xrzgqmyolskvzupasfiwhjctdb
|
||||
xgegqmyoyskvzupalfiwfjctdb
|
||||
xrvgqlyohskvzupalfiwhjctdb
|
||||
xregcmyonskvzuprlyiwhjctdb
|
||||
xregqmyonskvwjpalfiwsjctdb
|
||||
xrfgqmyonskvzupalfidhactdb
|
||||
xcegqmyonwkvzdpalfiwhjctdb
|
||||
nregqmyrnskvzupalciwhjctdb
|
||||
xcegqmyonskvzvpalfiwhjctdj
|
||||
xregqmyonskvzupqssiwhjctdb
|
||||
xregcmyonskvzupalfinhjutdb
|
||||
xregqmyonskvzupzlfiwcjctnb
|
||||
xnegqmyozskvzbpalfiwhjctdb
|
||||
xregvmponskvzupalfiwhsctdb
|
||||
xregqmyonskvpupalqichjctdb
|
||||
xreqqmyonskvzupauuiwhjctdb
|
||||
xregqryonskvzupatfiwhjctyb
|
||||
hregqmyonokvzupalfiwhmctdb
|
||||
xreuqmionckvzupalfiwhjctdb
|
||||
xregqmyoiskvzupanfiwhjntdb
|
||||
xrdgqmronskvzupaluiwhjctdb
|
||||
xadgqmyunskvzupalfiwhjctdb
|
||||
eregqmzonskvzupakfiwhjctdb
|
||||
xiegqmyonskvnupblfiwhjctdb
|
||||
yregqmzonskvzupalfiwhjotdb
|
||||
xregqmyonskvjupalfiwhjhtvb
|
||||
wregqmyonskvzzprlfiwhjctdb
|
||||
xregqmyovskvzupalgiuhjctdb
|
||||
xregqmyonskjzupelfuwhjctdb
|
||||
xregqmysuskvpupalfiwhjctdb
|
||||
xrebqkyonskvzupalfiwpjctdb
|
||||
xregcmyonskvzipalfiwhjcttb
|
||||
xregqmyonskdyupalfiwgjctdb
|
||||
xregcmyonskvzupalfiwijctnb
|
||||
xregqmyonsovdupalfrwhjctdb
|
||||
xregqmaonskvzupalnkwhjctdb
|
||||
xregqmysnfkvzupalfiwhictdb
|
||||
xregqmyonswvzupalfiyhjctdf
|
||||
xreoqmyrnskvzupalfihhjctdb
|
||||
tregqmydnskvzupalfizhjctdb
|
||||
xregxmyonykvzupalfnwhjctdb
|
||||
xzegqnyonskuzupalfiwhjctdb
|
||||
xregqmfonszvvupalfiwhjctdb
|
||||
xrerqmyjnskvzupalfiwhpctdb
|
||||
xregqmyanskvzupalffphjctdb
|
||||
rregqmyogskvzupalfiehjctdb
|
||||
xrpgqmyonspvzupalfiwgjctdb
|
||||
xuegqmppnskvzupalfiwhjctdb
|
||||
xregqmyonskvzqpalsiwhjhtdb
|
||||
xregqzyonskvzkpalfiwujctdb
|
||||
xrdgqmyonskvzupglfiwhjctdu
|
||||
xregqmyonskqzupahciwhjctdb
|
||||
treqqmyonskvzupalfiwhjcqdb
|
||||
vlegqmyonskvzupalfiwhjwtdb
|
||||
xregjmyonskviupglfiwhjctdb
|
||||
xreggmyanskvzupalfiwhjcydb
|
||||
xregqmybnskvzuprlfiwhjmtdb
|
||||
xrsgqmyonskizupagfiwhjctdb
|
||||
xregqmyenskvzupalfvwhjctib
|
||||
lrygqmyonsrvzupalfiwhjctdb
|
||||
xregqmjonskvqupalfiwhjctdu
|
||||
xregqmyonsknzmpzlfiwhjctdb
|
||||
xregqmyonhkvzupllfiwhjctdz
|
||||
xregqmronskvdumalfiwhjctdb
|
||||
xrpgqmyonskvzupalfhwhjhtdb
|
||||
xfegqmeonskvzupasfiwhjctdb
|
||||
xregqqyonskvzrpalfiwijctdb
|
||||
xretqmmonskvzupalfiwhjcfdb
|
||||
xregqmyonskvznpalniwhjztdb
|
||||
xregqmyqnskvzuoalfiwhhctdb
|
||||
xregqmyonsbvzupalviwhjxtdb
|
||||
xregqmyonskvzupazmiwhhctdb
|
||||
xregqmyosskvzupalflwhjctdw
|
||||
xtegqmyonskvzupamciwhjctdb
|
||||
xregamyonskvzbpalfiwhqctdb
|
||||
xregqmgonskvzupalfiwhictxb
|
||||
xregqmyonskvjupvlfnwhjctdb
|
||||
xrthqmyonskvzupalfiwhjctub
|
||||
xrexqmyoyskvzupalfiwhjcadb
|
||||
xvegqmyonskvxupalfiwhjztdb
|
||||
xregqmyonskgzupalhiwhjptdb
|
||||
xregqmysnskvzufalpiwhjctdb
|
||||
xregqmyonskvbipalfighjctdb
|
||||
xregqmyonskvzupylfiwhjwvdb
|
||||
gregqmyonskvzupalfikhjctdt
|
||||
ujegqmyonskvzupalfiwhjctlb
|
||||
nreqqmyonskjzupalfiwhjctdb
|
||||
xregqmyonskvzupanfbwhjchdb
|
||||
xregqyyoeskwzupalfiwhjctdb
|
||||
xregqmyokskvzgpalfiwhnctdb
|
||||
lregqmyonskvzupalfawsjctdb
|
||||
xtegqmyonskvzmpalfiwhjctmb
|
||||
xtegqvyonskvzupalfiwhjdtdb
|
||||
xpegqpyonekvzupalfiwhjctdb
|
||||
qregqmyonskvzupalfiwmjctdn
|
||||
xregqnyosskvzupalfibhjctdb
|
||||
xregqmyonsknzupalflwhjctfb
|
||||
xregqmxoyskvzuealfiwhjctdb
|
||||
xregdmyoeskvzupalfiwhfctdb
|
||||
xremmmyonskvzupalfiwhxctdb
|
||||
xregqmconskvzupylfuwhjctdb
|
||||
xregqmyonskvzupawiiwhictdb
|
||||
xlegsmyonskvzupalfiwhbctdb
|
||||
xregqmyonsavzopalyiwhjctdb
|
||||
xregqmyonskczupalfibhvctdb
|
||||
xregqmyonskvzvpalfiunjctdb
|
||||
xregqmyonskvdupalfiwhjczdp
|
||||
xregqmyonskvzupklfswhhctdb
|
||||
xrelqmyonskvzupalyiwhjctdi
|
||||
xrcgqmyonskvzupalfieqjctdb
|
||||
xregqmnonskvzupacfewhjctdb
|
||||
xrwgqmyonskvzuealfiwhcctdb
|
||||
xregqiyonsevzmpalfiwhjctdb
|
||||
xregqmyonjyvzupalfiwhjckdb
|
||||
xregqmyonyklzupadfiwhjctdb
|
||||
xregqmyanskvzupolfiwhjctpb
|
||||
xdbgqmyonskvzupslfiwhjctdb
|
||||
xregqmhonykvzupalfawhjctdb
|
||||
xregqmqonsivzupalfifhjctdb
|
||||
xregqgyonsrvzupalfiwhjctib
|
||||
xregqmyofskvzupalfiwlfctdb
|
||||
xregqmyovskvzupllftwhjctdb
|
||||
xregqmyonskvzupaciiwhuctdb
|
||||
xregqmyonsdvzuhalfiwhjhtdb
|
||||
xreiqmyonskvzupalfiwhncldb
|
||||
xregqmyongkvzugalfiwhjctxb
|
||||
xregqsyonskvzrpmlfiwhjctdb
|
||||
xrogqmyonskvzxpalfiwhbctdb
|
||||
xregqmkonskvzuqalfiwhjptdb
|
||||
xregqmyonskvvxpalfiwhactdb
|
||||
xregqmyonskvzupsliiwhwctdb
|
84
2018/day_02/main.go
Normal file
84
2018/day_02/main.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func checkDuplicates(s string) (bool, bool) {
|
||||
two := false
|
||||
three := false
|
||||
charsInString := map[string]int{}
|
||||
chars := strings.Split(s, "")
|
||||
for _, c := range chars {
|
||||
charsInString[c]++
|
||||
}
|
||||
for _, c := range charsInString {
|
||||
if c == 2 {
|
||||
two = true
|
||||
} else if c == 3 {
|
||||
three = true
|
||||
}
|
||||
}
|
||||
return two, three
|
||||
}
|
||||
|
||||
func compareStrings(s1, s2 string) (string, bool) {
|
||||
diffCount := 0
|
||||
diffString := ""
|
||||
for i := 0; i < len(s1) && diffCount < 2; i++ {
|
||||
if s1[i] == s2[i] {
|
||||
diffString += string(s1[i])
|
||||
} else {
|
||||
diffCount++
|
||||
}
|
||||
}
|
||||
if diffCount >= 2 {
|
||||
return "", false
|
||||
}
|
||||
return diffString, true
|
||||
}
|
||||
|
||||
func main() {
|
||||
twos := 0
|
||||
threes := 0
|
||||
var stringStore []string
|
||||
//We open the input file
|
||||
file, err := os.Open("./input")
|
||||
if err != nil {
|
||||
//If there is an error we print it in the stderr and exit(1)
|
||||
log.Fatal(err)
|
||||
}
|
||||
//We defer the closure of the file
|
||||
defer file.Close()
|
||||
|
||||
//We create a scanner to the file
|
||||
scan := bufio.NewScanner(file)
|
||||
|
||||
//We iterate throught the file line
|
||||
for scan.Scan() {
|
||||
currentString := scan.Text()
|
||||
stringStore = append(stringStore, currentString)
|
||||
two, three := checkDuplicates(currentString)
|
||||
if two {
|
||||
twos++
|
||||
}
|
||||
if three {
|
||||
threes++
|
||||
}
|
||||
}
|
||||
fmt.Printf("Part One: the checksum is %v\n", twos*threes)
|
||||
|
||||
for i, str := range stringStore {
|
||||
for j := i + 1; j < len(stringStore); j++ {
|
||||
ret, valid := compareStrings(str, stringStore[j])
|
||||
if valid {
|
||||
fmt.Printf("Part Two: the common letters are %v\n", ret)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1411
2018/day_03/input
Normal file
1411
2018/day_03/input
Normal file
File diff suppressed because it is too large
Load Diff
71
2018/day_03/main.go
Normal file
71
2018/day_03/main.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type claim struct {
|
||||
x int
|
||||
y int
|
||||
len int
|
||||
height int
|
||||
overlapping bool
|
||||
}
|
||||
|
||||
func main() {
|
||||
var fabric [1000][1000]int
|
||||
claims := make(map[int]*claim)
|
||||
inchesCount := 0
|
||||
file, err := os.Open("./input")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scan := bufio.NewScanner(file)
|
||||
|
||||
for scan.Scan() {
|
||||
line := scan.Text()
|
||||
line = strings.Join(strings.Fields(line), "")
|
||||
|
||||
info := strings.Split(line, "#")[1]
|
||||
id, _ := strconv.Atoi(strings.Split(info, "@")[0])
|
||||
measures := strings.Split(info, "@")[1]
|
||||
xy := strings.Split(strings.Split(measures, ":")[0], ",")
|
||||
dim := strings.Split(strings.Split(measures, ":")[1], "x")
|
||||
x, _ := strconv.Atoi(xy[0])
|
||||
y, _ := strconv.Atoi(xy[1])
|
||||
len, _ := strconv.Atoi(dim[0])
|
||||
height, _ := strconv.Atoi(dim[1])
|
||||
|
||||
newClaim := claim{x, y, len, height, false}
|
||||
|
||||
for i := x; i < x+len; i++ {
|
||||
for j := y; j < y+height; j++ {
|
||||
if fabric[i][j] == 0 {
|
||||
fabric[i][j] = id
|
||||
} else if fabric[i][j] != -1 {
|
||||
claims[fabric[i][j]].overlapping = true
|
||||
fabric[i][j] = -1
|
||||
inchesCount++
|
||||
}
|
||||
if fabric[i][j] == -1 {
|
||||
newClaim.overlapping = true
|
||||
}
|
||||
}
|
||||
}
|
||||
claims[id] = &newClaim
|
||||
}
|
||||
fmt.Printf("Part One: square inches of fabric within two or more claims %v\n", inchesCount)
|
||||
|
||||
for id, c := range claims {
|
||||
if !c.overlapping {
|
||||
fmt.Printf("Part Two: the id of the claim that doesn't overlap is %v\n", id)
|
||||
}
|
||||
}
|
||||
}
|
1134
2018/day_04/input
Normal file
1134
2018/day_04/input
Normal file
File diff suppressed because it is too large
Load Diff
115
2018/day_04/main.go
Normal file
115
2018/day_04/main.go
Normal file
@@ -0,0 +1,115 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type guard struct {
|
||||
timeCard [60]int
|
||||
}
|
||||
|
||||
func printSchedule(guardsSchedule map[int]guard) {
|
||||
fmt.Print("ID\t")
|
||||
for i := 0; i < 60; i++ {
|
||||
fmt.Printf("%v ", i)
|
||||
}
|
||||
fmt.Print("\tSUM\n")
|
||||
for i, g := range guardsSchedule {
|
||||
sum := 0
|
||||
fmt.Printf("%v\t", i)
|
||||
for i, t := range g.timeCard {
|
||||
sum += t
|
||||
if i < 59 && i > 8 && g.timeCard[i+1] < 10 {
|
||||
fmt.Printf("%v ", t)
|
||||
} else {
|
||||
fmt.Printf("%v ", t)
|
||||
}
|
||||
}
|
||||
fmt.Printf("\t%v\n", sum)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
var lines []string
|
||||
guardsSchedule := make(map[int]guard)
|
||||
|
||||
file, err := os.Open("./input")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scan := bufio.NewScanner(file)
|
||||
for scan.Scan() {
|
||||
lines = append(lines, scan.Text())
|
||||
}
|
||||
|
||||
sort.Strings(lines)
|
||||
|
||||
currentGuardID := -1
|
||||
sleepTime := 0
|
||||
wakeTime := 0
|
||||
for _, line := range lines {
|
||||
if strings.Contains(line, "Guard") {
|
||||
currentGuardID, _ = strconv.Atoi(strings.Split(strings.Split(line, "#")[1], " ")[0])
|
||||
_, exists := guardsSchedule[currentGuardID]
|
||||
if !exists {
|
||||
guardsSchedule[currentGuardID] = *new(guard)
|
||||
}
|
||||
} else if strings.Contains(line, "falls asleep") {
|
||||
st, _ := strconv.Atoi(strings.Split(strings.Split(strings.Split(line, "]")[0], " ")[1], ":")[1])
|
||||
sleepTime = st
|
||||
} else if strings.Contains(line, "wakes up") {
|
||||
wt, _ := strconv.Atoi(strings.Split(strings.Split(strings.Split(line, "]")[0], " ")[1], ":")[1])
|
||||
wakeTime = wt
|
||||
timeSchedule := guardsSchedule[currentGuardID]
|
||||
for j := sleepTime; j < wakeTime; j++ {
|
||||
timeSchedule.timeCard[j]++
|
||||
}
|
||||
guardsSchedule[currentGuardID] = timeSchedule
|
||||
}
|
||||
}
|
||||
|
||||
mostAsleepTime := -1
|
||||
mostAsleepID := -1
|
||||
for i, g := range guardsSchedule {
|
||||
sum := 0
|
||||
for _, t := range g.timeCard {
|
||||
sum += t
|
||||
}
|
||||
if sum > mostAsleepTime {
|
||||
mostAsleepTime = sum
|
||||
mostAsleepID = i
|
||||
}
|
||||
}
|
||||
|
||||
mostAsleepMinute := -1
|
||||
max := -1
|
||||
for i, t := range guardsSchedule[mostAsleepID].timeCard {
|
||||
if t > max {
|
||||
max = t
|
||||
mostAsleepMinute = i
|
||||
}
|
||||
}
|
||||
fmt.Printf("Part One: %v\n", mostAsleepMinute*mostAsleepID)
|
||||
|
||||
mostAsleepMinute = -1
|
||||
max = -1
|
||||
mostAsleepID = -1
|
||||
for i, g := range guardsSchedule {
|
||||
for j, t := range g.timeCard {
|
||||
if t > max {
|
||||
max = t
|
||||
mostAsleepMinute = j
|
||||
mostAsleepID = i
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Printf("Part Two: %v\n", mostAsleepMinute*mostAsleepID)
|
||||
}
|
1
2018/day_05/input
Normal file
1
2018/day_05/input
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user