replace the horrible error system with multiple returns

This commit is contained in:
2026-05-28 17:28:57 +02:00
parent 0b16cc4513
commit f181cfe675
18 changed files with 138 additions and 199 deletions

View File

@@ -15,7 +15,11 @@ func part2[l1: Array, l2: Array] : void
io.println_i64(out)
func main[] : i64
lines : Array = must(io.read_text_file?("input.txt")) |> str.split("\n")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
lines := str.split(input, "\n")
l1 := []
l2 := []

View File

@@ -40,7 +40,11 @@ func part2[data: Array] : void
io.println_i64(out)
func main[] : i64
lines := must(io.read_text_file?("input.txt")) |> str.split("\n")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
lines := str.split(input, "\n")
data := []
for i in 0..lines->size

View File

@@ -56,7 +56,11 @@ func part2[lines: Array] : void
io.println_i64(out)
func main[] : i64
lines : Array = must(io.read_text_file?("input.txt")) |> str.split("\n")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
lines := str.split(input, "\n")
part1(lines)
part2(lines)

View File

@@ -47,7 +47,11 @@ func part2[updates: Array, rules_left: Array, rules_right: Array] : void
io.println_i64(out)
func main[] : i64
data := must(io.read_text_file?("input.txt")) |> str.split("\n\n")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
data := str.split(input, "\n\n")
rules_left := []
rules_right := []

View File

@@ -61,7 +61,11 @@ func part2[equations: Array] : void
io.println_i64(out)
func main[] : i64
lines := must(io.read_text_file?("input.txt")) |> str.split("\n")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
lines := str.split(input, "\n")
equations := []
for i in 0..lines->size

View File

@@ -47,7 +47,11 @@ func part2[lines: Array] : void
io.println_i64(password)
func main[] : i64
lines := must(io.read_text_file?("input.txt")) |> str.split("\n")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
lines := str.split(input, "\n")
part1(lines)
part2(lines)

View File

@@ -54,7 +54,11 @@ func part2[ranges: Array] : void
io.println_i64(sum)
func main[] : i64
ranges := must(io.read_text_file?("input.txt")) |> str.split(",")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
ranges := str.split(input, ",")
part1(ranges)
part2(ranges)

View File

@@ -45,7 +45,11 @@ func part2[lines: Array] : void
io.println_i64(sum)
func main[] : i64
lines := must(io.read_text_file?("input.txt")) |> str.split("\n")
~input, ok := io.read_text_file("input.txt")
if !ok
panic("failed to open input.txt")
lines := str.split(input, "\n")
part1(lines)
part2(lines)