2024 rescaffold

This commit is contained in:
2025-11-25 13:10:32 -08:00
parent ca26da6b3b
commit 517dede130
26 changed files with 60 additions and 128 deletions

View File

@@ -1,7 +1,7 @@
package aoc package aoc
import "core:math"
import "core:fmt" import "core:fmt"
import "core:math"
import "core:sort" import "core:sort"
import "core:strconv" import "core:strconv"
import "core:strings" import "core:strings"
@@ -18,24 +18,25 @@ day01 :: proc() {
b, _ := strconv.parse_int(sp[1]) b, _ := strconv.parse_int(sp[1])
append(&left, a) append(&left, a)
append(&right, b) append(&right, b)
delete(sp)
} }
sort.quick_sort(left[:]) sort.quick_sort(left[:])
sort.quick_sort(right[:]) sort.quick_sort(right[:])
p1: int p1: int
for i in 0..<len(left) { for i in 0 ..< len(left) {
p1 += math.abs(left[i] - right[i]) p1 += math.abs(left[i] - right[i])
} }
fmt.println(p1) fmt.println(p1)
count: map[int]int count: map[int]int
for r in right { for r in right {
count[r] += 1 count[r] += 1
} }
p2: int p2: int
for l in left { for l in left {
p2 += l * count[l] p2 += l * count[l]
} }
fmt.println(p2) fmt.println(p2)
} }

View File

@@ -5,9 +5,10 @@ import "core:log"
import "core:os" import "core:os"
day02 :: proc() { day02 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/02")
if !ok { defer delete(input)
log.fatal("Failed to read input")
for line in input {
} }
fmt.println("Solution for Day 02 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day03 :: proc() { day03 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/03")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 03 is not implemented yet") fmt.println("Solution for Day 03 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day04 :: proc() { day04 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/04")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 04 is not implemented yet") fmt.println("Solution for Day 04 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day05 :: proc() { day05 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/05")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 05 is not implemented yet") fmt.println("Solution for Day 05 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day06 :: proc() { day06 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/06")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 06 is not implemented yet") fmt.println("Solution for Day 06 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day07 :: proc() { day07 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/07")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 07 is not implemented yet") fmt.println("Solution for Day 07 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day08 :: proc() { day08 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/08")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 08 is not implemented yet") fmt.println("Solution for Day 08 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day09 :: proc() { day09 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/09")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 09 is not implemented yet") fmt.println("Solution for Day 09 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day10 :: proc() { day10 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/10")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 10 is not implemented yet") fmt.println("Solution for Day 10 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day11 :: proc() { day11 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/11")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 11 is not implemented yet") fmt.println("Solution for Day 11 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day12 :: proc() { day12 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/12")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 12 is not implemented yet") fmt.println("Solution for Day 12 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day13 :: proc() { day13 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/13")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 13 is not implemented yet") fmt.println("Solution for Day 13 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day14 :: proc() { day14 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/14")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 14 is not implemented yet") fmt.println("Solution for Day 14 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day15 :: proc() { day15 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/15")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 15 is not implemented yet") fmt.println("Solution for Day 15 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day16 :: proc() { day16 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/16")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 16 is not implemented yet") fmt.println("Solution for Day 16 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day17 :: proc() { day17 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/17")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 17 is not implemented yet") fmt.println("Solution for Day 17 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day18 :: proc() { day18 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/18")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 18 is not implemented yet") fmt.println("Solution for Day 18 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day19 :: proc() { day19 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/19")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 19 is not implemented yet") fmt.println("Solution for Day 19 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day20 :: proc() { day20 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/20")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 20 is not implemented yet") fmt.println("Solution for Day 20 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day21 :: proc() { day21 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/21")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 21 is not implemented yet") fmt.println("Solution for Day 21 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day22 :: proc() { day22 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/22")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 22 is not implemented yet") fmt.println("Solution for Day 22 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day23 :: proc() { day23 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/23")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 23 is not implemented yet") fmt.println("Solution for Day 23 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day24 :: proc() { day24 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/24")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 24 is not implemented yet") fmt.println("Solution for Day 24 is not implemented yet")
} }

View File

@@ -5,9 +5,7 @@ import "core:log"
import "core:os" import "core:os"
day25 :: proc() { day25 :: proc() {
input, ok := os.read_entire_file("input/01") input := slurp_lines("input/25")
if !ok { defer delete(input)
log.fatal("Failed to read input")
}
fmt.println("Solution for Day 25 is not implemented yet") fmt.println("Solution for Day 25 is not implemented yet")
} }

View File

@@ -1,24 +0,0 @@
#!/usr/bin/env bash
for day in {1..25}; do
if [[ $day -lt 10 ]]; then
d="0${day}"
else
d="$day"
fi
tee "${d}.odin" <<EOF
package aoc
import "core:fmt"
import "core:log"
import "core:os"
day${d} :: proc() {
input, ok := os.read_entire_file("input/01")
if !ok {
log.fatal("Failed to read input")
}
fmt.println("Solution for Day ${d} is not implemented yet")
}
EOF
done