Skip to content

Commit

Permalink
restructure repo
Browse files Browse the repository at this point in the history
  • Loading branch information
sreedevk committed Dec 6, 2024
1 parent 8dac45d commit 1955b47
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 74 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Advent Of Code 2024

```sh
gleam run
# Run Tests Against all solutions (example inputs used)
gleam test

# Run the solution against actual input for a particular day
gleam run <day>
```
1 change: 1 addition & 0 deletions gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ simplifile = ">= 2.2.0 and < 3.0.0"
gleam_regexp = ">= 1.0.0 and < 2.0.0"
gleam_yielder = ">= 1.1.0 and < 2.0.0"
gleam_otp = ">= 0.14.1 and < 1.0.0"
argv = ">= 1.0.2 and < 2.0.0"

[dev-dependencies]
gleeunit = ">= 1.0.0 and < 2.0.0"
2 changes: 2 additions & 0 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# You typically do not need to edit this file

packages = [
{ name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
{ name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" },
{ name = "gleam_erlang", version = "0.33.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "A1D26B80F01901B59AABEE3475DD4C18D27D58FA5C897D922FCB9B099749C064" },
{ name = "gleam_otp", version = "0.14.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "5A8CE8DBD01C29403390A7BD5C0A63D26F865C83173CF9708E6E827E53159C65" },
Expand All @@ -13,6 +14,7 @@ packages = [
]

[requirements]
argv = { version = ">= 1.0.2 and < 2.0.0" }
gleam_otp = { version = ">= 0.14.1 and < 1.0.0" }
gleam_regexp = { version = ">= 1.0.0 and < 2.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
Expand Down
155 changes: 82 additions & 73 deletions src/advent_of_code.gleam
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import argv
import ceres_search as day04
import gleam/int
import gleam/io
Expand All @@ -10,83 +11,91 @@ import red_nosed_reports as day02
import simplifile.{read}

pub fn main() {
// Day 01
result.unwrap(
result.map(read("data/day1.txt"), fn(data) {
io.println(
"[1] Historian Hysteria (Part 1): "
<> int.to_string(day01.solve_a(data)),
case argv.load().arguments {
["1"] -> {
result.unwrap(
result.map(read("data/day1.txt"), fn(data) {
io.println(
"[1] Historian Hysteria (Part 1): "
<> int.to_string(day01.solve_a(data)),
)
io.println(
"[1] Historian Hysteria (Part 2): "
<> int.to_string(day01.solve_b(data)),
)
}),
Nil,
)
io.println(
"[1] Historian Hysteria (Part 2): "
<> int.to_string(day01.solve_b(data)),
}
["2"] -> {
result.unwrap(
result.map(read("data/day2.txt"), fn(data) {
io.println(
"[2] Red Nosed Reports (Part 1): "
<> int.to_string(day02.solve_a(data)),
)
io.println(
"[2] Red Nosed Reports (Part 2): "
<> int.to_string(day02.solve_b(data)),
)
}),
Nil,
)
}),
Nil,
)

// Day 02
result.unwrap(
result.map(read("data/day2.txt"), fn(data) {
io.println(
"[2] Red Nosed Reports (Part 1): " <> int.to_string(day02.solve_a(data)),
)
io.println(
"[2] Red Nosed Reports (Part 2): " <> int.to_string(day02.solve_b(data)),
)
}),
Nil,
)

// Day 03
result.unwrap(
result.map(read("data/day3.txt"), fn(data) {
io.println(
"[3] Mull It Over (Part 1): " <> int.to_string(day03.solve_a(data)),
)
io.println(
"[3] Mull It Over (Part 2): " <> int.to_string(day03.solve_b(data)),
}
["3"] -> {
result.unwrap(
result.map(read("data/day3.txt"), fn(data) {
io.println(
"[3] Mull It Over (Part 1): " <> int.to_string(day03.solve_a(data)),
)
io.println(
"[3] Mull It Over (Part 2): " <> int.to_string(day03.solve_b(data)),
)
}),
Nil,
)
}),
Nil,
)

// Day 04
result.unwrap(
result.map(read("data/day4.txt"), fn(data) {
io.println(
"[4] Ceres Search (Part 1): " <> int.to_string(day04.solve_a(data)),
}
["4"] -> {
result.unwrap(
result.map(read("data/day4.txt"), fn(data) {
io.println(
"[4] Ceres Search (Part 1): " <> int.to_string(day04.solve_a(data)),
)
io.println(
"[4] Ceres Search (Part 2): " <> int.to_string(day04.solve_b(data)),
)
}),
Nil,
)
io.println(
"[4] Ceres Search (Part 2): " <> int.to_string(day04.solve_b(data)),
)
}),
Nil,
)

// Day 05
result.unwrap(
result.map(read("data/day5.txt"), fn(data) {
io.println(
"[5] Print Queue (Part 1): " <> int.to_string(day05.solve_a(data)),
)
io.println(
"[5] Print Queue (Part 2): " <> int.to_string(day05.solve_b(data)),
)
}),
Nil,
)

// Day 06
result.unwrap(
result.map(read("data/day6.txt"), fn(data) {
io.println(
"[6] Guard Gallivant (Part 1): " <> int.to_string(day06.solve_a(data)),
}
["5"] -> {
result.unwrap(
result.map(read("data/day5.txt"), fn(data) {
io.println(
"[5] Print Queue (Part 1): " <> int.to_string(day05.solve_a(data)),
)
io.println(
"[5] Print Queue (Part 2): " <> int.to_string(day05.solve_b(data)),
)
}),
Nil,
)
io.println(
"[6] Guard Gallivant (Part 2): " <> int.to_string(day06.solve_b(data)),
}
["6"] -> {
result.unwrap(
result.map(read("data/day6.txt"), fn(data) {
io.println(
"[6] Guard Gallivant (Part 1): "
<> int.to_string(day06.solve_a(data)),
)
io.println(
"[6] Guard Gallivant (Part 2): "
<> int.to_string(day06.solve_b(data)),
)
}),
Nil,
)
}),
Nil,
)
}
_ -> io.println_error("invalid arguments!")
}
}

0 comments on commit 1955b47

Please sign in to comment.