import gleam/int import gleam/string import simplifile /// Read input for a given day. If example is True, reads from dayXX_example.txt pub fn read_input(day: Int, example: Bool) -> Result(List(String), String) { let day_str = int.to_string(day) |> string.pad_start(2, "0") let suffix = case example { True -> "_example" False -> "" } let path = "input/day" <> day_str <> suffix <> ".txt" case simplifile.read(path) { Ok(content) -> Ok( content |> string.trim |> string.split("\n"), ) Error(e) -> Error("failed to read " <> path <> ": " <> string.inspect(e)) } }