2024 rescaffold
This commit is contained in:
17
2024/01.odin
17
2024/01.odin
@@ -1,7 +1,7 @@
|
||||
package aoc
|
||||
|
||||
import "core:math"
|
||||
import "core:fmt"
|
||||
import "core:math"
|
||||
import "core:sort"
|
||||
import "core:strconv"
|
||||
import "core:strings"
|
||||
@@ -18,24 +18,25 @@ day01 :: proc() {
|
||||
b, _ := strconv.parse_int(sp[1])
|
||||
append(&left, a)
|
||||
append(&right, b)
|
||||
delete(sp)
|
||||
}
|
||||
sort.quick_sort(left[:])
|
||||
sort.quick_sort(right[:])
|
||||
|
||||
|
||||
p1: int
|
||||
for i in 0..<len(left) {
|
||||
p1 += math.abs(left[i] - right[i])
|
||||
for i in 0 ..< len(left) {
|
||||
p1 += math.abs(left[i] - right[i])
|
||||
}
|
||||
fmt.println(p1)
|
||||
|
||||
|
||||
count: map[int]int
|
||||
for r in right {
|
||||
count[r] += 1
|
||||
count[r] += 1
|
||||
}
|
||||
|
||||
|
||||
p2: int
|
||||
for l in left {
|
||||
p2 += l * count[l]
|
||||
p2 += l * count[l]
|
||||
}
|
||||
fmt.println(p2)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,10 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day02 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
input := slurp_lines("input/02")
|
||||
defer delete(input)
|
||||
|
||||
for line in input {
|
||||
|
||||
}
|
||||
fmt.println("Solution for Day 02 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day03 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/03")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 03 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day04 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/04")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 04 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day05 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/05")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 05 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day06 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/06")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 06 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day07 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/07")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 07 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day08 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/08")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 08 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day09 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/09")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 09 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day10 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/10")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 10 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day11 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/11")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 11 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day12 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/12")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 12 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day13 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/13")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 13 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day14 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/14")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 14 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day15 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/15")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 15 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day16 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/16")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 16 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day17 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/17")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 17 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day18 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/18")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 18 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day19 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/19")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 19 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day20 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/20")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 20 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day21 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/21")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 21 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day22 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/22")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 22 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day23 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/23")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 23 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day24 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/24")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 24 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import "core:log"
|
||||
import "core:os"
|
||||
|
||||
day25 :: proc() {
|
||||
input, ok := os.read_entire_file("input/01")
|
||||
if !ok {
|
||||
log.fatal("Failed to read input")
|
||||
}
|
||||
input := slurp_lines("input/25")
|
||||
defer delete(input)
|
||||
fmt.println("Solution for Day 25 is not implemented yet")
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user