From ab6db6b737427bb5882635de1b3d62eab99305a4 Mon Sep 17 00:00:00 2001 From: Dmytro Spivakov Date: Sun, 1 Dec 2024 14:14:30 +0200 Subject: [PATCH] move 2023 to subdir --- {day01 => 2023/day01}/day01.go | 0 {day01 => 2023/day01}/day01_test.go | 0 {day01 => 2023/day01}/test_input11 | 0 {day01 => 2023/day01}/test_input12 | 0 {day01 => 2023/day01}/test_input13 | 0 {day01 => 2023/day01}/test_input21 | 0 {day01 => 2023/day01}/test_input22 | 0 {day02 => 2023/day02}/day02.go | 0 {day02 => 2023/day02}/day02_test.go | 0 {day02 => 2023/day02}/test_input11 | 0 {day02 => 2023/day02}/test_input21 | 0 {day03 => 2023/day03}/day03.go | 0 {day03 => 2023/day03}/day03_test.go | 0 {day03 => 2023/day03}/test_input11 | 0 {day03 => 2023/day03}/test_input12 | 0 .../day03}/test_input13_goddamn_fucking_edge | 0 {day03 => 2023/day03}/test_input21 | 0 {day04 => 2023/day04}/day04.go | 0 {day04 => 2023/day04}/day04_test.go | 0 {day04 => 2023/day04}/test_input11 | 0 {day04 => 2023/day04}/test_input21 | 0 {day05 => 2023/day05}/day05.go | 0 {day05 => 2023/day05}/day05_test.go | 0 {day05 => 2023/day05}/test_input11 | 0 {day05 => 2023/day05}/test_input21 | 0 {day06 => 2023/day06}/day06.go | 0 {day06 => 2023/day06}/day06_test.go | 0 {day06 => 2023/day06}/test_input11 | 0 {day07 => 2023/day07}/day07.go | 0 {day07 => 2023/day07}/day07_test.go | 0 {day07 => 2023/day07}/test_input11 | 0 {day07 => 2023/day07}/test_input21 | 0 {day07 => 2023/day07}/test_input22 | 0 {day08 => 2023/day08}/day08.go | 0 {day08 => 2023/day08}/day08_test.go | 0 {day08 => 2023/day08}/test_input11 | 0 {day08 => 2023/day08}/test_input12 | 0 {day08 => 2023/day08}/test_input21 | 0 {day09 => 2023/day09}/day09.go | 0 {day09 => 2023/day09}/day09_test.go | 0 {day09 => 2023/day09}/test_input11 | 0 {day10 => 2023/day10}/day10.go | 0 {day10 => 2023/day10}/day10_test.go | 0 {day10 => 2023/day10}/test_input11 | 0 {day10 => 2023/day10}/test_input12 | 0 {day10 => 2023/day10}/test_input21 | 0 {day10 => 2023/day10}/test_input22 | 0 {day10 => 2023/day10}/test_input23 | 0 {day11 => 2023/day11}/day11.go | 0 {day11 => 2023/day11}/day11_test.go | 0 {day11 => 2023/day11}/test_input11 | 0 {day11 => 2023/day11}/test_input21 | 0 {day12 => 2023/day12}/day12.go | 0 {day12 => 2023/day12}/day12_test.go | 0 {day12 => 2023/day12}/test_input11 | 0 {day12 => 2023/day12}/test_input12 | 0 {day12 => 2023/day12}/test_input13 | 0 {day13 => 2023/day13}/day13.go | 0 {day13 => 2023/day13}/day13_test.go | 0 {day13 => 2023/day13}/test_input11 | 0 {day13 => 2023/day13}/test_input12 | 0 {day14 => 2023/day14}/day14.go | 0 {day14 => 2023/day14}/day14_test.go | 0 {day14 => 2023/day14}/test_input11 | 0 {day15 => 2023/day15}/day15.go | 0 {day15 => 2023/day15}/day15_test.go | 0 {day15 => 2023/day15}/test_input11 | 0 {day16 => 2023/day16}/day16.go | 0 {day16 => 2023/day16}/day16_test.go | 0 {day16 => 2023/day16}/test_input11 | 0 {day17 => 2023/day17}/day17.go | 0 {day17 => 2023/day17}/day17_test.go | 0 {day17 => 2023/day17}/test_input11 | 0 {day17 => 2023/day17}/test_input12 | 0 {day18 => 2023/day18}/day18.go | 0 {day18 => 2023/day18}/day18_test.go | 0 {day18 => 2023/day18}/test_input11 | 0 2023/day19/day19.go | 121 ++++++++++++++++++ 2023/day19/day19_test.go | 18 +++ 2023/day19/test_input11 | 17 +++ main.go | 114 +++++++++-------- 81 files changed, 215 insertions(+), 55 deletions(-) rename {day01 => 2023/day01}/day01.go (100%) rename {day01 => 2023/day01}/day01_test.go (100%) rename {day01 => 2023/day01}/test_input11 (100%) rename {day01 => 2023/day01}/test_input12 (100%) rename {day01 => 2023/day01}/test_input13 (100%) rename {day01 => 2023/day01}/test_input21 (100%) rename {day01 => 2023/day01}/test_input22 (100%) rename {day02 => 2023/day02}/day02.go (100%) rename {day02 => 2023/day02}/day02_test.go (100%) rename {day02 => 2023/day02}/test_input11 (100%) rename {day02 => 2023/day02}/test_input21 (100%) rename {day03 => 2023/day03}/day03.go (100%) rename {day03 => 2023/day03}/day03_test.go (100%) rename {day03 => 2023/day03}/test_input11 (100%) rename {day03 => 2023/day03}/test_input12 (100%) rename {day03 => 2023/day03}/test_input13_goddamn_fucking_edge (100%) rename {day03 => 2023/day03}/test_input21 (100%) rename {day04 => 2023/day04}/day04.go (100%) rename {day04 => 2023/day04}/day04_test.go (100%) rename {day04 => 2023/day04}/test_input11 (100%) rename {day04 => 2023/day04}/test_input21 (100%) rename {day05 => 2023/day05}/day05.go (100%) rename {day05 => 2023/day05}/day05_test.go (100%) rename {day05 => 2023/day05}/test_input11 (100%) rename {day05 => 2023/day05}/test_input21 (100%) rename {day06 => 2023/day06}/day06.go (100%) rename {day06 => 2023/day06}/day06_test.go (100%) rename {day06 => 2023/day06}/test_input11 (100%) rename {day07 => 2023/day07}/day07.go (100%) rename {day07 => 2023/day07}/day07_test.go (100%) rename {day07 => 2023/day07}/test_input11 (100%) rename {day07 => 2023/day07}/test_input21 (100%) rename {day07 => 2023/day07}/test_input22 (100%) rename {day08 => 2023/day08}/day08.go (100%) rename {day08 => 2023/day08}/day08_test.go (100%) rename {day08 => 2023/day08}/test_input11 (100%) rename {day08 => 2023/day08}/test_input12 (100%) rename {day08 => 2023/day08}/test_input21 (100%) rename {day09 => 2023/day09}/day09.go (100%) rename {day09 => 2023/day09}/day09_test.go (100%) rename {day09 => 2023/day09}/test_input11 (100%) rename {day10 => 2023/day10}/day10.go (100%) rename {day10 => 2023/day10}/day10_test.go (100%) rename {day10 => 2023/day10}/test_input11 (100%) rename {day10 => 2023/day10}/test_input12 (100%) rename {day10 => 2023/day10}/test_input21 (100%) rename {day10 => 2023/day10}/test_input22 (100%) rename {day10 => 2023/day10}/test_input23 (100%) rename {day11 => 2023/day11}/day11.go (100%) rename {day11 => 2023/day11}/day11_test.go (100%) rename {day11 => 2023/day11}/test_input11 (100%) rename {day11 => 2023/day11}/test_input21 (100%) rename {day12 => 2023/day12}/day12.go (100%) rename {day12 => 2023/day12}/day12_test.go (100%) rename {day12 => 2023/day12}/test_input11 (100%) rename {day12 => 2023/day12}/test_input12 (100%) rename {day12 => 2023/day12}/test_input13 (100%) rename {day13 => 2023/day13}/day13.go (100%) rename {day13 => 2023/day13}/day13_test.go (100%) rename {day13 => 2023/day13}/test_input11 (100%) rename {day13 => 2023/day13}/test_input12 (100%) rename {day14 => 2023/day14}/day14.go (100%) rename {day14 => 2023/day14}/day14_test.go (100%) rename {day14 => 2023/day14}/test_input11 (100%) rename {day15 => 2023/day15}/day15.go (100%) rename {day15 => 2023/day15}/day15_test.go (100%) rename {day15 => 2023/day15}/test_input11 (100%) rename {day16 => 2023/day16}/day16.go (100%) rename {day16 => 2023/day16}/day16_test.go (100%) rename {day16 => 2023/day16}/test_input11 (100%) rename {day17 => 2023/day17}/day17.go (100%) rename {day17 => 2023/day17}/day17_test.go (100%) rename {day17 => 2023/day17}/test_input11 (100%) rename {day17 => 2023/day17}/test_input12 (100%) rename {day18 => 2023/day18}/day18.go (100%) rename {day18 => 2023/day18}/day18_test.go (100%) rename {day18 => 2023/day18}/test_input11 (100%) create mode 100644 2023/day19/day19.go create mode 100644 2023/day19/day19_test.go create mode 100644 2023/day19/test_input11 diff --git a/day01/day01.go b/2023/day01/day01.go similarity index 100% rename from day01/day01.go rename to 2023/day01/day01.go diff --git a/day01/day01_test.go b/2023/day01/day01_test.go similarity index 100% rename from day01/day01_test.go rename to 2023/day01/day01_test.go diff --git a/day01/test_input11 b/2023/day01/test_input11 similarity index 100% rename from day01/test_input11 rename to 2023/day01/test_input11 diff --git a/day01/test_input12 b/2023/day01/test_input12 similarity index 100% rename from day01/test_input12 rename to 2023/day01/test_input12 diff --git a/day01/test_input13 b/2023/day01/test_input13 similarity index 100% rename from day01/test_input13 rename to 2023/day01/test_input13 diff --git a/day01/test_input21 b/2023/day01/test_input21 similarity index 100% rename from day01/test_input21 rename to 2023/day01/test_input21 diff --git a/day01/test_input22 b/2023/day01/test_input22 similarity index 100% rename from day01/test_input22 rename to 2023/day01/test_input22 diff --git a/day02/day02.go b/2023/day02/day02.go similarity index 100% rename from day02/day02.go rename to 2023/day02/day02.go diff --git a/day02/day02_test.go b/2023/day02/day02_test.go similarity index 100% rename from day02/day02_test.go rename to 2023/day02/day02_test.go diff --git a/day02/test_input11 b/2023/day02/test_input11 similarity index 100% rename from day02/test_input11 rename to 2023/day02/test_input11 diff --git a/day02/test_input21 b/2023/day02/test_input21 similarity index 100% rename from day02/test_input21 rename to 2023/day02/test_input21 diff --git a/day03/day03.go b/2023/day03/day03.go similarity index 100% rename from day03/day03.go rename to 2023/day03/day03.go diff --git a/day03/day03_test.go b/2023/day03/day03_test.go similarity index 100% rename from day03/day03_test.go rename to 2023/day03/day03_test.go diff --git a/day03/test_input11 b/2023/day03/test_input11 similarity index 100% rename from day03/test_input11 rename to 2023/day03/test_input11 diff --git a/day03/test_input12 b/2023/day03/test_input12 similarity index 100% rename from day03/test_input12 rename to 2023/day03/test_input12 diff --git a/day03/test_input13_goddamn_fucking_edge b/2023/day03/test_input13_goddamn_fucking_edge similarity index 100% rename from day03/test_input13_goddamn_fucking_edge rename to 2023/day03/test_input13_goddamn_fucking_edge diff --git a/day03/test_input21 b/2023/day03/test_input21 similarity index 100% rename from day03/test_input21 rename to 2023/day03/test_input21 diff --git a/day04/day04.go b/2023/day04/day04.go similarity index 100% rename from day04/day04.go rename to 2023/day04/day04.go diff --git a/day04/day04_test.go b/2023/day04/day04_test.go similarity index 100% rename from day04/day04_test.go rename to 2023/day04/day04_test.go diff --git a/day04/test_input11 b/2023/day04/test_input11 similarity index 100% rename from day04/test_input11 rename to 2023/day04/test_input11 diff --git a/day04/test_input21 b/2023/day04/test_input21 similarity index 100% rename from day04/test_input21 rename to 2023/day04/test_input21 diff --git a/day05/day05.go b/2023/day05/day05.go similarity index 100% rename from day05/day05.go rename to 2023/day05/day05.go diff --git a/day05/day05_test.go b/2023/day05/day05_test.go similarity index 100% rename from day05/day05_test.go rename to 2023/day05/day05_test.go diff --git a/day05/test_input11 b/2023/day05/test_input11 similarity index 100% rename from day05/test_input11 rename to 2023/day05/test_input11 diff --git a/day05/test_input21 b/2023/day05/test_input21 similarity index 100% rename from day05/test_input21 rename to 2023/day05/test_input21 diff --git a/day06/day06.go b/2023/day06/day06.go similarity index 100% rename from day06/day06.go rename to 2023/day06/day06.go diff --git a/day06/day06_test.go b/2023/day06/day06_test.go similarity index 100% rename from day06/day06_test.go rename to 2023/day06/day06_test.go diff --git a/day06/test_input11 b/2023/day06/test_input11 similarity index 100% rename from day06/test_input11 rename to 2023/day06/test_input11 diff --git a/day07/day07.go b/2023/day07/day07.go similarity index 100% rename from day07/day07.go rename to 2023/day07/day07.go diff --git a/day07/day07_test.go b/2023/day07/day07_test.go similarity index 100% rename from day07/day07_test.go rename to 2023/day07/day07_test.go diff --git a/day07/test_input11 b/2023/day07/test_input11 similarity index 100% rename from day07/test_input11 rename to 2023/day07/test_input11 diff --git a/day07/test_input21 b/2023/day07/test_input21 similarity index 100% rename from day07/test_input21 rename to 2023/day07/test_input21 diff --git a/day07/test_input22 b/2023/day07/test_input22 similarity index 100% rename from day07/test_input22 rename to 2023/day07/test_input22 diff --git a/day08/day08.go b/2023/day08/day08.go similarity index 100% rename from day08/day08.go rename to 2023/day08/day08.go diff --git a/day08/day08_test.go b/2023/day08/day08_test.go similarity index 100% rename from day08/day08_test.go rename to 2023/day08/day08_test.go diff --git a/day08/test_input11 b/2023/day08/test_input11 similarity index 100% rename from day08/test_input11 rename to 2023/day08/test_input11 diff --git a/day08/test_input12 b/2023/day08/test_input12 similarity index 100% rename from day08/test_input12 rename to 2023/day08/test_input12 diff --git a/day08/test_input21 b/2023/day08/test_input21 similarity index 100% rename from day08/test_input21 rename to 2023/day08/test_input21 diff --git a/day09/day09.go b/2023/day09/day09.go similarity index 100% rename from day09/day09.go rename to 2023/day09/day09.go diff --git a/day09/day09_test.go b/2023/day09/day09_test.go similarity index 100% rename from day09/day09_test.go rename to 2023/day09/day09_test.go diff --git a/day09/test_input11 b/2023/day09/test_input11 similarity index 100% rename from day09/test_input11 rename to 2023/day09/test_input11 diff --git a/day10/day10.go b/2023/day10/day10.go similarity index 100% rename from day10/day10.go rename to 2023/day10/day10.go diff --git a/day10/day10_test.go b/2023/day10/day10_test.go similarity index 100% rename from day10/day10_test.go rename to 2023/day10/day10_test.go diff --git a/day10/test_input11 b/2023/day10/test_input11 similarity index 100% rename from day10/test_input11 rename to 2023/day10/test_input11 diff --git a/day10/test_input12 b/2023/day10/test_input12 similarity index 100% rename from day10/test_input12 rename to 2023/day10/test_input12 diff --git a/day10/test_input21 b/2023/day10/test_input21 similarity index 100% rename from day10/test_input21 rename to 2023/day10/test_input21 diff --git a/day10/test_input22 b/2023/day10/test_input22 similarity index 100% rename from day10/test_input22 rename to 2023/day10/test_input22 diff --git a/day10/test_input23 b/2023/day10/test_input23 similarity index 100% rename from day10/test_input23 rename to 2023/day10/test_input23 diff --git a/day11/day11.go b/2023/day11/day11.go similarity index 100% rename from day11/day11.go rename to 2023/day11/day11.go diff --git a/day11/day11_test.go b/2023/day11/day11_test.go similarity index 100% rename from day11/day11_test.go rename to 2023/day11/day11_test.go diff --git a/day11/test_input11 b/2023/day11/test_input11 similarity index 100% rename from day11/test_input11 rename to 2023/day11/test_input11 diff --git a/day11/test_input21 b/2023/day11/test_input21 similarity index 100% rename from day11/test_input21 rename to 2023/day11/test_input21 diff --git a/day12/day12.go b/2023/day12/day12.go similarity index 100% rename from day12/day12.go rename to 2023/day12/day12.go diff --git a/day12/day12_test.go b/2023/day12/day12_test.go similarity index 100% rename from day12/day12_test.go rename to 2023/day12/day12_test.go diff --git a/day12/test_input11 b/2023/day12/test_input11 similarity index 100% rename from day12/test_input11 rename to 2023/day12/test_input11 diff --git a/day12/test_input12 b/2023/day12/test_input12 similarity index 100% rename from day12/test_input12 rename to 2023/day12/test_input12 diff --git a/day12/test_input13 b/2023/day12/test_input13 similarity index 100% rename from day12/test_input13 rename to 2023/day12/test_input13 diff --git a/day13/day13.go b/2023/day13/day13.go similarity index 100% rename from day13/day13.go rename to 2023/day13/day13.go diff --git a/day13/day13_test.go b/2023/day13/day13_test.go similarity index 100% rename from day13/day13_test.go rename to 2023/day13/day13_test.go diff --git a/day13/test_input11 b/2023/day13/test_input11 similarity index 100% rename from day13/test_input11 rename to 2023/day13/test_input11 diff --git a/day13/test_input12 b/2023/day13/test_input12 similarity index 100% rename from day13/test_input12 rename to 2023/day13/test_input12 diff --git a/day14/day14.go b/2023/day14/day14.go similarity index 100% rename from day14/day14.go rename to 2023/day14/day14.go diff --git a/day14/day14_test.go b/2023/day14/day14_test.go similarity index 100% rename from day14/day14_test.go rename to 2023/day14/day14_test.go diff --git a/day14/test_input11 b/2023/day14/test_input11 similarity index 100% rename from day14/test_input11 rename to 2023/day14/test_input11 diff --git a/day15/day15.go b/2023/day15/day15.go similarity index 100% rename from day15/day15.go rename to 2023/day15/day15.go diff --git a/day15/day15_test.go b/2023/day15/day15_test.go similarity index 100% rename from day15/day15_test.go rename to 2023/day15/day15_test.go diff --git a/day15/test_input11 b/2023/day15/test_input11 similarity index 100% rename from day15/test_input11 rename to 2023/day15/test_input11 diff --git a/day16/day16.go b/2023/day16/day16.go similarity index 100% rename from day16/day16.go rename to 2023/day16/day16.go diff --git a/day16/day16_test.go b/2023/day16/day16_test.go similarity index 100% rename from day16/day16_test.go rename to 2023/day16/day16_test.go diff --git a/day16/test_input11 b/2023/day16/test_input11 similarity index 100% rename from day16/test_input11 rename to 2023/day16/test_input11 diff --git a/day17/day17.go b/2023/day17/day17.go similarity index 100% rename from day17/day17.go rename to 2023/day17/day17.go diff --git a/day17/day17_test.go b/2023/day17/day17_test.go similarity index 100% rename from day17/day17_test.go rename to 2023/day17/day17_test.go diff --git a/day17/test_input11 b/2023/day17/test_input11 similarity index 100% rename from day17/test_input11 rename to 2023/day17/test_input11 diff --git a/day17/test_input12 b/2023/day17/test_input12 similarity index 100% rename from day17/test_input12 rename to 2023/day17/test_input12 diff --git a/day18/day18.go b/2023/day18/day18.go similarity index 100% rename from day18/day18.go rename to 2023/day18/day18.go diff --git a/day18/day18_test.go b/2023/day18/day18_test.go similarity index 100% rename from day18/day18_test.go rename to 2023/day18/day18_test.go diff --git a/day18/test_input11 b/2023/day18/test_input11 similarity index 100% rename from day18/test_input11 rename to 2023/day18/test_input11 diff --git a/2023/day19/day19.go b/2023/day19/day19.go new file mode 100644 index 0000000..5718bb1 --- /dev/null +++ b/2023/day19/day19.go @@ -0,0 +1,121 @@ +package day19 + +import ( + "bufio" + "log" + "os" + "regexp" + "strconv" + "strings" +) + +type Part struct { + x int + m int + a int + s int +} + +func (p *Part) getVal(field string) int { + switch field { + case "x": + return (*p).x + case "m": + return (*p).m + case "a": + return (*p).a + case "s": + return (*p).s + } + + log.Fatalf("Part.getVal() unknown field %s\n", field) + return -1 +} + +type RuleSet struct { + name string + rawInput string + workflowSteps []func() +} + +func (rs *RuleSet) init() { + // parse `rawInput` and populate `workflowSteps` +} + +func Solution1(filepath string) int { + return -1 +} + +func Solution2(filepath string) int { + return -1 +} + +func parseInput(filepath string) ([]RuleSet, []Part) { + var ruleSets []RuleSet + var parts []Part + + file, err := os.Open(filepath) + if err != nil { + log.Fatalf("Failed to open the input file: %v\n", err.Error()) + } + scanner := bufio.NewScanner(file) + for scanner.Scan() { + currentLine := scanner.Text() + + if strings.HasPrefix(currentLine, "{") { + parts = append(parts, parsePart(currentLine)) + } else { + ruleSets = append(ruleSets, parseRuleSet(currentLine)) + } + } + if err = scanner.Err(); err != nil { + log.Fatalf("Error during input file read: %v\n", err.Error()) + } + + return ruleSets, parts +} + +func parseRuleSet(rawInput string) RuleSet { + // name := strings.Split(rawInput, "{")[0] + // ruleSet := RuleSet{ + // name: name, + // rawInput: rawInput, + // } + // ruleSegments := strings.Split(rawInput, ",") + // var rules []func() + // for _, ruleSeg := range ruleSegments { + // samples: + // a<10:gd - conditinal transition + // A - unconditional transition + + // rule func signature func(p Part) (applied bool, transitTo string) + // } + + // return ruleSet + return RuleSet{} +} + +func parsePart(rawInput string) Part { + numRegex := regexp.MustCompile(`\d+`) + matches := numRegex.FindAllString(rawInput, -1) + if len(matches) != 4 { + log.Fatalf("Failed to parse Part properly: input=%v, matches=%v\n", rawInput, matches) + } + + // fields are always specified in the same order in the input + return Part{ + x: parseInt(matches[0]), + m: parseInt(matches[1]), + a: parseInt(matches[2]), + s: parseInt(matches[3]), + } +} + +func parseInt(strNum string) int { + num, err := strconv.ParseInt(strNum, 10, 64) + if err != nil { + log.Fatalf("Failed to parse number %v with %v\n", strNum, err.Error()) + } + + return int(num) +} diff --git a/2023/day19/day19_test.go b/2023/day19/day19_test.go new file mode 100644 index 0000000..ffebe43 --- /dev/null +++ b/2023/day19/day19_test.go @@ -0,0 +1,18 @@ +package day19 + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestSolution1(t *testing.T) { + cases := map[string]int{ + "test_input11": 19114, + } + + for input, expectedResult := range cases { + result := Solution1(input) + + assert.Equal(t, expectedResult, result, "Solution1()") + } +} diff --git a/2023/day19/test_input11 b/2023/day19/test_input11 new file mode 100644 index 0000000..e5b5d64 --- /dev/null +++ b/2023/day19/test_input11 @@ -0,0 +1,17 @@ +px{a<2006:qkq,m>2090:A,rfg} +pv{a>1716:R,A} +lnx{m>1548:A,A} +rfg{s<537:gd,x>2440:R,A} +qs{s>3448:A,lnx} +qkq{x<1416:A,crn} +crn{x>2662:A,R} +in{s<1351:px,qqz} +qqz{s>2770:qs,m<1801:hdj,R} +gd{a>3333:R,R} +hdj{m>838:A,pv} + +{x=787,m=2655,a=1222,s=2876} +{x=1679,m=44,a=2067,s=496} +{x=2036,m=264,a=79,s=2244} +{x=2461,m=1339,a=466,s=291} +{x=2127,m=1623,a=2188,s=1013} diff --git a/main.go b/main.go index 3a9dcd0..522c5f3 100644 --- a/main.go +++ b/main.go @@ -1,24 +1,25 @@ package main import ( - "advent-of-code/day01" - "advent-of-code/day02" - "advent-of-code/day03" - "advent-of-code/day04" - "advent-of-code/day05" - "advent-of-code/day06" - "advent-of-code/day07" - "advent-of-code/day08" - "advent-of-code/day09" - "advent-of-code/day10" - "advent-of-code/day11" - "advent-of-code/day12" - "advent-of-code/day13" - "advent-of-code/day14" - "advent-of-code/day15" - "advent-of-code/day16" - "advent-of-code/day17" - "advent-of-code/day18" + aoc2023day01 "advent-of-code/2023/day01" + aoc2023day02 "advent-of-code/2023/day02" + aoc2023day03 "advent-of-code/2023/day03" + aoc2023day04 "advent-of-code/2023/day04" + aoc2023day05 "advent-of-code/2023/day05" + aoc2023day06 "advent-of-code/2023/day06" + aoc2023day07 "advent-of-code/2023/day07" + aoc2023day08 "advent-of-code/2023/day08" + aoc2023day09 "advent-of-code/2023/day09" + aoc2023day10 "advent-of-code/2023/day10" + aoc2023day11 "advent-of-code/2023/day11" + aoc2023day12 "advent-of-code/2023/day12" + aoc2023day13 "advent-of-code/2023/day13" + aoc2023day14 "advent-of-code/2023/day14" + aoc2023day15 "advent-of-code/2023/day15" + aoc2023day16 "advent-of-code/2023/day16" + aoc2023day17 "advent-of-code/2023/day17" + aoc2023day18 "advent-of-code/2023/day18" + aoc2023day19 "advent-of-code/2023/day19" "fmt" "time" ) @@ -27,61 +28,64 @@ func runSolution(day, part int, s func() int) { start := time.Now() res := s() elapsed := time.Since(start) - fmt.Printf("Day %d, solution %d: %v - %v\n", day, part, res, elapsed.Round(time.Microsecond)) + fmt.Printf("Day %02d, solution %d: %v - %v\n", day, part, res, elapsed.Round(time.Microsecond)) } func main() { - runSolution(1, 1, func() int { return day01.Solution1("inputs/day01") }) - runSolution(1, 2, func() int { return day01.Solution2("inputs/day01") }) + runSolution(1, 1, func() int { return aoc2023day01.Solution1("2023/inputs/day01") }) + runSolution(1, 2, func() int { return aoc2023day01.Solution2("2023/inputs/day01") }) - runSolution(2, 1, func() int { return day02.Solution1("inputs/day02") }) - runSolution(2, 2, func() int { return day02.Solution2("inputs/day02") }) + runSolution(2, 1, func() int { return aoc2023day02.Solution1("2023/inputs/day02") }) + runSolution(2, 2, func() int { return aoc2023day02.Solution2("2023/inputs/day02") }) - runSolution(3, 1, func() int { return day03.Solution1("inputs/day03") }) - runSolution(3, 2, func() int { return day03.Solution2("inputs/day03") }) + runSolution(3, 1, func() int { return aoc2023day03.Solution1("2023/inputs/day03") }) + runSolution(3, 2, func() int { return aoc2023day03.Solution2("2023/inputs/day03") }) - runSolution(4, 1, func() int { return day04.Solution1("inputs/day04") }) - runSolution(4, 2, func() int { return day04.Solution2("inputs/day04") }) + runSolution(4, 1, func() int { return aoc2023day04.Solution1("2023/inputs/day04") }) + runSolution(4, 2, func() int { return aoc2023day04.Solution2("2023/inputs/day04") }) - runSolution(5, 1, func() int { return day05.Solution1("inputs/day05") }) - runSolution(5, 2, func() int { return day05.Solution2("inputs/day05") }) + runSolution(5, 1, func() int { return aoc2023day05.Solution1("2023/inputs/day05") }) + runSolution(5, 2, func() int { return aoc2023day05.Solution2("2023/inputs/day05") }) - runSolution(6, 1, func() int { return day06.Solution1("inputs/day06") }) - runSolution(6, 2, func() int { return day06.Solution2("inputs/day06") }) + runSolution(6, 1, func() int { return aoc2023day06.Solution1("2023/inputs/day06") }) + runSolution(6, 2, func() int { return aoc2023day06.Solution2("2023/inputs/day06") }) - runSolution(7, 1, func() int { return day07.Solution1("inputs/day07") }) - runSolution(7, 2, func() int { return day07.Solution2("inputs/day07") }) + runSolution(7, 1, func() int { return aoc2023day07.Solution1("2023/inputs/day07") }) + runSolution(7, 2, func() int { return aoc2023day07.Solution2("2023/inputs/day07") }) - runSolution(8, 1, func() int { return day08.Solution1("inputs/day08") }) - runSolution(8, 2, func() int { return day08.Solution2("inputs/day08") }) + runSolution(8, 1, func() int { return aoc2023day08.Solution1("2023/inputs/day08") }) + runSolution(8, 2, func() int { return aoc2023day08.Solution2("2023/inputs/day08") }) - runSolution(9, 1, func() int { return day09.Solution1("inputs/day09") }) - runSolution(9, 2, func() int { return day09.Solution2("inputs/day09") }) + runSolution(9, 1, func() int { return aoc2023day09.Solution1("2023/inputs/day09") }) + runSolution(9, 2, func() int { return aoc2023day09.Solution2("2023/inputs/day09") }) - runSolution(10, 1, func() int { return day10.Solution1("inputs/day10") }) - runSolution(10, 2, func() int { return day10.Solution2("inputs/day10") }) + runSolution(10, 1, func() int { return aoc2023day10.Solution1("2023/inputs/day10") }) + runSolution(10, 2, func() int { return aoc2023day10.Solution2("2023/inputs/day10") }) - runSolution(11, 1, func() int { return day11.Solution1("inputs/day11") }) - runSolution(11, 2, func() int { return day11.Solution2("inputs/day11") }) + runSolution(11, 1, func() int { return aoc2023day11.Solution1("2023/inputs/day11") }) + runSolution(11, 2, func() int { return aoc2023day11.Solution2("2023/inputs/day11") }) - runSolution(12, 1, func() int { return day12.Solution1("inputs/day12") }) - runSolution(12, 2, func() int { return day12.Solution2("inputs/day12") }) + runSolution(12, 1, func() int { return aoc2023day12.Solution1("2023/inputs/day12") }) + runSolution(12, 2, func() int { return aoc2023day12.Solution2("2023/inputs/day12") }) - runSolution(13, 1, func() int { return day13.Solution1("inputs/day13") }) - runSolution(13, 2, func() int { return day13.Solution2("inputs/day13") }) + runSolution(13, 1, func() int { return aoc2023day13.Solution1("2023/inputs/day13") }) + runSolution(13, 2, func() int { return aoc2023day13.Solution2("2023/inputs/day13") }) - runSolution(14, 1, func() int { return day14.Solution1("inputs/day14") }) - runSolution(14, 2, func() int { return day14.Solution2("inputs/day14") }) + runSolution(14, 1, func() int { return aoc2023day14.Solution1("2023/inputs/day14") }) + runSolution(14, 2, func() int { return aoc2023day14.Solution2("2023/inputs/day14") }) - runSolution(15, 1, func() int { return day15.Solution1("inputs/day15") }) - runSolution(15, 2, func() int { return day15.Solution2("inputs/day15") }) + runSolution(15, 1, func() int { return aoc2023day15.Solution1("2023/inputs/day15") }) + runSolution(15, 2, func() int { return aoc2023day15.Solution2("2023/inputs/day15") }) - runSolution(16, 1, func() int { return day16.Solution1("inputs/day16") }) - runSolution(16, 2, func() int { return day16.Solution2("inputs/day16") }) + runSolution(16, 1, func() int { return aoc2023day16.Solution1("2023/inputs/day16") }) + runSolution(16, 2, func() int { return aoc2023day16.Solution2("2023/inputs/day16") }) - runSolution(17, 1, func() int { return day17.Solution1("inputs/day17") }) - runSolution(17, 2, func() int { return day17.Solution2("inputs/day17") }) + runSolution(17, 1, func() int { return aoc2023day17.Solution1("2023/inputs/day17") }) + runSolution(17, 2, func() int { return aoc2023day17.Solution2("2023/inputs/day17") }) - runSolution(18, 1, func() int { return day18.Solution1("inputs/day18") }) - runSolution(18, 2, func() int { return day18.Solution2("inputs/day18") }) + runSolution(18, 1, func() int { return aoc2023day18.Solution1("2023/inputs/day18") }) + runSolution(18, 2, func() int { return aoc2023day18.Solution2("2023/inputs/day18") }) + + runSolution(19, 1, func() int { return aoc2023day19.Solution1("2023/inputs/day19") }) + runSolution(19, 2, func() int { return aoc2023day19.Solution2("2023/inputs/day19") }) }