diff options
author | Hunky Jimpjorps <thechairman@thechairman.info> | 2022-12-01 08:57:41 -0500 |
---|---|---|
committer | Hunky Jimpjorps <thechairman@thechairman.info> | 2022-12-01 08:57:41 -0500 |
commit | 02d222719eb63e1c301a5eacca07e94d8d676d84 (patch) | |
tree | 1a15208742b1e4ed0937544e23ee0416aefa8f66 /2022/day-01 | |
parent | 92bb2cb2ea5c3f75ce1fdefafdf44e9f3cece6d8 (diff) | |
download | gleam_aoc-02d222719eb63e1c301a5eacca07e94d8d676d84.tar.gz gleam_aoc-02d222719eb63e1c301a5eacca07e94d8d676d84.zip |
day 1 complete
Diffstat (limited to '2022/day-01')
-rw-r--r-- | 2022/day-01/day-01.ipynb | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/2022/day-01/day-01.ipynb b/2022/day-01/day-01.ipynb index b585757..59be327 100644 --- a/2022/day-01/day-01.ipynb +++ b/2022/day-01/day-01.ipynb @@ -4,18 +4,19 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Advent of Code 2020\n", + "### Advent of Code 2022\n", "#### Day 1: Calorie Counting\n", "\n", "Elves carry various amounts of food with various caloric contents.\n", "\n", "**Part 1.** How many calories is the elf with the most calories of food carrying?\n", + "\n", "**Part 2.** How many calories are the three elves with the most calories of food carrying?" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "metadata": { "vscode": { "languageId": "racket" @@ -37,9 +38,9 @@ "The data file is a list of integers, one on each line, with an empty line separating the inventory of each elf.\n", "\n", "1. Fetch the input file,\n", - "2. split it on double newlines,\n", - "3. split each list member on single newlines,\n", - "4. convert each sublist member to a number,\n", + "2. split it on double newlines to find each elf's inventory,\n", + "3. split each inventory on single newlines,\n", + "4. convert each inventory member to a number,\n", "5. sum up each list, and\n", "6. find the maximum one. \n", "\n", @@ -48,7 +49,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 9, "metadata": { "vscode": { "languageId": "racket" @@ -64,7 +65,7 @@ "70374" ] }, - "execution_count": 13, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -72,10 +73,10 @@ "source": [ "(define calorie-data (fetch-aoc-input (find-session) 2022 1))\n", "\n", - "(~> calorie-data\n", - " (string-split \"\\n\\n\")\n", - " (map (λ~> string-split (map string->number _) (apply + _)) _)\n", - " (apply max _))" + "(~>> calorie-data\n", + " (string-split _ \"\\n\\n\")\n", + " (map (λ~>> string-split (map string->number) (apply +)))\n", + " (apply max))\n" ] }, { @@ -98,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 7, "metadata": { "vscode": { "languageId": "racket" @@ -114,18 +115,18 @@ "204610" ] }, - "execution_count": 14, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "(~> calorie-data\n", - " (string-split \"\\n\\n\")\n", - " (map (λ~> string-split (map string->number _) (apply + _)) _)\n", - " (sort _ >)\n", - " (take 3)\n", - " (apply + _))\n" + "(~>> calorie-data\n", + " (string-split _ \"\\n\\n\")\n", + " (map (λ~>> string-split (map string->number) (apply +)))\n", + " (sort _ >)\n", + " (take _ 3)\n", + " (apply +))\n" ] } ], |