refactor: massive refactor to have only one binary to call
This commit is contained in:
79
internal/2020/DayFive/code.go
Normal file
79
internal/2020/DayFive/code.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package dayfive
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2020D5", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func calculateSeatID(pass string) int {
|
||||
if len(pass) < 10 {
|
||||
return -1
|
||||
}
|
||||
rowStr := pass[:7]
|
||||
columnStr := pass[7:10]
|
||||
|
||||
row := 0
|
||||
for idx, char := range rowStr {
|
||||
if char == 'B' {
|
||||
row |= 1 << (6 - idx)
|
||||
}
|
||||
}
|
||||
|
||||
column := 0
|
||||
for idx, char := range columnStr {
|
||||
if char == 'R' {
|
||||
column |= 1 << (2 - idx)
|
||||
}
|
||||
}
|
||||
|
||||
return row*8 + column
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []string {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
return strings.Split(string(content), "\n")
|
||||
}
|
||||
|
||||
func PartOne(input []string) int {
|
||||
maxSeatID := 0
|
||||
for _, pass := range input {
|
||||
seatID := calculateSeatID(pass)
|
||||
if seatID > maxSeatID {
|
||||
maxSeatID = seatID
|
||||
}
|
||||
}
|
||||
return maxSeatID
|
||||
}
|
||||
|
||||
func PartTwo(input []string) int {
|
||||
seatIDs := make(map[int]bool)
|
||||
minSeatID := 1000
|
||||
maxSeatID := 0
|
||||
|
||||
for _, pass := range input {
|
||||
if len(pass) < 10 {
|
||||
continue
|
||||
}
|
||||
seatID := calculateSeatID(pass)
|
||||
seatIDs[seatID] = true
|
||||
if seatID < minSeatID {
|
||||
minSeatID = seatID
|
||||
}
|
||||
if seatID > maxSeatID {
|
||||
maxSeatID = seatID
|
||||
}
|
||||
}
|
||||
|
||||
for seatID := minSeatID + 1; seatID < maxSeatID; seatID++ {
|
||||
if !seatIDs[seatID] && seatIDs[seatID-1] && seatIDs[seatID+1] {
|
||||
return seatID
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
35
internal/2020/DayFive/code_test.go
Normal file
35
internal/2020/DayFive/code_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package dayfive
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
input := []string{
|
||||
"FBFBBFFRLR",
|
||||
"BFFFBBFRRR",
|
||||
"FFFBBBFRRR",
|
||||
"BBFFBBFRLL",
|
||||
}
|
||||
expected := 820
|
||||
got := PartOne(input)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
input := []string{
|
||||
"FFFFFFFLLL",
|
||||
"FFFFFFFLLR",
|
||||
"FFFFFFFLRL",
|
||||
"FFFFFFFLRR",
|
||||
"FFFFFFFRLR",
|
||||
"FFFFFFFRRL",
|
||||
"FFFFFFFRRR",
|
||||
}
|
||||
expected := 4
|
||||
got := PartTwo(input)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
154
internal/2020/DayFour/code.go
Normal file
154
internal/2020/DayFour/code.go
Normal file
@@ -0,0 +1,154 @@
|
||||
package dayfour
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2020D4", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []string {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
|
||||
text := string(content)
|
||||
passports := strings.Split(text, "\n\n")
|
||||
|
||||
result := make([]string, 0, len(passports))
|
||||
for _, passport := range passports {
|
||||
passport = strings.TrimSpace(passport)
|
||||
if passport == "" {
|
||||
continue
|
||||
}
|
||||
passport = strings.ReplaceAll(passport, "\n", " ")
|
||||
passport = strings.Join(strings.Fields(passport), " ")
|
||||
result = append(result, passport)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func PartOne(data []string) int {
|
||||
count := 0
|
||||
required := []string{"byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"}
|
||||
for _, passport := range data {
|
||||
fields := strings.Fields(passport)
|
||||
present := make(map[string]bool)
|
||||
for _, field := range fields {
|
||||
if idx := strings.Index(field, ":"); idx != -1 {
|
||||
present[field[:idx]] = true
|
||||
}
|
||||
}
|
||||
missing := false
|
||||
for _, field := range required {
|
||||
if !present[field] {
|
||||
missing = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !missing {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func PartTwo(data []string) int {
|
||||
isNumberInRange := func(value string, min, max int, digits int) bool {
|
||||
if len(value) != digits {
|
||||
return false
|
||||
}
|
||||
n, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return n >= min && n <= max
|
||||
}
|
||||
|
||||
isValidHeight := func(value string) bool {
|
||||
if len(value) < 3 {
|
||||
return false
|
||||
}
|
||||
unit := value[len(value)-2:]
|
||||
number := value[:len(value)-2]
|
||||
n, err := strconv.Atoi(number)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if unit == "cm" {
|
||||
return n >= 150 && n <= 193
|
||||
}
|
||||
if unit == "in" {
|
||||
return n >= 59 && n <= 76
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
isValidHairColor := func(value string) bool {
|
||||
if len(value) != 7 || value[0] != '#' {
|
||||
return false
|
||||
}
|
||||
for _, c := range value[1:] {
|
||||
if !((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
isValidPID := func(value string) bool {
|
||||
if len(value) != 9 {
|
||||
return false
|
||||
}
|
||||
for _, c := range value {
|
||||
if c < '0' || c > '9' {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
validECL := map[string]bool{
|
||||
"amb": true, "blu": true, "brn": true, "gry": true,
|
||||
"grn": true, "hzl": true, "oth": true,
|
||||
}
|
||||
|
||||
required := []string{"byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"}
|
||||
count := 0
|
||||
|
||||
for _, passport := range data {
|
||||
fields := map[string]string{}
|
||||
for field := range strings.FieldsSeq(passport) {
|
||||
parts := strings.SplitN(field, ":", 2)
|
||||
if len(parts) == 2 {
|
||||
fields[parts[0]] = parts[1]
|
||||
}
|
||||
}
|
||||
|
||||
passportValidators := map[string]func(string) bool{
|
||||
"byr": func(v string) bool { return isNumberInRange(v, 1920, 2002, 4) },
|
||||
"iyr": func(v string) bool { return isNumberInRange(v, 2010, 2020, 4) },
|
||||
"eyr": func(v string) bool { return isNumberInRange(v, 2020, 2030, 4) },
|
||||
"hgt": isValidHeight,
|
||||
"hcl": isValidHairColor,
|
||||
"ecl": func(v string) bool { return validECL[v] },
|
||||
"pid": isValidPID,
|
||||
}
|
||||
|
||||
valid := true
|
||||
for _, key := range required {
|
||||
value, ok := fields[key]
|
||||
if !ok || !passportValidators[key](value) {
|
||||
valid = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if valid {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
27
internal/2020/DayFour/code_test.go
Normal file
27
internal/2020/DayFour/code_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package dayfour
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []string{
|
||||
"ecl:gry pid:860033327 eyr:2020 hcl:#fffffd byr:1937 iyr:2017 cid:147 hgt:183cm",
|
||||
"iyr:2013 ecl:amb cid:350 eyr:2023 pid:028048884 hcl:#cfa07d byr:1929",
|
||||
"hcl:#ae17e1 iyr:2013 eyr:2024 ecl:brn pid:760753108 byr:1931 hgt:179cm",
|
||||
"hcl:#cfa07d eyr:2025 pid:166559648 iyr:2011 ecl:brn hgt:59in",
|
||||
}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 2
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 2
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
50
internal/2020/DayOne/code.go
Normal file
50
internal/2020/DayOne/code.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package dayone
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2020D1", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []int {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
lines := strings.Fields(string(content))
|
||||
var data []int
|
||||
for _, line := range lines {
|
||||
num, _ := strconv.Atoi(line)
|
||||
data = append(data, num)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func PartOne(data []int) int {
|
||||
seen := make(map[int]bool)
|
||||
for _, number := range data {
|
||||
complement := 2020 - number
|
||||
if seen[complement] {
|
||||
return number * complement
|
||||
}
|
||||
seen[number] = true
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func PartTwo(data []int) int {
|
||||
seen := make(map[int]bool)
|
||||
for idx := range data {
|
||||
for _, number := range data[idx+1:] {
|
||||
complement := 2020 - data[idx] - number
|
||||
if seen[complement] {
|
||||
return complement * data[idx] * number
|
||||
}
|
||||
}
|
||||
seen[data[idx]] = true
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
22
internal/2020/DayOne/code_test.go
Normal file
22
internal/2020/DayOne/code_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package dayone
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []int{1721, 979, 366, 299, 675, 1456}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 514579
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 241861950
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
70
internal/2020/DaySix/code.go
Normal file
70
internal/2020/DaySix/code.go
Normal file
@@ -0,0 +1,70 @@
|
||||
package daysix
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2020D6", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []string {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
return strings.Split(strings.TrimSpace(string(content)), "\n")
|
||||
}
|
||||
|
||||
func PartOne(input []string) int {
|
||||
total := 0
|
||||
groupAnswers := make(map[rune]bool)
|
||||
|
||||
for idx, line := range input {
|
||||
if line != "" {
|
||||
for _, char := range line {
|
||||
if char >= 'a' && char <= 'z' {
|
||||
groupAnswers[char] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if line == "" || idx == len(input)-1 {
|
||||
total += len(groupAnswers)
|
||||
groupAnswers = make(map[rune]bool)
|
||||
}
|
||||
}
|
||||
|
||||
total += len(groupAnswers)
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
func PartTwo(input []string) int {
|
||||
total := 0
|
||||
groupAnswers := make(map[rune]int)
|
||||
groupSize := 0
|
||||
|
||||
for idx, line := range input {
|
||||
if line != "" {
|
||||
groupSize++
|
||||
for _, char := range line {
|
||||
if char >= 'a' && char <= 'z' {
|
||||
groupAnswers[char]++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if line == "" || idx == len(input)-1 {
|
||||
for _, count := range groupAnswers {
|
||||
if count == groupSize {
|
||||
total++
|
||||
}
|
||||
}
|
||||
groupAnswers = make(map[rune]int)
|
||||
groupSize = 0
|
||||
}
|
||||
}
|
||||
|
||||
return total
|
||||
}
|
||||
|
||||
38
internal/2020/DaySix/code_test.go
Normal file
38
internal/2020/DaySix/code_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package daysix
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []string{
|
||||
"abc",
|
||||
"",
|
||||
"a",
|
||||
"b",
|
||||
"c",
|
||||
"",
|
||||
"ab",
|
||||
"ac",
|
||||
"",
|
||||
"a",
|
||||
"a",
|
||||
"a",
|
||||
"a",
|
||||
"",
|
||||
"b",
|
||||
}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 11
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 6
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
52
internal/2020/DayThree/code.go
Normal file
52
internal/2020/DayThree/code.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package daythree
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2020D3", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []string {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
return strings.Split(string(content), "\n")
|
||||
}
|
||||
|
||||
func PartOne(input []string) int {
|
||||
trees := 0
|
||||
column := 0
|
||||
for row := range input {
|
||||
if len(input[row]) == 0 {
|
||||
continue
|
||||
}
|
||||
if input[row][column%len(input[row])] == '#' {
|
||||
trees++
|
||||
}
|
||||
column += 3
|
||||
}
|
||||
return trees
|
||||
}
|
||||
|
||||
func PartTwo(input []string) int {
|
||||
result := 1
|
||||
slopes := [][]int{{1, 1}, {3, 1}, {5, 1}, {7, 1}, {1, 2}}
|
||||
for _, slope := range slopes {
|
||||
trees := 0
|
||||
column := 0
|
||||
for row := 0; row < len(input); row += slope[1] {
|
||||
if len(input[row]) == 0 {
|
||||
continue
|
||||
}
|
||||
if input[row][column%len(input[row])] == '#' {
|
||||
trees++
|
||||
}
|
||||
column += slope[0]
|
||||
}
|
||||
result *= trees
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
34
internal/2020/DayThree/code_test.go
Normal file
34
internal/2020/DayThree/code_test.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package daythree
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []string{
|
||||
"..##.......",
|
||||
"#...#...#..",
|
||||
".#....#..#.",
|
||||
"..#.#...#.#",
|
||||
".#...##..#.",
|
||||
"..#.##.....",
|
||||
".#.#.#....#",
|
||||
".#........#",
|
||||
"#.##...#...",
|
||||
"#...##....#",
|
||||
".#..#...#.#",
|
||||
}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 7
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 336
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
77
internal/2020/DayTwo/code.go
Normal file
77
internal/2020/DayTwo/code.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package daytwo
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2020D2", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []string {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
lines := strings.Split(string(content), "\n")
|
||||
var data []string
|
||||
for _, line := range lines {
|
||||
data = append(data, line)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func PartOne(data []string) int {
|
||||
valid := 0
|
||||
for _, line := range data {
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
parts := strings.Split(line, ": ")
|
||||
policy := parts[0]
|
||||
password := parts[1]
|
||||
|
||||
policyParts := strings.Split(policy, " ")
|
||||
rangeStr := policyParts[0]
|
||||
letter := policyParts[1]
|
||||
|
||||
rangeParts := strings.Split(rangeStr, "-")
|
||||
min, _ := strconv.Atoi(rangeParts[0])
|
||||
max, _ := strconv.Atoi(rangeParts[1])
|
||||
|
||||
count := strings.Count(password, letter)
|
||||
if count >= min && count <= max {
|
||||
valid++
|
||||
}
|
||||
}
|
||||
return valid
|
||||
}
|
||||
|
||||
func PartTwo(data []string) int {
|
||||
valid := 0
|
||||
for _, line := range data {
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
parts := strings.Split(line, ": ")
|
||||
policy := parts[0]
|
||||
password := parts[1]
|
||||
|
||||
policyParts := strings.Split(policy, " ")
|
||||
rangeStr := policyParts[0]
|
||||
letter := policyParts[1]
|
||||
|
||||
rangeParts := strings.Split(rangeStr, "-")
|
||||
firstPosition, _ := strconv.Atoi(rangeParts[0])
|
||||
secondPosition, _ := strconv.Atoi(rangeParts[1])
|
||||
|
||||
atFirstPosition := len(password) >= firstPosition && password[firstPosition-1] == letter[0]
|
||||
atSecondPosition := len(password) >= secondPosition && password[secondPosition-1] == letter[0]
|
||||
|
||||
if atFirstPosition != atSecondPosition {
|
||||
valid++
|
||||
}
|
||||
}
|
||||
return valid
|
||||
}
|
||||
|
||||
26
internal/2020/DayTwo/code_test.go
Normal file
26
internal/2020/DayTwo/code_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package daytwo
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []string{
|
||||
"1-3 a: abcde",
|
||||
"1-3 b: cdefg",
|
||||
"2-9 c: ccccccccc",
|
||||
}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 2
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 1
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
43
internal/2021/DayOne/code.go
Normal file
43
internal/2021/DayOne/code.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package dayone
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2021D1", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []int {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
var data []int
|
||||
for line := range strings.SplitSeq(string(content), "\n") {
|
||||
num, _ := strconv.Atoi(line)
|
||||
data = append(data, num)
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func PartOne(data []int) int {
|
||||
count := 0
|
||||
for i := 1; i < len(data); i++ {
|
||||
if data[i] > data[i-1] {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func PartTwo(data []int) int {
|
||||
count := 0
|
||||
for i := 3; i < len(data); i++ {
|
||||
if data[i] > data[i-3] {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
22
internal/2021/DayOne/code_test.go
Normal file
22
internal/2021/DayOne/code_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package dayone
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []int{199, 200, 208, 210, 200, 207, 240, 269, 260, 263}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 7
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 5
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
117
internal/2021/DayThree/code.go
Normal file
117
internal/2021/DayThree/code.go
Normal file
@@ -0,0 +1,117 @@
|
||||
package daythree
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2021D3", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []string {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
return strings.Split(strings.TrimSpace(string(content)), "\n")
|
||||
}
|
||||
|
||||
func PartOne(data []string) int {
|
||||
bitlen := len(data[0])
|
||||
ones := make([]int, bitlen)
|
||||
|
||||
for _, line := range data {
|
||||
for i := range bitlen {
|
||||
if line[i] == '1' {
|
||||
ones[i]++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var gamma int
|
||||
total := len(data)
|
||||
for idx := range bitlen {
|
||||
gamma <<= 1
|
||||
if ones[idx] > total-ones[idx] {
|
||||
gamma |= 1
|
||||
}
|
||||
}
|
||||
|
||||
mask := (1 << bitlen) - 1
|
||||
epsilon := mask ^ gamma
|
||||
return gamma * epsilon
|
||||
}
|
||||
|
||||
func PartTwo(data []string) int {
|
||||
bitlen := len(data[0])
|
||||
|
||||
oxygenIndices := make([]int, len(data))
|
||||
for idx := range oxygenIndices {
|
||||
oxygenIndices[idx] = idx
|
||||
}
|
||||
|
||||
co2Indices := make([]int, len(data))
|
||||
for idx := range co2Indices {
|
||||
co2Indices[idx] = idx
|
||||
}
|
||||
|
||||
for indice := 0; indice < bitlen && len(oxygenIndices) > 1; indice++ {
|
||||
ones := 0
|
||||
for _, idx := range oxygenIndices {
|
||||
if data[idx][indice] == '1' {
|
||||
ones++
|
||||
}
|
||||
}
|
||||
target := byte('1')
|
||||
if ones*2 < len(oxygenIndices) {
|
||||
target = '0'
|
||||
}
|
||||
writeIdx := 0
|
||||
for readIdx := 0; readIdx < len(oxygenIndices); readIdx++ {
|
||||
if data[oxygenIndices[readIdx]][indice] == target {
|
||||
oxygenIndices[writeIdx] = oxygenIndices[readIdx]
|
||||
writeIdx++
|
||||
}
|
||||
}
|
||||
oxygenIndices = oxygenIndices[:writeIdx]
|
||||
}
|
||||
|
||||
for idx := 0; idx < bitlen && len(co2Indices) > 1; idx++ {
|
||||
ones := 0
|
||||
for _, indice := range co2Indices {
|
||||
if data[indice][idx] == '1' {
|
||||
ones++
|
||||
}
|
||||
}
|
||||
target := byte('0')
|
||||
if ones*2 < len(co2Indices) {
|
||||
target = '1'
|
||||
}
|
||||
writeIdx := 0
|
||||
for readIdx := 0; readIdx < len(co2Indices); readIdx++ {
|
||||
if data[co2Indices[readIdx]][idx] == target {
|
||||
co2Indices[writeIdx] = co2Indices[readIdx]
|
||||
writeIdx++
|
||||
}
|
||||
}
|
||||
co2Indices = co2Indices[:writeIdx]
|
||||
}
|
||||
|
||||
oxygenRating := 0
|
||||
for _, char := range data[oxygenIndices[0]] {
|
||||
oxygenRating <<= 1
|
||||
if char == '1' {
|
||||
oxygenRating |= 1
|
||||
}
|
||||
}
|
||||
|
||||
co2Rating := 0
|
||||
for _, char := range data[co2Indices[0]] {
|
||||
co2Rating <<= 1
|
||||
if char == '1' {
|
||||
co2Rating |= 1
|
||||
}
|
||||
}
|
||||
|
||||
return oxygenRating * co2Rating
|
||||
}
|
||||
|
||||
35
internal/2021/DayThree/code_test.go
Normal file
35
internal/2021/DayThree/code_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package daythree
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []string{
|
||||
"00100",
|
||||
"11110",
|
||||
"10110",
|
||||
"10111",
|
||||
"10101",
|
||||
"01111",
|
||||
"00111",
|
||||
"11100",
|
||||
"10000",
|
||||
"11001",
|
||||
"00010",
|
||||
"01010",
|
||||
}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 198
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 230
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
60
internal/2021/DayTwo/code.go
Normal file
60
internal/2021/DayTwo/code.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package daytwo
|
||||
|
||||
import (
|
||||
"advent-of-code/internal/registry"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registry.Register("2021D2", ParseInput, PartOne, PartTwo)
|
||||
}
|
||||
|
||||
func ParseInput(filepath string) []string {
|
||||
content, _ := os.ReadFile(filepath)
|
||||
return strings.Split(string(content), "\n")
|
||||
}
|
||||
|
||||
func PartOne(data []string) int {
|
||||
horizontal := 0
|
||||
depth := 0
|
||||
for _, line := range data {
|
||||
parts := strings.Split(line, " ")
|
||||
direction := parts[0]
|
||||
amount, _ := strconv.Atoi(parts[1])
|
||||
switch direction {
|
||||
case "forward":
|
||||
horizontal += amount
|
||||
case "down":
|
||||
depth += amount
|
||||
case "up":
|
||||
depth -= amount
|
||||
}
|
||||
}
|
||||
return horizontal * depth
|
||||
}
|
||||
|
||||
func PartTwo(data []string) int {
|
||||
horizontal := 0
|
||||
depth := 0
|
||||
aim := 0
|
||||
|
||||
for _, line := range data {
|
||||
parts := strings.Split(line, " ")
|
||||
direction := parts[0]
|
||||
amount, _ := strconv.Atoi(parts[1])
|
||||
|
||||
switch direction {
|
||||
case "forward":
|
||||
horizontal += amount
|
||||
depth += aim * amount
|
||||
case "down":
|
||||
aim += amount
|
||||
case "up":
|
||||
aim -= amount
|
||||
}
|
||||
}
|
||||
return horizontal * depth
|
||||
}
|
||||
|
||||
29
internal/2021/DayTwo/code_test.go
Normal file
29
internal/2021/DayTwo/code_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package daytwo
|
||||
|
||||
import "testing"
|
||||
|
||||
var testInput = []string{
|
||||
"forward 5",
|
||||
"down 5",
|
||||
"forward 8",
|
||||
"up 3",
|
||||
"down 8",
|
||||
"forward 2",
|
||||
}
|
||||
|
||||
func TestPartOne(t *testing.T) {
|
||||
expected := 150
|
||||
got := PartOne(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartOne() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPartTwo(t *testing.T) {
|
||||
expected := 900
|
||||
got := PartTwo(testInput)
|
||||
if got != expected {
|
||||
t.Errorf("PartTwo() = %d, want %d", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
881
internal/data/2020/DayFive/input.txt
Normal file
881
internal/data/2020/DayFive/input.txt
Normal file
@@ -0,0 +1,881 @@
|
||||
FFBBBFFLRL
|
||||
BFFBFBFRLR
|
||||
FFFBBFBRRR
|
||||
BFFBBBBRRL
|
||||
FFFBBFBLLR
|
||||
BBFBFBFLLR
|
||||
FBBFFBFLRL
|
||||
BFBFBBFLLL
|
||||
FBFBBFBLRR
|
||||
FFFBBBBRLR
|
||||
FFFFBFFRRL
|
||||
BFFFBFBLRL
|
||||
BBFFFBBRLL
|
||||
FFBFFFBLRL
|
||||
FBFBFFFRLL
|
||||
BFFBBBFRRL
|
||||
BFFFBBFRLR
|
||||
BBBFFFBRLL
|
||||
FBBBFFBRLL
|
||||
FFFBFFBRLL
|
||||
BBFBFBFLLL
|
||||
BFFBFFFLRL
|
||||
BBFBBFFLRL
|
||||
FBFBBBFRRR
|
||||
FBBBBFBRRL
|
||||
FBBFFFFLRL
|
||||
FFFBBFBLRL
|
||||
BFFFFFFLLR
|
||||
FFBFFBBRRR
|
||||
FFFFBBBRLR
|
||||
FFFBFFFLRR
|
||||
FBBFBBFLLL
|
||||
FBBFBBBRLR
|
||||
BFFBFFFLLR
|
||||
FFBFBFFRLL
|
||||
FFFFBBFLRR
|
||||
BBFBBBFLRR
|
||||
BFBFBBBRLR
|
||||
BFFBBFFLRL
|
||||
BFFBFFFLLL
|
||||
FBFFFBFLRR
|
||||
FFFBBBFRLR
|
||||
FBBFBBFRLL
|
||||
BBFFFBBLLL
|
||||
BBFFFFFLLL
|
||||
FBFFBBBLLL
|
||||
FBFFFBFLRL
|
||||
FFBFBBFLLL
|
||||
BFFBBFBLLR
|
||||
BFBBBFFRRR
|
||||
BFBBBBBLLR
|
||||
FBFFFFFRLR
|
||||
BBFFBFFLLR
|
||||
FFBFBFFLLR
|
||||
BBFBBBFRRL
|
||||
FFFBFFFRLR
|
||||
FBFBFFFLRL
|
||||
BBFFFFBLLL
|
||||
FFBBFFFLRL
|
||||
BBFFBFBRRR
|
||||
FBBFBBBLLR
|
||||
BFFFBFBRRR
|
||||
BBFFFFFLRL
|
||||
FBFBBFBRRR
|
||||
FFFBBBBLRR
|
||||
FBBFBFFLLR
|
||||
BBFBFFFRLR
|
||||
BBFFFFBRLR
|
||||
FBFBFFBRLR
|
||||
FFFBBFFLLR
|
||||
FBBFFFFLRR
|
||||
BBFFBBBLLR
|
||||
BBFFFFBRRL
|
||||
BFBBBBBRRL
|
||||
FBBBFFBRLR
|
||||
FFBBBFBRLR
|
||||
BFBBBBBRLR
|
||||
FBFBBBFRLR
|
||||
BBFBBFBRRR
|
||||
FFBFFBBLRR
|
||||
FFBBBBFLLR
|
||||
BFFFBBBLRL
|
||||
FBBFBFFLRL
|
||||
FBFFBFFRRL
|
||||
FBBBFFFRRR
|
||||
FFBBFBFRLL
|
||||
FBBFBBBLLL
|
||||
FFFFBFFRLR
|
||||
BBFBBBFRLR
|
||||
FBFBBBBLRL
|
||||
FFFFBBBLRL
|
||||
BFFBBFBRRL
|
||||
BBFFFBFRLR
|
||||
FBFFBFFRRR
|
||||
BBFBBFBRLL
|
||||
FBBFBFFRRR
|
||||
BFFFBFBLRR
|
||||
FFFBBFBLRR
|
||||
FFBFBFFRRL
|
||||
FFBBBBBRLR
|
||||
FBBBBBBLLR
|
||||
BBFBFBBRRL
|
||||
FBBFFFFRLR
|
||||
BFBBBBFRRL
|
||||
FBBFFBFLRR
|
||||
FFFBBBBLRL
|
||||
BBFFBBFLRR
|
||||
BFBFFBBRLL
|
||||
FFBBBBBLRR
|
||||
BBBFFFFRRR
|
||||
BFFFFBFRRR
|
||||
FBFFFFBLRR
|
||||
FBBBBBFLRR
|
||||
FFBBBBFRRR
|
||||
FFBFBFFLLL
|
||||
FBFBFFFLLR
|
||||
BFBBBBFLLL
|
||||
FBBFBBFRLR
|
||||
FFFBFBFLLL
|
||||
FBBFBBFLLR
|
||||
FBFFFFFRRL
|
||||
BFFBBBBRLL
|
||||
BFFBFFBLRR
|
||||
FBBFFFBLLR
|
||||
FBBFBFBLLL
|
||||
BFFFBFBRLR
|
||||
FBFBFBBRLR
|
||||
FBFFFBFRRR
|
||||
BFFBBFFRRR
|
||||
BFBFFFBRRL
|
||||
BFFBFBBRRL
|
||||
BBFFBFBRRL
|
||||
FBBBBFBRRR
|
||||
FFFBBBBRRL
|
||||
BFFFFBFLLL
|
||||
FBBBFBFLLR
|
||||
BBFFBFFRLR
|
||||
FBBFBFFRLR
|
||||
BFFFBFFLRR
|
||||
FBBFFBFLLL
|
||||
FFBBFFBRRR
|
||||
FFBFFFBLRR
|
||||
FFBFBBBRLR
|
||||
BBFBBFFLLR
|
||||
BBFFFBFLRR
|
||||
FFFBBBFLRR
|
||||
FBFFFBFLLR
|
||||
BBFBFBFLRL
|
||||
BFBFBBBLRR
|
||||
BFFBBFFRLR
|
||||
FBFBBBBRLL
|
||||
BBFFBBBLRL
|
||||
BBFFFBFLLR
|
||||
BBFFBFFRLL
|
||||
FFFFBFBRRR
|
||||
BFBFFBBLRR
|
||||
BFBBBBBRLL
|
||||
FBBFFFFRRR
|
||||
BFFFBBBRRL
|
||||
BFFBFBFLRL
|
||||
FFFFBFFRLL
|
||||
FBFFFFBRRL
|
||||
BBBFFFBRRL
|
||||
BFBBFFFLLL
|
||||
FFFFBBBRRL
|
||||
FBFFBBBRLR
|
||||
FFBFFFFRLL
|
||||
BFFBBBBRRR
|
||||
BBFFBBFRRL
|
||||
BFBBBFBLLL
|
||||
FBBBFBBLLL
|
||||
FBFBFFFLLL
|
||||
BFBFFFFRLR
|
||||
FFBFFBFLLR
|
||||
BFFBFBBRLL
|
||||
BFBBBFFLLL
|
||||
FBBFBFFRLL
|
||||
FFBFBBFLLR
|
||||
FBFBFBBRRL
|
||||
BFBFBFFLRL
|
||||
FFBFFFFRRL
|
||||
BFFBFFFRLR
|
||||
BFFFBBBLRR
|
||||
BBFBFBBLLR
|
||||
BFFBFBFLLR
|
||||
BFBBFBFRRR
|
||||
FBFBFFBLRR
|
||||
BBFBBBBRRL
|
||||
BFFFBFFLLR
|
||||
FFFFBBFRRL
|
||||
FFFBFFBRRL
|
||||
FBFFFBBRRR
|
||||
BFBBBBFLLR
|
||||
BBFBFBFRRL
|
||||
FFFBBFFLRL
|
||||
BBBFFFFLRL
|
||||
FFFBFFFRRL
|
||||
FBFBFFFLRR
|
||||
FFBFBBFLRL
|
||||
BBFBFBFRLR
|
||||
BBFBBFFRLR
|
||||
FBBFBFBRRR
|
||||
FBFFFBBRLR
|
||||
BBFFBBBRLL
|
||||
BFFBFFBLLR
|
||||
FBBBFBBLRL
|
||||
FFFBFFFRRR
|
||||
BFBBBFFLLR
|
||||
FBBFFFFLLL
|
||||
BFBBFBFRRL
|
||||
FBBFFBBRRR
|
||||
BFBFFFBLRL
|
||||
BBBFFBFLLL
|
||||
FFBFFBFRRL
|
||||
FBFFBFBRRL
|
||||
BFFFFBFRLL
|
||||
FFBFFFBRLL
|
||||
FFBBFFBLLL
|
||||
BFFBBFFLLL
|
||||
FBFFFFBLRL
|
||||
BFBFFBFLLR
|
||||
FFFFBBBLRR
|
||||
BFFBFBBRLR
|
||||
FBBBFFFRRL
|
||||
BBFBFBBLLL
|
||||
FFBBBFBRRL
|
||||
BBFBFFBLRR
|
||||
FBFBFFBLRL
|
||||
BBFBBFBLRL
|
||||
BFBBFFBRRL
|
||||
FFBBBFBLLL
|
||||
FFBFBBFRLL
|
||||
BFFFFBBLLL
|
||||
FBBBFBBLRR
|
||||
FBFBBFBLLL
|
||||
FFBBBBFRRL
|
||||
BBFBBBBLLL
|
||||
FBFBBBBLLR
|
||||
BFFFBFBLLR
|
||||
FBBBFFFRLR
|
||||
FFBBBFBRRR
|
||||
BBFFFFBLLR
|
||||
BBFFBBBLLL
|
||||
BBFFBBFLRL
|
||||
BBBFFFBLRR
|
||||
BBBFFFFRLL
|
||||
BFBFFFFRRR
|
||||
BFFFBFBRRL
|
||||
FBBBBBBLRL
|
||||
FFBFBBBRRL
|
||||
FFBFBFFLRL
|
||||
FFBBFFFLLL
|
||||
BBFFBFBLLR
|
||||
BFBBBFBRLL
|
||||
FFBBBFBRLL
|
||||
FBFBBFBRRL
|
||||
FBFFBFFLLR
|
||||
BBBFFFBRRR
|
||||
BBFBBBBLRR
|
||||
BBFFBBBRLR
|
||||
FBBBBFFRRR
|
||||
BFFFFBBLRR
|
||||
FFBFFBBRRL
|
||||
FBFBBBFRLL
|
||||
BBFBFBBLRL
|
||||
BFBBFBBRRR
|
||||
BFBBFBBRLR
|
||||
FFFBFBBLLR
|
||||
FFFBFFFLLR
|
||||
BFFFBBFLRL
|
||||
FBFBBFFLRL
|
||||
BFBFBBBRRL
|
||||
BBFBFBBRRR
|
||||
BBFFBFBRLR
|
||||
BFBFBFBRLL
|
||||
FBBFBFBLRL
|
||||
FFBBFBBRRL
|
||||
FFBFFFBLLL
|
||||
FBBBFFBRRL
|
||||
BFBBFFBLRL
|
||||
FFFBBBBRLL
|
||||
FBFBFBFLRR
|
||||
FFFBFBFLRL
|
||||
BFBBBBBLRR
|
||||
BBFFBFFLLL
|
||||
FFFFBFFLRR
|
||||
FFBBFFBRLR
|
||||
FBBBFFBLRR
|
||||
FBBBBFBLRL
|
||||
FBFFBBFRLR
|
||||
FFBFBFFRRR
|
||||
FBFFFBFRLL
|
||||
FFFBFBFRRR
|
||||
BFFFBFFRRL
|
||||
FFFBFBFLRR
|
||||
BBFFBFFLRL
|
||||
BBBFFBFLLR
|
||||
FFFBFFBLRL
|
||||
BFBBBBFRRR
|
||||
BFFBFFFLRR
|
||||
FBFFFFBRRR
|
||||
BFFBFFFRLL
|
||||
FBFFBFFRLL
|
||||
FFFBBBBLLR
|
||||
FFFBBBFLLR
|
||||
BFBBBFFLRR
|
||||
BBBFFFFRRL
|
||||
FFFBBFFRRR
|
||||
BBFFBBBLRR
|
||||
FFBFFFBRRR
|
||||
BFFBFFFRRL
|
||||
BFFBFBFRRL
|
||||
BBFFFBFLLL
|
||||
FBFBFFBRRL
|
||||
BFBFFFBLLR
|
||||
FFBBBBBLRL
|
||||
FBFBBBBRRL
|
||||
BFFBBFBLRL
|
||||
FBBFBBFLRL
|
||||
FFBFFFBRLR
|
||||
FBFFFBFRRL
|
||||
FFFFBBFRLL
|
||||
BFBBFBFLRL
|
||||
FFFBFFBLLR
|
||||
FBBFBFBRRL
|
||||
FFBFFFBLLR
|
||||
FFBBBBFLLL
|
||||
BFBBBBFLRR
|
||||
FBFFFBFLLL
|
||||
BBFBFFBRRL
|
||||
FBBBFBBRRR
|
||||
FFFBBBBLLL
|
||||
FBBBBBFRRL
|
||||
BFBBBBFRLR
|
||||
BFFBBBFRLL
|
||||
FBFFFFFLRR
|
||||
BFBBBBFLRL
|
||||
FBFBFBBRLL
|
||||
BFFBBBBLRR
|
||||
BFFFFFFLLL
|
||||
BBBFFFFLLL
|
||||
BFBFFFFRLL
|
||||
FBBFBFFLLL
|
||||
BFBFFBBRLR
|
||||
BBFBFFFRRL
|
||||
FBFBFFBRLL
|
||||
FBFBBFBLLR
|
||||
FBFFBFBRLR
|
||||
FBBFFBBRLR
|
||||
FBBFBBFRRL
|
||||
FFBBFFBRLL
|
||||
FBFFBFFLLL
|
||||
BBFBBFFRLL
|
||||
BFFFFBFRRL
|
||||
FBFBFBFRLL
|
||||
FFFBBFBRRL
|
||||
BFFFBBFRRR
|
||||
BFFBBBFLRR
|
||||
FBBFFBFRLL
|
||||
BBFBFBBLRR
|
||||
BBFBBFBRLR
|
||||
BFBFBBFRRL
|
||||
FBBBFFFLRL
|
||||
FBFBFFBRRR
|
||||
BFBFBBFRRR
|
||||
FFBBFBBLRL
|
||||
BFFBFFBRLR
|
||||
BFFFFFBRRR
|
||||
BBFFBBFRRR
|
||||
BBFFBBFRLL
|
||||
FFBFFBFRLR
|
||||
BBFBBBBRLR
|
||||
BBFFBBBRRL
|
||||
BFFFBFFLRL
|
||||
BFBBFBFRLR
|
||||
FFBBBBBLLL
|
||||
FBBBBFFRLR
|
||||
BFBFFFBLRR
|
||||
BFBFFFFRRL
|
||||
BFFBBBBLLL
|
||||
BFBBFFFRLL
|
||||
FFFBBBFLLL
|
||||
BFFBBFBLLL
|
||||
BFFFBBFRRL
|
||||
FBBBFBBRRL
|
||||
BFFFBBFLLL
|
||||
BBBFFFFLLR
|
||||
BFBBFFFLRL
|
||||
BFFBBBBLLR
|
||||
FBBFFFBRRR
|
||||
BFBFFFFLLR
|
||||
FBFFBFBLLR
|
||||
FFBBFFBLLR
|
||||
FBFBBBFLLL
|
||||
BBFFFBBRLR
|
||||
BFBFBFFLLL
|
||||
FBFFFBBLRL
|
||||
BFFFBFFRLL
|
||||
FBBFFFBRRL
|
||||
BFFFFBBRLL
|
||||
BFBFBBBLLL
|
||||
BFBFBFBLLL
|
||||
FFFBBFBLLL
|
||||
BBBFFFBLRL
|
||||
BFBBFBBLLR
|
||||
BFBFBFFRRR
|
||||
BBFFFFBLRR
|
||||
BFFFBBBRRR
|
||||
FBFFFFFRLL
|
||||
FFBFFFFRRR
|
||||
BFBBFFFRRL
|
||||
BFFFBBBRLL
|
||||
FFBBFBBRRR
|
||||
FFBFBFBRRL
|
||||
FFBFBBFRLR
|
||||
BFBFFBBLRL
|
||||
FBBBBBFLLR
|
||||
BFBFFBBRRL
|
||||
FFBFFFFLLL
|
||||
FFFBBFBRLL
|
||||
FBFBBFFLLR
|
||||
BFBBFFBRLL
|
||||
FFBBFBBLLL
|
||||
FBBBFBFLRR
|
||||
FFBBFBBLLR
|
||||
FFBFFFFLLR
|
||||
BFBBFBBLLL
|
||||
BBFFBBFLLL
|
||||
FFBBFFFRRL
|
||||
FBFBBBBLLL
|
||||
FBBBBBFLLL
|
||||
FBBBBFBRLR
|
||||
BBBFFFFLRR
|
||||
FBFBFBFLLL
|
||||
BFBBFFFLRR
|
||||
FFBBFBBRLL
|
||||
FBBBBFBRLL
|
||||
FBFBBFFLRR
|
||||
FBBBBBFRLR
|
||||
BFBFBBFLRL
|
||||
BFBFBFFLRR
|
||||
FBFBFBFRRR
|
||||
BFBFFFBRRR
|
||||
FBBFFFFLLR
|
||||
BFBFBFBLLR
|
||||
BFFFFFFLRL
|
||||
FFFBBBFRRL
|
||||
BFFFBFFLLL
|
||||
FFBFBBBRRR
|
||||
BBFFFFBRLL
|
||||
FBBBFBFLRL
|
||||
BFBBBFBLRR
|
||||
BBFFFBBRRR
|
||||
FBFFBBFRLL
|
||||
BFBBFBBLRL
|
||||
FBBFBBBRLL
|
||||
BBFBBBFLLR
|
||||
FFBFFFBRRL
|
||||
BBBFFFBLLR
|
||||
FFFFBBBLLL
|
||||
BFFFBFBLLL
|
||||
BFFBFBBLRL
|
||||
FBBFFFBRLR
|
||||
BFBFFBFRRR
|
||||
FBBBFBBRLL
|
||||
FBBBBBFRRR
|
||||
FBFFFFBRLR
|
||||
BFFBBBFRLR
|
||||
BFBBFBFLLR
|
||||
BFBFBFFRLR
|
||||
FBFFBFBRRR
|
||||
FBFFFBBLLL
|
||||
BFBFBFBRRL
|
||||
FFFFBFBRLL
|
||||
FFFBBFFRLR
|
||||
FFFFBFBLRL
|
||||
FFFBFFBLLL
|
||||
FBFFBFFRLR
|
||||
FBBBFFFLRR
|
||||
FBFBFFFRLR
|
||||
FFBFBBFLRR
|
||||
FFFBFBBLRL
|
||||
BBFFBFBLRR
|
||||
BFBFFBFLRR
|
||||
FBBFFFFRRL
|
||||
FBFBBFBRLL
|
||||
FBBBBFFLRR
|
||||
FBFFFFFLRL
|
||||
BFBBBFFRRL
|
||||
FBFFBBBLLR
|
||||
BBFFFBFRRL
|
||||
FBBFFBBLRL
|
||||
BBFFFFFLRR
|
||||
FBBFFBBRLL
|
||||
FBBFFBFRRL
|
||||
FFBFFBFRRR
|
||||
FBBBBFFRRL
|
||||
BFBFBBBLLR
|
||||
FBFFFFFRRR
|
||||
FFBBFBFRRL
|
||||
BFBBBFBRLR
|
||||
FFBBFFBRRL
|
||||
BBFFBBFRLR
|
||||
FFBFBBBLRR
|
||||
FFFBFFFLRL
|
||||
BBFBBFBLLR
|
||||
FBBBFBBLLR
|
||||
BFBBFBFRLL
|
||||
BBFBFFBRRR
|
||||
FFBFFBBLRL
|
||||
BFBFBBBRRR
|
||||
FBBBFBFRRR
|
||||
FFBBFFFRLR
|
||||
BBFBFFBRLR
|
||||
FFBFBBBLLR
|
||||
BBFBFFFLRR
|
||||
BBFFFBBLLR
|
||||
BFFFFBBLLR
|
||||
BFFBBFBRRR
|
||||
BFFBBBFLRL
|
||||
BFBBFFBLLL
|
||||
FFFFBFFRRR
|
||||
FFFBFFBLRR
|
||||
BFFBFFBLRL
|
||||
BFBBBBBLLL
|
||||
FFBFFBFLLL
|
||||
BFBFBFBRRR
|
||||
BFFFFFBLRR
|
||||
BFFFBBFLRR
|
||||
BBFFFFFLLR
|
||||
FFFBFBBRRL
|
||||
FBFFBBFRRL
|
||||
BBFBBBFLLL
|
||||
BBFFFFBLRL
|
||||
BFFFFFFLRR
|
||||
FBBBBBBLRR
|
||||
BFFBBBFLLR
|
||||
FFBFBBFRRR
|
||||
BFBFBFBLRL
|
||||
FBFFBFFLRL
|
||||
FBBBBBBRLL
|
||||
FFBBBFFLLL
|
||||
BFBFFFBLLL
|
||||
FBBFFBBLLL
|
||||
BBFFBFFLRR
|
||||
FBBBBBBRLR
|
||||
FBFFBBFLRL
|
||||
FBBBBFFLLR
|
||||
BFBFFFBRLR
|
||||
FFFBFBBRRR
|
||||
FFBBFBFLRL
|
||||
BBFFBFFRRR
|
||||
FBBFBFBLRR
|
||||
BFBFBFBLRR
|
||||
FBFBBFFLLL
|
||||
FBFBBFFRLR
|
||||
FBFFBBBRLL
|
||||
FBBFBFBRLL
|
||||
BFFFFFFRLL
|
||||
FBBBBBBLLL
|
||||
BFFBBFFRRL
|
||||
FFBFBFBLLR
|
||||
BFFFFFBRLR
|
||||
FBFFFBBRRL
|
||||
BFBFFBFRLR
|
||||
BFFBFFFRRR
|
||||
FFBFBBBLLL
|
||||
BFBFFBFLLL
|
||||
BFFFFBFLLR
|
||||
FFBFBFBRLR
|
||||
BBFBBBBRRR
|
||||
BBFFFBFRRR
|
||||
BFFFFFBRRL
|
||||
FBFFBBFLLL
|
||||
FBFFFBBLLR
|
||||
BBFBFBFLRR
|
||||
BFBFBFFRLL
|
||||
FBFFFFFLLL
|
||||
BFBBFBFLLL
|
||||
FFBFBFFLRR
|
||||
FBBFFFBLRR
|
||||
FBBBFFBLRL
|
||||
BFFFFBBRRR
|
||||
FBFBBFFRLL
|
||||
FFBFFBBRLR
|
||||
FBFFFBBLRR
|
||||
BFBBFFFLLR
|
||||
BFBFBFBRLR
|
||||
BFBFFBBRRR
|
||||
FFBBBFFRLR
|
||||
FFBFBBBLRL
|
||||
FFBFBFBRLL
|
||||
FFBBFBFRLR
|
||||
FBFFBFBLRR
|
||||
BFBBBFBRRL
|
||||
FBBFFFBLLL
|
||||
FBFBBBFLRL
|
||||
FBFBBBFLRR
|
||||
BBFBBBBLLR
|
||||
BFFBBBFLLL
|
||||
FFFFBBBRRR
|
||||
FFBBFFFRLL
|
||||
FFBBBFBLRR
|
||||
FFFBFBBRLL
|
||||
BBFFFFFRRR
|
||||
FFBBBFBLLR
|
||||
FFFBBFFLLL
|
||||
FFFFBFFLRL
|
||||
FFFFBBFRLR
|
||||
BFBFBBFRLL
|
||||
FFBFBFBLRR
|
||||
FBBFFBBLLR
|
||||
BBFBBBBRLL
|
||||
FFFBFBFRRL
|
||||
FBBFBFBRLR
|
||||
FBBFBBBLRR
|
||||
BFFBBBBLRL
|
||||
FFFBBFFLRR
|
||||
BFFFFBFRLR
|
||||
FFBBBFFRLL
|
||||
BFBFFFBRLL
|
||||
BFBBFBFLRR
|
||||
FFFFBBFRRR
|
||||
FBFBBBBRLR
|
||||
FBBBBBBRRL
|
||||
BBFFBFBLLL
|
||||
FBBFFBFLLR
|
||||
BFBBBFFLRL
|
||||
BBFBFFFLLR
|
||||
BBFFBBBRRR
|
||||
BFFBFBFRRR
|
||||
FFBBBBBLLR
|
||||
BBFBBBFRRR
|
||||
FBBFBFFRRL
|
||||
FBFFFBFRLR
|
||||
BFFFBBBLLL
|
||||
FBBFFBBRRL
|
||||
FBBBBBFLRL
|
||||
BBFBFFFLRL
|
||||
FFFBFFFRLL
|
||||
FFBFFBFRLL
|
||||
BFFFBFFRRR
|
||||
BFBBFFFRLR
|
||||
BBBFFFFRLR
|
||||
FBBBBFBLRR
|
||||
BBFBFFBRLL
|
||||
FBFFBBFLRR
|
||||
BFFFBFFRLR
|
||||
BFBFBBFRLR
|
||||
BFFFBBBLLR
|
||||
FBFBBFBRLR
|
||||
FFBBBBFRLR
|
||||
FBBBBFFRLL
|
||||
BBFBFFBLRL
|
||||
BFBFFBBLLL
|
||||
FFBBFFBLRR
|
||||
FBBBFFBLLL
|
||||
BFFBFFBRRL
|
||||
FBFFBBBRRL
|
||||
FFBFBBFRRL
|
||||
FBBFFBFRRR
|
||||
FBBBBBFRLL
|
||||
BBFBFBFRRR
|
||||
FFFBBFFRRL
|
||||
BFFFBBFRLL
|
||||
FBFFBFBLRL
|
||||
BFBBBFBLRL
|
||||
FFFBBBFLRL
|
||||
FFBBFBFLLL
|
||||
BBFBFFBLLR
|
||||
BFFFFFFRRL
|
||||
BFFBFBBLRR
|
||||
BFBFBBFLLR
|
||||
FFBBBFFLLR
|
||||
FBBFFBFRLR
|
||||
FFFBBFBRLR
|
||||
FBFFBFBLLL
|
||||
FBBBBFBLLR
|
||||
FFBBBFBLRL
|
||||
BFFFFFBLLR
|
||||
FBFFFFFLLR
|
||||
FFFBFBBLLL
|
||||
FFBBFFFLRR
|
||||
BFFBFBFRLL
|
||||
FBFBFBFLLR
|
||||
FBFBFBBLLL
|
||||
FBBFBFBLLR
|
||||
BBFFFFFRRL
|
||||
FBFFBFBRLL
|
||||
FBBBFFFRLL
|
||||
FBFBFBFRRL
|
||||
BFFFFBBLRL
|
||||
BBFBBFBLLL
|
||||
BBFBBBBLRL
|
||||
FBBBFBFRRL
|
||||
FFFFBBFLLR
|
||||
BFBFFFFLRL
|
||||
BBFFFFBRRR
|
||||
FFFFBBFLRL
|
||||
BBFFFBFRLL
|
||||
BFFFFBFLRL
|
||||
BFFBFFBRRR
|
||||
FBFBFFFRRR
|
||||
FBFFBBBLRL
|
||||
FFFBFBFRLR
|
||||
FBBFFFFRLL
|
||||
BBFBBFFRRR
|
||||
FFBFFBBLLL
|
||||
FFBFFFFLRL
|
||||
BBFBBFFLRR
|
||||
FBFBFFBLLR
|
||||
FFBBFFFRRR
|
||||
BBFBFFBLLL
|
||||
FFFBFFFLLL
|
||||
BFBFFBFRRL
|
||||
FBBBFFFLLR
|
||||
FBFBBBBLRR
|
||||
FBFFBFFLRR
|
||||
BBFFFFFRLR
|
||||
FBBBFFBRRR
|
||||
FFFBFFBRRR
|
||||
FBFBFBBLLR
|
||||
BFBBFFBRRR
|
||||
BFFFFBBRLR
|
||||
FBBFFBBLRR
|
||||
BFFBFFBRLL
|
||||
FFBBBFFRRR
|
||||
BFFBFBBLLR
|
||||
FBFBBFFRRL
|
||||
FBFBFFBLLL
|
||||
BFFFFFBLLL
|
||||
BBFBBBFRLL
|
||||
BFBBBBBRRR
|
||||
BFFBBFBLRR
|
||||
FFFFBBBLLR
|
||||
BFFBFBBRRR
|
||||
FBFFFFBLLL
|
||||
FFBFBFBLRL
|
||||
BFBFFFFLRR
|
||||
BFBBFFBLRR
|
||||
FFFBBBFRRR
|
||||
FBBBBBBRRR
|
||||
BFBFFBBLLR
|
||||
FBBBFBFLLL
|
||||
FBFFBBFRRR
|
||||
FBBFBBBRRR
|
||||
FFBFBBBRLL
|
||||
BFBBBBBLRL
|
||||
BFFBBFBRLR
|
||||
FBFBBFBLRL
|
||||
FBBFBFFLRR
|
||||
BFFFFFBLRL
|
||||
FFBBFFBLRL
|
||||
FFFFBFFLLR
|
||||
FBFBFBBRRR
|
||||
FFBBFBFLLR
|
||||
BFFBFFBLLL
|
||||
FFFBFBBRLR
|
||||
BFBFBBBLRL
|
||||
BFBFFFFLLL
|
||||
FFBBFBFRRR
|
||||
FBFBBBBRRR
|
||||
FBBBFFBLLR
|
||||
BBFBFFFLLL
|
||||
FBFBFBFRLR
|
||||
FBFBFBBLRL
|
||||
BFBBFFBLLR
|
||||
FFBBBBBRRR
|
||||
FFFFBFFLLL
|
||||
BBFBFBBRLR
|
||||
BFFBFBBLLL
|
||||
BBFFBFBRLL
|
||||
BFBBFBBRRL
|
||||
BBBFFFBLLL
|
||||
BBFFBFFRRL
|
||||
FFFFBBBRLL
|
||||
BFFFFFBRLL
|
||||
BBFBFFFRRR
|
||||
FFBFFBBRLL
|
||||
BFFBBBBRLR
|
||||
FFBBBBFRLL
|
||||
FBBBBFBLLL
|
||||
BFFFFBBRRL
|
||||
BBFBBBFLRL
|
||||
FBBFBBBRRL
|
||||
FFFBBFFRLL
|
||||
FFBBBFFLRR
|
||||
FFBFFBFLRL
|
||||
FFFBFFBRLR
|
||||
FBFFFFBRLL
|
||||
FBFFBBBLRR
|
||||
FFFFBFBRLR
|
||||
FBFBFBBLRR
|
||||
BFBBFFFRRR
|
||||
FBFBFBFLRL
|
||||
FBBBFBBRLR
|
||||
FFBBBFFRRL
|
||||
FBFFFBBRLL
|
||||
BBFFBFBLRL
|
||||
BBFFFBBLRR
|
||||
BFFBBBFRRR
|
||||
BBFBFFFRLL
|
||||
FFBBBBFLRR
|
||||
FBFFBBFLLR
|
||||
BFFFFBFLRR
|
||||
FBFBBBFLLR
|
||||
FFFBFBFLLR
|
||||
FFBBFBBRLR
|
||||
BBFBBFFRRL
|
||||
BBFFBBFLLR
|
||||
FFBFFBFLRR
|
||||
FBFFBBBRRR
|
||||
BFBFBBBRLL
|
||||
FFBBFBFLRR
|
||||
BFFBBFFRLL
|
||||
BFFFFFFRLR
|
||||
BBBFFFBRLR
|
||||
BFBBBFBLLR
|
||||
FBFFFFBLLR
|
||||
FFFFBFBLRR
|
||||
FBBBFBFRLL
|
||||
FFBFBFBRRR
|
||||
BBFFFBFLRL
|
||||
FFBFFFFLRR
|
||||
BBFBFBBRLL
|
||||
BBFBFBFRLL
|
||||
FBBBBFFLRL
|
||||
BFFFBFBRLL
|
||||
FFFFBFBLLR
|
||||
FBBFFFBLRL
|
||||
FBBBBFFLLL
|
||||
BFBBFBBLRR
|
||||
FBFBFFFRRL
|
||||
FBBBFFFLLL
|
||||
FBBBFBFRLR
|
||||
BBFBBFBLRR
|
||||
FBBFBBFRRR
|
||||
FFBBBBBRRL
|
||||
FFFBBBFRLL
|
||||
BFFBBFFLLR
|
||||
BFBBBFFRLL
|
||||
BBFFFBBRRL
|
||||
BFBBFBBRLL
|
||||
BFBFBFFRRL
|
||||
BFFBFBFLRR
|
||||
FFBFBFBLLL
|
||||
BBFFFBBLRL
|
||||
BFBFBBFLRR
|
||||
BBFBBFFLLL
|
||||
BFFFFFFRRR
|
||||
BFBBBBFRLL
|
||||
FBBFBBFLRR
|
||||
BFBFFBFRLL
|
||||
FFBBFBBLRR
|
||||
BFFBBFBRLL
|
||||
BFBFFBFLRL
|
||||
FFFBFBBLRR
|
||||
BFBBBFBRRR
|
||||
FFFFBFBLLL
|
||||
FFBFBFFRLR
|
||||
FFFFBBFLLL
|
||||
FBFBBFFRRR
|
||||
BBFFFFFRLL
|
||||
BFBFBFFLLR
|
||||
FFBBFFFLLR
|
||||
FFBFFFFRLR
|
||||
BFBBBFFRLR
|
||||
BFFBBFFLRR
|
||||
FBBFFFBRLL
|
||||
FFBBBBBRLL
|
||||
FFBFFBBLLR
|
||||
FFFFBFBRRL
|
||||
BFFBFBFLLL
|
||||
FBBFBBBLRL
|
||||
BBFBBFBRRL
|
||||
FFBBBBFLRL
|
||||
BFFFBBFLLR
|
||||
FFFBFBFRLL
|
||||
FFFBBBBRRR
|
||||
FBFBBBFRRL
|
||||
BFFFBBBRLR
|
||||
1133
internal/data/2020/DayFour/input.txt
Normal file
1133
internal/data/2020/DayFour/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
200
internal/data/2020/DayOne/input.txt
Normal file
200
internal/data/2020/DayOne/input.txt
Normal file
@@ -0,0 +1,200 @@
|
||||
2004
|
||||
1671
|
||||
1678
|
||||
1304
|
||||
1242
|
||||
1882
|
||||
1605
|
||||
1034
|
||||
1883
|
||||
1589
|
||||
1881
|
||||
1546
|
||||
1713
|
||||
1218
|
||||
1982
|
||||
1395
|
||||
1277
|
||||
1417
|
||||
1497
|
||||
1499
|
||||
1847
|
||||
1989
|
||||
1172
|
||||
1684
|
||||
1243
|
||||
1843
|
||||
1661
|
||||
1662
|
||||
1421
|
||||
1790
|
||||
1344
|
||||
1458
|
||||
1074
|
||||
1809
|
||||
1990
|
||||
1369
|
||||
1386
|
||||
1736
|
||||
1972
|
||||
1634
|
||||
1229
|
||||
1123
|
||||
1870
|
||||
1595
|
||||
1934
|
||||
1399
|
||||
1732
|
||||
1545
|
||||
1208
|
||||
368
|
||||
1907
|
||||
1143
|
||||
443
|
||||
1929
|
||||
1965
|
||||
1872
|
||||
1738
|
||||
1967
|
||||
997
|
||||
1473
|
||||
1041
|
||||
1991
|
||||
1868
|
||||
1180
|
||||
1409
|
||||
1379
|
||||
1568
|
||||
1163
|
||||
1869
|
||||
1391
|
||||
1956
|
||||
1249
|
||||
1505
|
||||
351
|
||||
2001
|
||||
462
|
||||
1219
|
||||
1731
|
||||
1802
|
||||
1798
|
||||
1626
|
||||
1438
|
||||
1099
|
||||
1477
|
||||
1980
|
||||
1708
|
||||
1666
|
||||
1066
|
||||
1121
|
||||
1359
|
||||
1426
|
||||
1734
|
||||
1768
|
||||
1836
|
||||
1453
|
||||
923
|
||||
1660
|
||||
1878
|
||||
1522
|
||||
1024
|
||||
1429
|
||||
232
|
||||
1952
|
||||
1730
|
||||
1763
|
||||
1981
|
||||
1388
|
||||
1337
|
||||
1317
|
||||
1922
|
||||
1044
|
||||
1999
|
||||
1341
|
||||
1178
|
||||
1524
|
||||
1185
|
||||
1257
|
||||
1256
|
||||
1061
|
||||
1262
|
||||
1022
|
||||
1778
|
||||
1917
|
||||
1205
|
||||
1272
|
||||
1842
|
||||
1533
|
||||
1194
|
||||
1746
|
||||
1691
|
||||
1617
|
||||
1667
|
||||
1940
|
||||
1171
|
||||
1792
|
||||
1773
|
||||
1411
|
||||
1902
|
||||
1859
|
||||
1978
|
||||
1764
|
||||
1482
|
||||
1276
|
||||
735
|
||||
1716
|
||||
1915
|
||||
1675
|
||||
1126
|
||||
1830
|
||||
1227
|
||||
1299
|
||||
1535
|
||||
1700
|
||||
1658
|
||||
1771
|
||||
1823
|
||||
1055
|
||||
1602
|
||||
1590
|
||||
1983
|
||||
1885
|
||||
1735
|
||||
103
|
||||
1766
|
||||
14
|
||||
1486
|
||||
1939
|
||||
1525
|
||||
1916
|
||||
1279
|
||||
544
|
||||
1406
|
||||
1674
|
||||
1948
|
||||
1971
|
||||
1651
|
||||
1715
|
||||
1943
|
||||
1784
|
||||
2008
|
||||
1800
|
||||
1720
|
||||
1557
|
||||
1467
|
||||
1371
|
||||
1637
|
||||
1345
|
||||
1924
|
||||
1565
|
||||
1976
|
||||
1827
|
||||
1890
|
||||
1848
|
||||
1465
|
||||
1573
|
||||
1231
|
||||
1310
|
||||
1754
|
||||
1569
|
||||
1532
|
||||
2147
internal/data/2020/DaySix/input.txt
Normal file
2147
internal/data/2020/DaySix/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
323
internal/data/2020/DayThree/input.txt
Normal file
323
internal/data/2020/DayThree/input.txt
Normal file
@@ -0,0 +1,323 @@
|
||||
...............#.#.............
|
||||
##..#....................#...##
|
||||
......#..#.#.....#..#.#.##.....
|
||||
.........#...#..............#.#
|
||||
............#.......##.........
|
||||
...#.....#.....#...#.....#..#..
|
||||
..............#..##.#..#......#
|
||||
.##.....#.....#......##.#......
|
||||
.#..........###....#...##....#.
|
||||
.....#....#.#.......#......##..
|
||||
.#....#......#.......#........#
|
||||
..#.#.......#..##.....##.......
|
||||
...#.#....#.......#.......#...#
|
||||
##.##...##..#......#.#.....#..#
|
||||
.#.#.......#..#.#......#...#.#.
|
||||
#.......##.......#...#.........
|
||||
.....#......#.#.#.....#....##..
|
||||
.#.#........#....#..#..#.......
|
||||
...#....#..###.........#.....#.
|
||||
........#........#........#....
|
||||
..##..............#.....#.#..#.
|
||||
.#...##.............#.#........
|
||||
....#..#...........#.......#...
|
||||
..#....#.....................#.
|
||||
#.#..................##......##
|
||||
.#.##....#......#........#.....
|
||||
.........##.....#....#...##..#.
|
||||
#..........#..#.#.............#
|
||||
.........#...#.#.#.#..##..##...
|
||||
#...#.....#..#..#....#...#.....
|
||||
..##.....#..................#..
|
||||
#..###.....#....#.......#..#...
|
||||
...##.##..#............#......#
|
||||
........###.........###......#.
|
||||
#..##....#.........#.........#.
|
||||
....#.....................#....
|
||||
#..#..##..#..####.##..#.....##.
|
||||
..#...#.#....#....##.....#.....
|
||||
...#.#.........#.....#.#.......
|
||||
....#................#..#...##.
|
||||
....#..#..........#...#.#.##...
|
||||
........#..##............#....#
|
||||
...#......##..........#.##...#.
|
||||
.......##......................
|
||||
.......##..........#....#.#...#
|
||||
......###.##..##..#....#...#..#
|
||||
#.#...........##.....#........#
|
||||
..#...........#..###....#.#.#..
|
||||
........#...........#......##..
|
||||
.........#...##.###...###..#...
|
||||
.....#.....#..##.........##....
|
||||
...##..............#.....#...##
|
||||
.##....#.......###.....#.......
|
||||
.#...........##.............##.
|
||||
......#..#..##.##......#......#
|
||||
........###........#......#.#..
|
||||
#.#....#.....#........#......#.
|
||||
.##..#.........##...##....#....
|
||||
.....#.........#...##.....#....
|
||||
.............#........###....#.
|
||||
......#.......#.#........#.#...
|
||||
..#....#.#...#....#...#.#...##.
|
||||
#...#......##..##......#.##.###
|
||||
...##.#....#...#....#.........#
|
||||
...#..####.....##.#..#.#...##..
|
||||
##.#..#....##......#......##...
|
||||
###.........#.#..#.#.....#.....
|
||||
...#........#..##...#.#.#..#.#.
|
||||
...###..#.###.#...#............
|
||||
....................###........
|
||||
...........#...........#.......
|
||||
#..............#.#.........###.
|
||||
....................##.....#..#
|
||||
#.#.....#.......#...#..........
|
||||
.#...#......#....##...#...#....
|
||||
.....#.##..................###.
|
||||
.........#.#..#.#......#.......
|
||||
.......#.....##..#.##.#........
|
||||
..#..........#.###.....#....#..
|
||||
......#.............#.#........
|
||||
........##....#........#.......
|
||||
...#.............#....#.#......
|
||||
#........#..####.....#.....#.#.
|
||||
.##......##...#........#..#.#..
|
||||
....##....#...#...#..##...#.#..
|
||||
#.##...###..#....##.#..........
|
||||
....#.#...#.#...#..##.###...#..
|
||||
#.....##..#..#....#.#.....##...
|
||||
.#..#..........##.#.....##.....
|
||||
.#..#........#.#.#.#...........
|
||||
.#..#.....#...........#...#....
|
||||
...#......##..........##..#....
|
||||
...#..#....#.##...#..#.....###.
|
||||
#.#....#.....##................
|
||||
#..#......#.#.#.......#........
|
||||
......#....#.#....#..##....#..#
|
||||
.#.....#.#....###.##.........#.
|
||||
.###..#.....#........#.#.......
|
||||
.#...#......#..#.#......#.....#
|
||||
#...............####...#.....#.
|
||||
.......#..........##.#........#
|
||||
#........##....##.....###..##..
|
||||
#..#.....#..##.....#....#..#...
|
||||
#.....#.......##......#.#.....#
|
||||
#.##..#......##..#.............
|
||||
##...#.....#........##.........
|
||||
....#..##....#...#.......#.#...
|
||||
....#...#...##..#....#..#...#..
|
||||
..............#.#...#....###...
|
||||
...#....#..##...##..#....##....
|
||||
#.##.#..#..#......#.#.#.#...#..
|
||||
.......#..#..##........#......#
|
||||
##.#....#....##.#......##.#....
|
||||
.#...#..............#........#.
|
||||
.#.#....#.........#............
|
||||
.#..#..###.............#....#..
|
||||
#......#...#.#..##..#...#....#.
|
||||
.......................#...#.#.
|
||||
.............#..#...##.........
|
||||
..#.#..#....#....#........#....
|
||||
#......#.##..#...#.#...........
|
||||
.....#....#...........##.#..#..
|
||||
..#.#.....#..............#.#...
|
||||
#.......#.....#................
|
||||
#..............#...#....#...#..
|
||||
...#...##..#..#............#...
|
||||
......###.....................#
|
||||
.........#.......##..#....#....
|
||||
........#...#.##..#.##......#..
|
||||
....###..#.#...#...#..#.#...###
|
||||
##...#...##.#...#.#...#.#....#.
|
||||
.........#...#.....###.........
|
||||
...#........##..#.......##.....
|
||||
.#.......##.........#.....##..#
|
||||
.#..................#...#......
|
||||
.##..#..#.#.....#.###..........
|
||||
...#.....##..#.........#...#...
|
||||
.#......#.#.......#.#..........
|
||||
.........#.#...#..........#.#..
|
||||
#..........#.##..#.##....#.....
|
||||
.#.#....#.....#..##.....#...#..
|
||||
..#........##...##..#..#....#..
|
||||
#...........##....#..###....#..
|
||||
...........##.........####...#.
|
||||
..#........###...#.#.........#.
|
||||
.#...............#.##.#.#...#..
|
||||
.#.##..#.....#.#.....##..#.....
|
||||
...#...#..#.##.##...#.......##.
|
||||
..#...#...#......##.##.##...#..
|
||||
##....#...#...#...............#
|
||||
...##...........#......#..#.#..
|
||||
#.........#......#.#.##.....#..
|
||||
........#..#.........##........
|
||||
..#.#....###.....##..#...#.....
|
||||
.........#...#.......#.....##..
|
||||
##.....................#...##..
|
||||
.#.#..#......#.................
|
||||
.....###..#......#..###..#.....
|
||||
...#.....##.........#......#..#
|
||||
......##.....#...#........#.#..
|
||||
..#.#...#......#...#.##.##.....
|
||||
...#..........#...#.......#..##
|
||||
.###........#........##........
|
||||
..#.#.#..........#.#...##......
|
||||
.........#........#......###..#
|
||||
....##..#.........#...........#
|
||||
..####..#............##.......#
|
||||
.....##.#..##.........#...#.#..
|
||||
...#.........#.....#.....#.....
|
||||
.......#...#..#...##.........#.
|
||||
...#...#..#...#....#..#........
|
||||
#............##.##...#.........
|
||||
.#.#.....#.......####.....#....
|
||||
..............#......#.#.......
|
||||
..............#...........#...#
|
||||
#...#........###....#.#....#.#.
|
||||
##.#..#..#......#......#.#.#...
|
||||
.#..#.....#..#.#..#.#.......##.
|
||||
......##.#...#...#......#...#..
|
||||
#...........##....#.#..........
|
||||
....#.......###.#...#..........
|
||||
.......................#.....#.
|
||||
........#...#..#...#.#.#.#.#...
|
||||
.#.#...........#......##...#...
|
||||
.........................#.....
|
||||
.................#.##.#...##...
|
||||
...#...##.....#.....##....#.#..
|
||||
...#...#...................#...
|
||||
...#..#..#...#...#....#........
|
||||
#....#...#.....#...............
|
||||
.......#...........#...#.......
|
||||
....#....#.....##.......#......
|
||||
.......#..........##...........
|
||||
.#.#........#..##....#......#..
|
||||
.....#.......#.#.........#...#.
|
||||
.#..####.#.#...............#..#
|
||||
.....###..#..#..........#.#..##
|
||||
..#.......#...#.....##..#..#.#.
|
||||
#....#......#..................
|
||||
........#.##.#....#...........#
|
||||
....#.#....##..#.#.....##......
|
||||
...#..#.......#....#.....#.#.#.
|
||||
#...#......#.....#.#..........#
|
||||
....#....#...............#.....
|
||||
..###......................###.
|
||||
.##....#..#.......###.....#..#.
|
||||
..###............#........#.##.
|
||||
.#........#......#.....#..#....
|
||||
....#..##...#...#.###.......#.#
|
||||
.......#.##...........#.#..#...
|
||||
.....#...##....................
|
||||
....#....#...##......#.........
|
||||
..#............##....###.#...#.
|
||||
.#........#...............#....
|
||||
#..#.#.##.........#..##....##..
|
||||
#.#....#..#.##....##...#.#.....
|
||||
.....#.....##....#.#........#..
|
||||
#..#...#...#....#....#.........
|
||||
...#........#..#.#.....##......
|
||||
..#...#...#................##..
|
||||
#........#.#.##.......#.#...#..
|
||||
#......#..####.##.....#.#..#.#.
|
||||
............#..#.#....#......##
|
||||
..#.....##....#...#.#..........
|
||||
...#...#.........#...#.#.......
|
||||
.###..#.......##.##.....#.#.#..
|
||||
...#....#...............##.#...
|
||||
....##..#..#..#.#......##.....#
|
||||
#.#..............##...##...####
|
||||
.....#.##...#.#...............#
|
||||
.##.....#.........#.......#.#.#
|
||||
#.#..#.....#.......#.......#..#
|
||||
...#.#.....#.....#......#......
|
||||
.......#....#..#.#..........#..
|
||||
......#......#.##...#..........
|
||||
.....#.......###...#...#.#.....
|
||||
#..#.#.........#.....#.##....#.
|
||||
..#.#.........#..#..#..#.....#.
|
||||
.#..##..#..#....#......#.##..#.
|
||||
...##......###.....#.##.##.....
|
||||
.#.....#...#..#...#............
|
||||
##..##..#.##....#..#...........
|
||||
...#..##..#..#.............#.##
|
||||
...............##............#.
|
||||
..#.....##........##.#...#....#
|
||||
.#.#...#.#.#..#.#.....#....#...
|
||||
.#....#...............#..#.....
|
||||
....#.##..#....#......#...###..
|
||||
#................###...#.#.....
|
||||
...#...#......##..#.#....#.....
|
||||
.#....#....#.#...##............
|
||||
....#...##..#..#........#.##...
|
||||
..##.....#..#..##..............
|
||||
..#..##..#.#..##....#....#....#
|
||||
...##.............#............
|
||||
#....#....#.#........#.....##.#
|
||||
.....#..#.#.....####...###.....
|
||||
................#......#.......
|
||||
.....#.#.#.#.#....#..#........#
|
||||
.##.#...#.#.......##....#....#.
|
||||
.....#........#................
|
||||
..#.....#..#...#..#...........#
|
||||
.#.....#...##.....##..#.#....##
|
||||
......#.......#..#......##.#...
|
||||
#.#..........#.##.#........#...
|
||||
...#..#.............#..........
|
||||
#..#..#..........#..##.#.......
|
||||
.#..#...............####..#....
|
||||
.......#.....#......#.....#.#..
|
||||
.#...............#...#.........
|
||||
.#..#..........#..#.#..##..#..#
|
||||
......##..#.....#..#......###..
|
||||
..........#...#..#.......#.....
|
||||
.#.#.#..#.....#.##.#...#..#....
|
||||
........#.......#.....#.#......
|
||||
......#.....##.....#....##.#...
|
||||
...............#......#.......#
|
||||
..#.#...#.....#.#...##......#..
|
||||
#.#.........#.#...#........####
|
||||
#..........##..#..#........##..
|
||||
.............#..#.......##.#..#
|
||||
..#........#.#....#........#.#.
|
||||
.#......####..#..#.............
|
||||
............###.......#.#..#...
|
||||
#.##......##...#...#.........#.
|
||||
....##.#.#.#......#....#..#...#
|
||||
.#..#.#....#...#.........#.....
|
||||
#...#.....##............#...#..
|
||||
#.#...#..#.................#...
|
||||
............#.#..#.....#.#.#..#
|
||||
...................#....#.##...
|
||||
.....#...#.#....#....#.#......#
|
||||
.......##.#.#......##..........
|
||||
.#..#...##.#...#..#......#.....
|
||||
......#.#..#..###..##..##......
|
||||
.#.#.#.#.....#...###.....#..#..
|
||||
.#....#.....#.......#.......#..
|
||||
..........##.........####......
|
||||
.#.#.............#..#.#...#....
|
||||
........#........##...#.#....#.
|
||||
........#......................
|
||||
..#.#....#...............#...##
|
||||
.......#.#...#..#.....##......#
|
||||
.#...#....#..........##........
|
||||
.#.........#.#............##...
|
||||
.....#......##...#.......#..#..
|
||||
#.#..#.............#...#...#...
|
||||
......#.......#............#...
|
||||
...........##....#......##.....
|
||||
.#.#..#.....................#..
|
||||
##..##.....###..##.#...........
|
||||
...##......##....#...##.....#..
|
||||
#...#.##.............#.........
|
||||
......#..#.........###.#......#
|
||||
#.#.....#.....................#
|
||||
....#####.....##........#.#..#.
|
||||
...........##..##.###..........
|
||||
..........##.....#........#...#
|
||||
.......#..#......#.....##..##.#
|
||||
.....##.#........#.........#...
|
||||
......##......................#
|
||||
.#.......#.#.#............#..#.
|
||||
.....##.#.......#.#........#...
|
||||
1000
internal/data/2020/DayTwo/input.txt
Normal file
1000
internal/data/2020/DayTwo/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
2000
internal/data/2021/DayOne/input.txt
Normal file
2000
internal/data/2021/DayOne/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
1000
internal/data/2021/DayThree/input.txt
Normal file
1000
internal/data/2021/DayThree/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
1000
internal/data/2021/DayTwo/input.txt
Normal file
1000
internal/data/2021/DayTwo/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
42
internal/registry/registry.go
Normal file
42
internal/registry/registry.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package registry
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Runner interface {
|
||||
Run(input string, part string)
|
||||
}
|
||||
|
||||
type DayRunner[T any] struct {
|
||||
ParseInput func(string) T
|
||||
PartOne func(T) int
|
||||
PartTwo func(T) int
|
||||
}
|
||||
|
||||
func (r *DayRunner[T]) Run(input string, part string) {
|
||||
data := r.ParseInput(input)
|
||||
switch part {
|
||||
case "":
|
||||
fmt.Println(r.PartOne(data))
|
||||
fmt.Println(r.PartTwo(data))
|
||||
case "1":
|
||||
fmt.Println(r.PartOne(data))
|
||||
case "2":
|
||||
fmt.Println(r.PartTwo(data))
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "Invalid part: %s\n", part)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
var Days = make(map[string]any)
|
||||
|
||||
func Register[T any](key string, parseInput func(string) T, partOne func(T) int, partTwo func(T) int) {
|
||||
Days[key] = &DayRunner[T]{
|
||||
ParseInput: parseInput,
|
||||
PartOne: partOne,
|
||||
PartTwo: partTwo,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user