From 75bfee1677c35fb4cf06c4ba67af18408b316d05 Mon Sep 17 00:00:00 2001 From: Dallin Urness Date: Fri, 20 Dec 2024 13:36:23 -0700 Subject: [PATCH] day19 --- .../communitySolutions/19/dalurness.md | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 src/content/communitySolutions/19/dalurness.md diff --git a/src/content/communitySolutions/19/dalurness.md b/src/content/communitySolutions/19/dalurness.md new file mode 100644 index 0000000..c448aa7 --- /dev/null +++ b/src/content/communitySolutions/19/dalurness.md @@ -0,0 +1,156 @@ +--- +descriptions: ["gleam"] +--- + +### 2024 Solution Gleam + +#### Output + +``` +Liam: NICE +Emma: NICE +Noah: NICE +Olivia: NICE +Sophia: NICE +Jackson: NICE +Ava: NAUGHTY +Aiden: NAUGHTY +Isabella: NICE +Lucas: NICE +Mia: NICE +Caden: NICE +Charlotte: NAUGHTY +Grayson: NICE +Amelia: NICE +Muhammad: NICE +Harper: NICE +Mason: NICE +Evelyn: NICE +Elijah: NAUGHTY +Abigail: NICE +Oliver: NICE +Emily: NAUGHTY +Jacob: NAUGHTY +Elizabeth: NAUGHTY +Michael: NICE +Mila: NAUGHTY +Alexander: NICE +Ella: NICE +William: NICE +Sofia: NICE +James: NICE +Camila: NICE +Benjamin: NICE +Avery: NAUGHTY +Henry: NICE +Scarlett: NAUGHTY +Daniel: NAUGHTY +Victoria: NICE +Matthew: NAUGHTY +Luna: NAUGHTY +Jackson: NICE +Grace: NICE +Logan: NICE +Chloe: NAUGHTY +Sebastian: NICE +Penelope: NAUGHTY +Levi: NICE +Layla: NICE +Mateo: NICE +Riley: NICE +David: NICE +Zoey: NICE +Samuel: NICE +Nora: NICE +Joseph: NICE +Lily: NICE +John: NICE +Eleanor: NICE +Henry: NICE +Hannah: NICE +Owen: NICE +Lillian: NAUGHTY +Jack: NAUGHTY +Addison: NAUGHTY +Wyatt: NICE +Aubrey: NAUGHTY +Luke: NAUGHTY +Ellie: NICE +Jayden: NICE +Stella: NAUGHTY +Dylan: NAUGHTY +Natalie: NAUGHTY +Nicholas: NICE +Zoe: NICE +Isaac: NICE +Leah: NICE +Olivia: NICE +Hazel: NICE +Charlie: NAUGHTY +Violet: NICE +Gabriel: NICE +Aurora: NICE +Julian: NICE +Savannah: NICE +Caleb: NAUGHTY +Audrey: NAUGHTY +Daniel: NICE +Brooklyn: NAUGHTY +Ryan: NAUGHTY +Claire: NICE +Tyler: NICE +Bella: NICE +William: NICE +Lucy: NICE +Zachary: NICE +Anna: NICE +Nathan: NICE +Samantha: NICE +Thomas: NICE +Genesis: NICE +Peter: NICE +Maya: NICE +Eli: NICE +Lily: NICE +Mateo: NICE +Emilia: NICE +Isaiah: NICE +Valentina: NICE +Anthony: NAUGHTY +Josephine: NICE +Joshua: NAUGHTY +Nova: NICE +Christopher: NICE +Naomi: NICE +Andrew: NAUGHTY +Madison: NICE +``` + +```gleam +import gleam/int +import gleam/io +import gleam/list +import gleam/string +import simplifile + +pub fn main() { + let filename = "bin.txt" + case simplifile.read(filename) { + Ok(file_contents) -> file_contents + Error(_) -> { + io.println("failed to read file: " <> filename) + panic as "failed to read file" + } + } + |> string.split("") + |> list.sized_chunk(8) + |> list.map(fn(l) { + let joined_str = string.join(l, "") + let assert Ok(int_val) = int.base_parse(joined_str, 2) + let assert Ok(cp) = string.utf_codepoint(int_val) + cp + }) + |> string.from_utf_codepoints + |> io.println +} +```