summaryrefslogtreecommitdiff
path: root/2022/day11
diff options
context:
space:
mode:
authornekineki <nekineki@nekineki.net>2022-12-11 14:47:27 +0100
committernekineki <nekineki@nekineki.net>2022-12-11 14:50:32 +0100
commitfe75c10e350743a1c078f065d69556fecf825ca5 (patch)
tree956556a564c9329346dc9d8b1535dc5e365f3d55 /2022/day11
parenta74d2dc54aef546664bcc8c81eb8e01a93e94391 (diff)
move files around, update paths
Diffstat (limited to '2022/day11')
-rwxr-xr-x2022/day11/asd.py82
-rw-r--r--2022/day11/pzl.txt55
-rw-r--r--2022/day11/ref.txt27
3 files changed, 0 insertions, 164 deletions
diff --git a/2022/day11/asd.py b/2022/day11/asd.py
deleted file mode 100755
index f89179c..0000000
--- a/2022/day11/asd.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env python3
-
-# import numpy as np
-from functools import reduce
-from re import findall
-from copy import deepcopy
-import sys
-
-# filename = "ref.txt"
-filename = "pzl.txt"
-data = open(filename).read()
-
-num_mon = len([None for _ in data.split('\n\n')])
-
-mons = list()
-itmss = list()
-for m in data.split('\n\n'):
- lines = [line for line in m.rstrip('\n').split('\n')]
- mon = dict()
- # mon['n'] = int(lines[0][-2])
- # mon['items'] = [int(i.strip()) for i in lines[1].split(':')[-1].split(',')]
- itmss.append([int(i.strip()) for i in lines[1].split(':')[-1].split(',')])
- mon['op'] = lines[2].split('=')[-1].strip()
- mon['test'] = int(lines[3].split(' ')[-1])
- mon['true'] = int(lines[4].split(' ')[-1])
- mon['false'] = int(lines[5].split(' ')[-1])
- mons.append(mon)
-
-# for mon,itms in zip(mons,itmss):
-# print(mon)
-# print(itms)
-
-def get_next_one_ape(n, old_timss, sums, div=0, mod=0):
- new_itmss = [list() for _ in old_timss]
-
- for ape,itms in enumerate(old_timss):
- for wl in itms:
- if n == ape:
- old = wl
- wl = eval(mons[ape]['op'])
- if div != 0:
- wl = int(wl/div)
- if mod != 0:
- wl = wl % mod
- sums[ape] += 1
- if wl % mons[ape]['test'] == 0:
- new_itmss[mons[ape]['true']].append(wl)
- else:
- new_itmss[mons[ape]['false']].append(wl)
- else:
- new_itmss[ape].append(wl)
- return new_itmss, sums
-
-
-def get_next(itmss, sums, div=0, mod=0):
- for ape,itms in enumerate(itmss):
- itmss, sums = get_next_one_ape(ape, itmss, sums, div=div, mod=mod)
- return itmss, sums
-
-
-res1 = 0
-div1 = 3
-sums1 = [0 for _ in itmss]
-itmss1 = itmss
-for i in range(20):
- itmss1, sums1 = get_next(itmss1, sums1, div=div1)
-res1 = reduce(lambda x,y:x*y, sorted(sums1, reverse=True)[:2])
-
-
-res2 = 0
-mod2 = reduce(lambda x,y:x*y, map(lambda a:a['test'],mons))
-sums2 = [0 for _ in itmss]
-itmss2 = itmss
-for i in range(1, 10001):
- itmss2, sums2 = get_next(itmss2, sums2, mod=mod2)
- # if i in [1, 20, 100, 200, 300, 400, 500, 1000, 2000, 10000]:
- # print(i, sums2)
-res2 = reduce(lambda x,y:x*y, sorted(sums2, reverse=True)[:2])
-
-print('res1:', res1)
-print('res2:', res2)
-
diff --git a/2022/day11/pzl.txt b/2022/day11/pzl.txt
deleted file mode 100644
index f6d24aa..0000000
--- a/2022/day11/pzl.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-Monkey 0:
- Starting items: 76, 88, 96, 97, 58, 61, 67
- Operation: new = old * 19
- Test: divisible by 3
- If true: throw to monkey 2
- If false: throw to monkey 3
-
-Monkey 1:
- Starting items: 93, 71, 79, 83, 69, 70, 94, 98
- Operation: new = old + 8
- Test: divisible by 11
- If true: throw to monkey 5
- If false: throw to monkey 6
-
-Monkey 2:
- Starting items: 50, 74, 67, 92, 61, 76
- Operation: new = old * 13
- Test: divisible by 19
- If true: throw to monkey 3
- If false: throw to monkey 1
-
-Monkey 3:
- Starting items: 76, 92
- Operation: new = old + 6
- Test: divisible by 5
- If true: throw to monkey 1
- If false: throw to monkey 6
-
-Monkey 4:
- Starting items: 74, 94, 55, 87, 62
- Operation: new = old + 5
- Test: divisible by 2
- If true: throw to monkey 2
- If false: throw to monkey 0
-
-Monkey 5:
- Starting items: 59, 62, 53, 62
- Operation: new = old * old
- Test: divisible by 7
- If true: throw to monkey 4
- If false: throw to monkey 7
-
-Monkey 6:
- Starting items: 62
- Operation: new = old + 2
- Test: divisible by 17
- If true: throw to monkey 5
- If false: throw to monkey 7
-
-Monkey 7:
- Starting items: 85, 54, 53
- Operation: new = old + 3
- Test: divisible by 13
- If true: throw to monkey 4
- If false: throw to monkey 0
diff --git a/2022/day11/ref.txt b/2022/day11/ref.txt
deleted file mode 100644
index 30e09e5..0000000
--- a/2022/day11/ref.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-Monkey 0:
- Starting items: 79, 98
- Operation: new = old * 19
- Test: divisible by 23
- If true: throw to monkey 2
- If false: throw to monkey 3
-
-Monkey 1:
- Starting items: 54, 65, 75, 74
- Operation: new = old + 6
- Test: divisible by 19
- If true: throw to monkey 2
- If false: throw to monkey 0
-
-Monkey 2:
- Starting items: 79, 60, 97
- Operation: new = old * old
- Test: divisible by 13
- If true: throw to monkey 1
- If false: throw to monkey 3
-
-Monkey 3:
- Starting items: 74
- Operation: new = old + 3
- Test: divisible by 17
- If true: throw to monkey 0
- If false: throw to monkey 1