From 974210a333247e279236eb0d7eb5b5f8c5e8d35c Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Fri, 2 Dec 2022 11:02:43 -0500 Subject: day 2 revisions --- 2022/day-01/day-01.ipynb | 24 ++------ 2022/day-02/day-02.ipynb | 156 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 115 insertions(+), 65 deletions(-) (limited to '2022') diff --git a/2022/day-01/day-01.ipynb b/2022/day-01/day-01.ipynb index d65785e..c79a3f6 100644 --- a/2022/day-01/day-01.ipynb +++ b/2022/day-01/day-01.ipynb @@ -17,11 +17,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "vscode": { - "languageId": "racket" - } - }, + "metadata": {}, "outputs": [], "source": [ "(require racket\n", @@ -50,11 +46,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "vscode": { - "languageId": "racket" - } - }, + "metadata": {}, "outputs": [ { "data": { @@ -100,11 +92,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "vscode": { - "languageId": "racket" - } - }, + "metadata": {}, "outputs": [ { "data": { @@ -132,15 +120,15 @@ ], "metadata": { "kernelspec": { - "display_name": "Racket (WSL)", + "display_name": "Racket (trusted)", "language": "racket", - "name": "racket" + "name": "racket-trusted" }, "language_info": { "codemirror_mode": "scheme", "file_extension": ".rkt", "mimetype": "text/x-racket", - "name": "Racket", + "name": "racket", "pygments_lexer": "racket", "version": "8.7" }, diff --git a/2022/day-02/day-02.ipynb b/2022/day-02/day-02.ipynb index 1041425..ed080ea 100644 --- a/2022/day-02/day-02.ipynb +++ b/2022/day-02/day-02.ipynb @@ -1,9 +1,27 @@ { "cells": [ { - "cell_type": "code", - "execution_count": 56, + "cell_type": "markdown", "metadata": {}, + "source": [ + "### Advent of Code 2022\n", + "#### Day 2: Rock Paper Scissors\n", + "\n", + "You've given a strategy guide for how to win at a Rock Paper Scissors tournament. The first column is what your opponent will throw. Your score is determined by the result (win, lose, draw) of each round and what you played (rock, paper, scissors).\n", + "\n", + "**Part 1.** What's your tournament score if the second column represents what you should play in each round?\n", + "\n", + "**Part 2.** What's your tournament score if the second column represents the result of each round?" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "vscode": { + "languageId": "racket" + } + }, "outputs": [], "source": [ "(require racket\n", @@ -11,32 +29,71 @@ " threading)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The input for this problem is a list with two columns; the first column is one of the characters `A`, `B`, `C` and the second column is `X`, `Y` or `Z`." + ] + }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 46, + "metadata": { + "vscode": { + "languageId": "racket" + } + }, + "outputs": [], + "source": [ + "(define strategy-guide (~> (fetch-aoc-input (find-session) 2022 2) (string-split \"\\n\")))" + ] + }, + { + "cell_type": "markdown", "metadata": {}, + "source": [ + "##### Part 1\n", + "We're given the bonus for a round result and the bonus for the selected throw, and we write a function that determines the result for a given round." + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "vscode": { + "languageId": "racket" + } + }, "outputs": [], "source": [ - "(define strategy-guide-raw (~> (fetch-aoc-input (find-session) 2022 2) (string-split \"\\n\")))\n", - "\n", - "(define translation-part-1\n", - " (hash \"A\" 'rock \"B\" 'paper \"C\" 'scissors \"X\" 'rock \"Y\" 'paper \"Z\" 'scissors))\n", - "\n", "(define score-bonus (hash 'rock 1 'paper 2 'scissors 3 'win 6 'draw 3 'lose 0))\n", "\n", - "(define (naive-play them me)\n", - " (match* ((hash-ref translation-part-1 them) (hash-ref translation-part-1 me))\n", - " [(x x) (+ 3 (hash-ref score-bonus x))]\n", - " [('rock (and x 'paper)) (+ 6 (hash-ref score-bonus x))]\n", - " [('paper (and x 'scissors)) (+ 6 (hash-ref score-bonus x))]\n", - " [('scissors (and x 'rock)) (+ 6 (hash-ref score-bonus x))]\n", - " [(_ x) (hash-ref score-bonus x)]))\n" + "(define winning-rounds '((rock . paper) (paper . scissors) (scissors . rock)))\n", + "(define losing-rounds '((rock . scissors) (paper . rock) (scissors . paper)))\n", + "\n", + "(define (outcome them me)\n", + " (match (cons them me)\n", + " [(cons x x) 'draw]\n", + " [winner #:when (member winner winning-rounds) 'win]\n", + " [_ 'lose]))\n" ] }, { - "cell_type": "code", - "execution_count": 58, + "cell_type": "markdown", "metadata": {}, + "source": [ + "In part 1, we assume that the second column refers to the throw we should select in each round." + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "vscode": { + "languageId": "racket" + } + }, "outputs": [ { "data": { @@ -47,25 +104,37 @@ "13809" ] }, - "execution_count": 58, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ + "(define assume-throw (hash \"A\" 'rock \"B\" 'paper \"C\" 'scissors \"X\" 'rock \"Y\" 'paper \"Z\" 'scissors))\n", "\n", - "(define trust-the-guide\n", - " (for/sum ([play (in-list strategy-guide-raw)])\n", - " (match-define (list them me) (string-split play))\n", - " (naive-play them me)))\n", - "\n", - "trust-the-guide\n" + "(for/sum\n", + " ([play (in-list strategy-guide)])\n", + " (match-define (list (app (curry hash-ref assume-throw) them) (app (curry hash-ref assume-throw) me))\n", + " (string-split play))\n", + " (+ (hash-ref score-bonus (outcome them me)) (hash-ref score-bonus me)))\n" ] }, { - "cell_type": "code", - "execution_count": 59, + "cell_type": "markdown", "metadata": {}, + "source": [ + "### Part 2\n", + "Now we're told that the second column actually represents the round result: `X` is lose, `Y` is draw, `Z` is win. We can use pattern matching to look up what we should throw in response for each round, and then calculate the score from that." + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": { + "vscode": { + "languageId": "racket" + } + }, "outputs": [ { "data": { @@ -76,38 +145,31 @@ "12316" ] }, - "execution_count": 59, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "(define translation-part-2 (hash \"A\" 'rock \"B\" 'paper \"C\" 'scissors \"X\" 'lose \"Y\" 'draw \"Z\" 'win))\n", - "\n", - "(define (skilled-play them me)\n", - " (match* ((hash-ref translation-part-2 them) (hash-ref translation-part-2 me))\n", - " [('rock 'win) 8]\n", - " [('rock 'draw) 4]\n", - " [('rock 'lose) 3]\n", - " [('paper 'win) 9]\n", - " [('paper 'draw) 5]\n", - " [('paper 'lose) 1]\n", - " [('scissors 'win) 7]\n", - " [('scissors 'draw) 6]\n", - " [('scissors 'lose) 2]))\n", + "(define assume-result (hash \"A\" 'rock \"B\" 'paper \"C\" 'scissors \"X\" 'lose \"Y\" 'draw \"Z\" 'win))\n", "\n", - "(define new-understanding\n", - " (for/sum ([play (in-list strategy-guide-raw)])\n", - " (match-define (list them me) (string-split play))\n", - " (skilled-play them me)))\n", + "(define (pick-throw them result)\n", + "(match* (them result)\n", + "[(x 'draw) x]\n", + "[(x 'win) (dict-ref winning-rounds x)]\n", + "[(x 'lose) (dict-ref losing-rounds x)]))\n", "\n", - "new-understanding\n" + "(for/sum ([play (in-list strategy-guide)])\n", + " (match-define (list (app (curry hash-ref assume-result) them)\n", + " (app (curry hash-ref assume-result) result))\n", + " (string-split play))\n", + " (+ (hash-ref score-bonus result) (hash-ref score-bonus (pick-throw them result))))\n" ] } ], "metadata": { "kernelspec": { - "display_name": "Racket (Trusted)", + "display_name": "Racket (trusted)", "language": "racket", "name": "racket-trusted" }, @@ -115,7 +177,7 @@ "codemirror_mode": "scheme", "file_extension": ".rkt", "mimetype": "text/x-racket", - "name": "racket", + "name": "Racket", "pygments_lexer": "racket", "version": "8.7" }, -- cgit v1.2.3 From 5c9874e467ad94d76909c06309b4936e393b5122 Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Fri, 2 Dec 2022 11:38:59 -0500 Subject: day 2 final cleanup --- 2022/day-02/day-02.ipynb | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) (limited to '2022') diff --git a/2022/day-02/day-02.ipynb b/2022/day-02/day-02.ipynb index ed080ea..c308201 100644 --- a/2022/day-02/day-02.ipynb +++ b/2022/day-02/day-02.ipynb @@ -11,12 +11,14 @@ "\n", "**Part 1.** What's your tournament score if the second column represents what you should play in each round?\n", "\n", - "**Part 2.** What's your tournament score if the second column represents the result of each round?" + "**Part 2.** What's your tournament score if the second column represents the result of each round?\n", + "\n", + "For this solution, I'm using `rackjure` since I'm planning on using a bunch of dictionaries, and `rackjure`'s shorthand makes them easier to work with." ] }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 7, "metadata": { "vscode": { "languageId": "racket" @@ -24,21 +26,20 @@ }, "outputs": [], "source": [ - "(require racket\n", - " advent-of-code\n", - " threading)" + "#lang iracket/lang #:require rackjure\n", + "(require advent-of-code)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "The input for this problem is a list with two columns; the first column is one of the characters `A`, `B`, `C` and the second column is `X`, `Y` or `Z`." + "The input for this problem is a list with two columns; the first column is one of the characters `A`, `B` or `C` (corresponding to the opponent's throw of rock, paper or scissors) and the second column is `X`, `Y` or `Z`, whose meaning is currently unknown." ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 8, "metadata": { "vscode": { "languageId": "racket" @@ -46,20 +47,20 @@ }, "outputs": [], "source": [ - "(define strategy-guide (~> (fetch-aoc-input (find-session) 2022 2) (string-split \"\\n\")))" + "(define strategy-guide (~> (fetch-aoc-input (find-session) 2022 2) (string-split \"\\n\")))\n", + "(define opponent-throw {\"A\" 'rock \"B\" 'paper \"C\" 'scissors})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "##### Part 1\n", - "We're given the bonus for a round result and the bonus for the selected throw, and we write a function that determines the result for a given round." + "We're also given the score for a round result and the bonus for the selected throw, and we write a function that determines the result for a given round." ] }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 9, "metadata": { "vscode": { "languageId": "racket" @@ -67,15 +68,15 @@ }, "outputs": [], "source": [ - "(define score-bonus (hash 'rock 1 'paper 2 'scissors 3 'win 6 'draw 3 'lose 0))\n", + "(define score-bonus {'rock 1 'paper 2 'scissors 3 'win 6 'draw 3 'lose 0})\n", "\n", - "(define winning-rounds '((rock . paper) (paper . scissors) (scissors . rock)))\n", - "(define losing-rounds '((rock . scissors) (paper . rock) (scissors . paper)))\n", + "(define winning-rounds {'rock 'paper 'paper 'scissors 'scissors 'rock})\n", + "(define losing-rounds {'rock 'scissors 'paper 'rock 'scissors 'paper})\n", "\n", "(define (outcome them me)\n", " (match (cons them me)\n", " [(cons x x) 'draw]\n", - " [winner #:when (member winner winning-rounds) 'win]\n", + " [(cons x y) #:when (eq? y (winning-rounds x)) 'win]\n", " [_ 'lose]))\n" ] }, @@ -83,12 +84,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In part 1, we assume that the second column refers to the throw we should select in each round." + "##### Part 1\n", + "\n", + "In part 1, we assume that the second column refers to the throw we should select in each round. We add that to our existing dictionary and write a `for` comprehension to calculate each round result." ] }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 10, "metadata": { "vscode": { "languageId": "racket" @@ -104,19 +107,18 @@ "13809" ] }, - "execution_count": 48, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "(define assume-throw (hash \"A\" 'rock \"B\" 'paper \"C\" 'scissors \"X\" 'rock \"Y\" 'paper \"Z\" 'scissors))\n", + "(define assume-throw (dict-merge opponent-throw {\"X\" 'rock \"Y\" 'paper \"Z\" 'scissors}))\n", "\n", - "(for/sum\n", - " ([play (in-list strategy-guide)])\n", - " (match-define (list (app (curry hash-ref assume-throw) them) (app (curry hash-ref assume-throw) me))\n", - " (string-split play))\n", - " (+ (hash-ref score-bonus (outcome them me)) (hash-ref score-bonus me)))\n" + "(for/sum ([play (in-list strategy-guide)])\n", + " (match-define (list them me) (string-split play))\n", + " (+ (score-bonus (outcome (assume-throw them) (assume-throw me)))\n", + " (score-bonus (assume-throw me))))\n" ] }, { @@ -124,12 +126,12 @@ "metadata": {}, "source": [ "### Part 2\n", - "Now we're told that the second column actually represents the round result: `X` is lose, `Y` is draw, `Z` is win. We can use pattern matching to look up what we should throw in response for each round, and then calculate the score from that." + "Now we're told that the second column actually represents the round result: `X` is lose, `Y` is draw, `Z` is win. We can look up what we should throw in response for each round, and then calculate the score from that." ] }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 11, "metadata": { "vscode": { "languageId": "racket" @@ -145,25 +147,23 @@ "12316" ] }, - "execution_count": 49, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "(define assume-result (hash \"A\" 'rock \"B\" 'paper \"C\" 'scissors \"X\" 'lose \"Y\" 'draw \"Z\" 'win))\n", - "\n", + "(define assume-result (dict-merge opponent-throw {\"X\" 'lose \"Y\" 'draw \"Z\" 'win}))\n", "(define (pick-throw them result)\n", - "(match* (them result)\n", - "[(x 'draw) x]\n", - "[(x 'win) (dict-ref winning-rounds x)]\n", - "[(x 'lose) (dict-ref losing-rounds x)]))\n", + " (match* (them result)\n", + " [(x 'draw) x]\n", + " [(x 'win) (winning-rounds x)]\n", + " [(x 'lose) (losing-rounds x)]))\n", "\n", "(for/sum ([play (in-list strategy-guide)])\n", - " (match-define (list (app (curry hash-ref assume-result) them)\n", - " (app (curry hash-ref assume-result) result))\n", - " (string-split play))\n", - " (+ (hash-ref score-bonus result) (hash-ref score-bonus (pick-throw them result))))\n" + " (match-define (list them result) (string-split play))\n", + " (+ (score-bonus (assume-result result))\n", + " (score-bonus (pick-throw (assume-result them) (assume-result result)))))\n" ] } ], -- cgit v1.2.3 From 3b19a598d9c5e4e45289438f18174ae7dee190fb Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Fri, 2 Dec 2022 11:43:49 -0500 Subject: day 2 markdown fix --- 2022/day-02/day-02.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '2022') diff --git a/2022/day-02/day-02.ipynb b/2022/day-02/day-02.ipynb index c308201..4423c55 100644 --- a/2022/day-02/day-02.ipynb +++ b/2022/day-02/day-02.ipynb @@ -125,7 +125,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Part 2\n", + "##### Part 2\n", "Now we're told that the second column actually represents the round result: `X` is lose, `Y` is draw, `Z` is win. We can look up what we should throw in response for each round, and then calculate the score from that." ] }, -- cgit v1.2.3 From c3d257ba97ffbee320c8fbdc9a90bf2a5e859d61 Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Fri, 2 Dec 2022 11:44:47 -0500 Subject: day 2 markdown fixes --- 2022/day-02/day-02.ipynb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to '2022') diff --git a/2022/day-02/day-02.ipynb b/2022/day-02/day-02.ipynb index 4423c55..715f14b 100644 --- a/2022/day-02/day-02.ipynb +++ b/2022/day-02/day-02.ipynb @@ -76,8 +76,10 @@ "(define (outcome them me)\n", " (match (cons them me)\n", " [(cons x x) 'draw]\n", - " [(cons x y) #:when (eq? y (winning-rounds x)) 'win]\n", - " [_ 'lose]))\n" + " [(cons x y)\n", + " #:when (eq? y (winning-rounds x))\n", + " 'win]\n", + " [_ 'lose]))" ] }, { @@ -118,7 +120,7 @@ "(for/sum ([play (in-list strategy-guide)])\n", " (match-define (list them me) (string-split play))\n", " (+ (score-bonus (outcome (assume-throw them) (assume-throw me)))\n", - " (score-bonus (assume-throw me))))\n" + " (score-bonus (assume-throw me))))" ] }, { @@ -163,7 +165,7 @@ "(for/sum ([play (in-list strategy-guide)])\n", " (match-define (list them result) (string-split play))\n", " (+ (score-bonus (assume-result result))\n", - " (score-bonus (pick-throw (assume-result them) (assume-result result)))))\n" + " (score-bonus (pick-throw (assume-result them) (assume-result result)))))" ] } ], -- cgit v1.2.3 From 36e7a9cc09221990f8ee69d0ad0885ff07ebaeef Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Fri, 2 Dec 2022 11:47:50 -0500 Subject: day 2 markdown fixes --- 2022/day-02/day-02.ipynb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to '2022') diff --git a/2022/day-02/day-02.ipynb b/2022/day-02/day-02.ipynb index 715f14b..d9dcd72 100644 --- a/2022/day-02/day-02.ipynb +++ b/2022/day-02/day-02.ipynb @@ -74,11 +74,9 @@ "(define losing-rounds {'rock 'scissors 'paper 'rock 'scissors 'paper})\n", "\n", "(define (outcome them me)\n", - " (match (cons them me)\n", - " [(cons x x) 'draw]\n", - " [(cons x y)\n", - " #:when (eq? y (winning-rounds x))\n", - " 'win]\n", + " (match* (them me)\n", + " [(x x) 'draw]\n", + " [(x y) #:when (eq? y (winning-rounds x)) 'win]\n", " [_ 'lose]))" ] }, -- cgit v1.2.3 From 9ab985aca36a98b446bf6fed1d26764b0d327c70 Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Fri, 2 Dec 2022 11:50:09 -0500 Subject: day 2 markdown fixes --- 2022/day-02/day-02.ipynb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to '2022') diff --git a/2022/day-02/day-02.ipynb b/2022/day-02/day-02.ipynb index d9dcd72..13b9986 100644 --- a/2022/day-02/day-02.ipynb +++ b/2022/day-02/day-02.ipynb @@ -18,7 +18,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 1, "metadata": { "vscode": { "languageId": "racket" @@ -39,7 +39,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "metadata": { "vscode": { "languageId": "racket" @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 3, "metadata": { "vscode": { "languageId": "racket" @@ -77,7 +77,7 @@ " (match* (them me)\n", " [(x x) 'draw]\n", " [(x y) #:when (eq? y (winning-rounds x)) 'win]\n", - " [_ 'lose]))" + " [(_ _) 'lose]))" ] }, { @@ -91,7 +91,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "metadata": { "vscode": { "languageId": "racket" @@ -107,7 +107,7 @@ "13809" ] }, - "execution_count": 10, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 5, "metadata": { "vscode": { "languageId": "racket" @@ -147,7 +147,7 @@ "12316" ] }, - "execution_count": 11, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } -- cgit v1.2.3 From 3d979e5bcc7808d231f4749e810382abfb57a831 Mon Sep 17 00:00:00 2001 From: Hunky Jimpjorps Date: Fri, 2 Dec 2022 16:19:50 -0500 Subject: day 2 in Prolog --- 2022/day-02/day-02.pl | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 2022/day-02/day-02.pl (limited to '2022') diff --git a/2022/day-02/day-02.pl b/2022/day-02/day-02.pl new file mode 100644 index 0000000..6561ea5 --- /dev/null +++ b/2022/day-02/day-02.pl @@ -0,0 +1,67 @@ +:- use_module(library(yall)). +:- use_module(library(apply)). + +% Facts + +game(X, X, draw). +game(rock, scissors, win). +game(scissors, paper, win). +game(paper, rock, win). +game(rock, paper, lose). +game(scissors, rock, lose). +game(paper, scissors, lose). + +opponent_move("A", rock). +opponent_move("B", paper). +opponent_move("C", scissors). + +assume_move("X", rock). +assume_move("Y", paper). +assume_move("Z", scissors). + +assume_outcome("X", lose). +assume_outcome("Y", draw). +assume_outcome("Z", win). + +bonus(rock, 1). +bonus(paper, 2). +bonus(scissors, 3). +bonus(lose, 0). +bonus(draw, 3). +bonus(win, 6). + +% Predicates + +get_data(Result) :- + setup_call_cleanup(open("2022/day-02/input", read, In), + (read_string(In, _, Str), + split_string(Str, "\n", "\s\t\n", Lines), + maplist([In, Out] >> split_string(In, "\s", "", Out), Lines, Result)), + close(In)). + +score_game(MyMove, Result, Score) :- + bonus(Result, X), + bonus(MyMove, Y), + Score is X + Y. + +part_1_score([Them, Me], Score) :- + opponent_move(Them, TheirMove), + assume_move(Me, MyMove), + game(MyMove, TheirMove, Result), + score_game(MyMove, Result, Score). + +part_1_total(Total) :- + get_data(Games), + maplist(part_1_score, Games, Scores), + sum_list(Scores, Total). + +part_2_score([Them, Outcome], Score) :- + opponent_move(Them, TheirMove), + assume_outcome(Outcome, Result), + game(MyMove, TheirMove, Result), + score_game(MyMove, Result, Score). + +part_2_total(Total) :- + get_data(Games), + maplist(part_2_score, Games, Scores), + sum_list(Scores, Total). \ No newline at end of file -- cgit v1.2.3