···11+# Advent of Code 2024 - Gleam
22+33+My take at the 2024 advent of code in the [Gleam](https://github.com/gleam-lang/gleam) programming language
44+55+## Requirements
66+- Gleam
77+88+## Usage
99+1010+Put your AOC inputs into an `inputs` folder at the `pwd` of the program.
1111+1212+The file must be named following the syntax `day{number}.txt` where `{number}` should be replaced by the day number, ie : `day7.txt` `day24.txt`
1313+1414+```bash
1515+$ gleam run
1616+What day do you wanna run ?
1717+# Enter the day you wanna run in the prompt
1818+```
1919+2020+## Extending
2121+There is an `src/days/day.gleam` file that exist, this file is used as a template for all other day files.
2222+2323+After greating a file, for example `day10.gleam`, you must add it to the `src/aoc.gleam` in the case statement, for it to be launchable with the CLI.
+16
gleam.toml
···11+name = "aoc"
22+author = "Evann (Estym) Regnault"
33+version = "1.0.0"
44+55+[dependencies]
66+simplifile = ">= 2.2.0 and < 3.0.0"
77+gleam_erlang = ">= 0.27.0 and < 1.0.0"
88+gleam_stdlib = ">= 0.40.0 and < 1.0.0"
99+nibble = ">= 1.1.1 and < 2.0.0"
1010+gleam_otp = ">= 0.12.1 and < 1.0.0"
1111+birl = ">= 1.7.1 and < 2.0.0"
1212+gleam_regexp = ">= 1.0.0 and < 2.0.0"
1313+1414+[dev-dependencies]
1515+gleeunit = ">= 1.0.0 and < 2.0.0"
1616+
+25
manifest.toml
···11+# This file was generated by Gleam
22+# You typically do not need to edit this file
33+44+packages = [
55+ { name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" },
66+ { name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" },
77+ { name = "gleam_erlang", version = "0.32.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "B18643083A0117AC5CFD0C1AEEBE5469071895ECFA426DCC26517A07F6AD9948" },
88+ { name = "gleam_otp", version = "0.14.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "5A8CE8DBD01C29403390A7BD5C0A63D26F865C83173CF9708E6E827E53159C65" },
99+ { name = "gleam_regexp", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_regexp", source = "hex", outer_checksum = "A3655FDD288571E90EE9C4009B719FEF59FA16AFCDF3952A76A125AF23CF1592" },
1010+ { name = "gleam_stdlib", version = "0.45.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "206FCE1A76974AECFC55AEBCD0217D59EDE4E408C016E2CFCCC8FF51278F186E" },
1111+ { name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
1212+ { name = "nibble", version = "1.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "nibble", source = "hex", outer_checksum = "67C6BEBC1AB6D771AB893B4A7B3E66C92668C6E7774C335FEFCD545B06435FE5" },
1313+ { name = "ranger", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "B8F3AFF23A3A5B5D9526B8D18E7C43A7DFD3902B151B97EC65397FE29192B695" },
1414+ { name = "simplifile", version = "2.2.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0DFABEF7DC7A9E2FF4BB27B108034E60C81BEBFCB7AB816B9E7E18ED4503ACD8" },
1515+]
1616+1717+[requirements]
1818+birl = { version = ">= 1.7.1 and < 2.0.0" }
1919+gleam_erlang = { version = ">= 0.27.0 and < 1.0.0" }
2020+gleam_otp = { version = ">= 0.12.1 and < 1.0.0" }
2121+gleam_regexp = { version = ">= 1.0.0 and < 2.0.0" }
2222+gleam_stdlib = { version = ">= 0.40.0 and < 1.0.0" }
2323+gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
2424+nibble = { version = ">= 1.1.1 and < 2.0.0" }
2525+simplifile = { version = ">= 2.2.0 and < 3.0.0" }
+28
src/aoc.gleam
···11+import birl
22+import birl/duration
33+import gleam/erlang
44+import gleam/int
55+import gleam/io
66+import gleam/result
77+import gleam/string
88+99+pub fn main() {
1010+ erlang.get_line("What day do you wanna run ? ")
1111+ |> result.unwrap("")
1212+ |> string.trim()
1313+ |> int.parse()
1414+ |> result.unwrap(0)
1515+ |> run_day()
1616+}
1717+1818+pub fn run_day(day: Int) {
1919+ let start = birl.now()
2020+ case day {
2121+ 0 -> io.println_error("Invalid day")
2222+ _ -> io.println("Tried to run day " <> int.to_string(day))
2323+ }
2424+ birl.now()
2525+ |> birl.difference(start)
2626+ |> duration.accurate_decompose
2727+ |> io.debug
2828+}