From a9747a799b31c687f262bc92f390b3aeaac992f2 Mon Sep 17 00:00:00 2001 From: Andreas Grois Date: Fri, 6 Jan 2023 15:57:45 +0100 Subject: Day 11 with some notes for part2 --- Day11/app/Main.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3