Skip to content

Commit

Permalink
Moar gleam
Browse files Browse the repository at this point in the history
  • Loading branch information
dalanmiller committed Dec 2, 2024
1 parent 07f34a5 commit 3dd70d5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 2024/gleam.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ version = "1.0.0"

[dependencies]
gleam_stdlib = ">= 0.34.0 and < 2.0.0"
file_streams = ">= 1.2.2 and < 2.0.0"
simplifile = ">= 2.2.0 and < 3.0.0"
gleave = ">= 1.0.0 and < 2.0.0"

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

packages = [
{ name = "file_streams", version = "1.2.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "file_streams", source = "hex", outer_checksum = "E8659E84092A720CB8D737FE6E529B9B7597E92B4B2A70A917E8590FBEAD0AE6" },
{ name = "filepath", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "67A6D15FB39EEB69DD31F8C145BB5A421790581BD6AA14B33D64D5A55DBD6587" },
{ name = "gleam_stdlib", version = "0.45.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "206FCE1A76974AECFC55AEBCD0217D59EDE4E408C016E2CFCCC8FF51278F186E" },
{ name = "gleave", version = "1.0.0", build_tools = ["gleam"], requirements = [], otp_app = "gleave", source = "hex", outer_checksum = "EBEB0DF9C764A6CB22623FF6F03A0BC978D75225303F3BBDEEB705A2DD700D0D" },
{ name = "gleeunit", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "F7A7228925D3EE7D0813C922E062BFD6D7E9310F0BEE585D3A42F3307E3CFD13" },
{ name = "simplifile", version = "2.2.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0DFABEF7DC7A9E2FF4BB27B108034E60C81BEBFCB7AB816B9E7E18ED4503ACD8" },
]

[requirements]
file_streams = { version = ">= 1.2.2 and < 2.0.0" }
gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
gleave = { version = ">= 1.0.0 and < 2.0.0" }
gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
simplifile = { version = ">= 2.2.0 and < 3.0.0" }
22 changes: 22 additions & 0 deletions 2024/src/day1.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import gleam/list
import gleam/io
import gleam/result
import gleam/string
import simplifile
import utils

pub fn part1() {
// use file <- result.try(utils.read_file("day1.input"))

let file = case utils.read_file("day1.input") {
Ok(s) -> s
_ -> "dunno"
}
let lines = string.split(file, "\n")

}

pub fn part2() {
let file = utils.read_file("day2.input")
let lines = string.split(file, "\n")
}
14 changes: 14 additions & 0 deletions 2024/src/utils.gleam
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import gleam/io
import gleave
import simplifile

pub fn read_file(path: String) -> Result(String, String) {
case simplifile.read(path) {
Ok(result) -> Ok(result)
Error(_reason) -> {
io.println_error("Failed to read file!")
gleave.exit(1)
Error("failed")
}
}
}

0 comments on commit 3dd70d5

Please sign in to comment.