summaryrefslogtreecommitdiff
path: root/Day11/app/Main.hs
diff options
context:
space:
mode:
authorAndreas Grois <andi@grois.info>2023-01-06 15:57:45 +0100
committerAndreas Grois <andi@grois.info>2023-01-06 15:57:45 +0100
commita9747a799b31c687f262bc92f390b3aeaac992f2 (patch)
tree96767beaf329e20f1078e5aa8e05bbd5bb797f35 /Day11/app/Main.hs
parent5c56191f800023e97e66a5498f2ed5911ee2973f (diff)
Day 11 with some notes for part2
Diffstat (limited to 'Day11/app/Main.hs')
-rw-r--r--Day11/app/Main.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/Day11/app/Main.hs b/Day11/app/Main.hs
index 9bac5a5..163419e 100644
--- a/Day11/app/Main.hs
+++ b/Day11/app/Main.hs
@@ -218,4 +218,10 @@ monkeyBusiness = mulTwoBusiest . foldl countItemsPerActiveMonkey []
where incrementCountForMonkey :: [(MonkeyId, Int)] -> MonkeyId -> [(MonkeyId, Int)]
incrementCountForMonkey [] mid = [(mid,1)]
incrementCountForMonkey ((m, i):as) mid | m == mid = (m,i+1):as
- incrementCountForMonkey (a:as) mid = a:incrementCountForMonkey as mid \ No newline at end of file
+ incrementCountForMonkey (a:as) mid = a:incrementCountForMonkey as mid
+
+
+-- Part 2... Is a hack. It relies on the fact that all tests done by monkeys are "if foo divisible by bar", and that monkeys can only add and multiply.
+-- For addition this is true: (a%c + b%c)%c = (a+b)%c
+-- For multiplication this is true: ((a%c) * (b%c))%c = (a*b)%c
+-- The hack part is, that the same trick does not work for division... \ No newline at end of file