Skip to content

Commit

Permalink
Complete Day 11
Browse files Browse the repository at this point in the history
  • Loading branch information
BB-BenBridges committed Dec 12, 2022
1 parent 6e8f743 commit 5bec952
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Day11P1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import time
st = time.time()

items = [[96, 60, 68, 91, 83, 57, 85],[75, 78, 68, 81, 73, 99],[69, 86, 67, 55, 96, 69, 94, 85],[88, 75, 74, 98, 80],[82],[72, 92, 92],[74, 61],[76, 86, 83, 55]]
opperation = [['*',2],['+',3],['+',6],['+',5],['+',8],['*',5],['**',2],['+',4]]
test = [[17,2,5],[13,7,4],[19,6,5],[7,7,1],[11,0,2],[3,6,3],[2,3,1],[5,4,0]]
busy = [0,0,0,0,0,0,0,0]

for x in range (1,21):
for i in range(0,8):
pops = 0
for item in items[i]:
opperator, val = opperation[i]
match opperator:
case '*':
item = item * val
case '+':
item = item + val
case '**':
item = item ** val
item = item // 3
if item % test[i][0] == 0:
items[test[i][1]].append(item)
else:
items[test[i][2]].append(item)
busy[i] += 1
pops += 1
for j in range(0,pops):
items[i].pop(0)

busy_max_1 = max(busy)
busy.remove(busy_max_1)
busy_max_2 = max(busy)
print('Max 1(' + str(busy_max_1) + ') * Max 2(' + str(busy_max_2) + ') = ' + str(busy_max_1 * busy_max_2))

et = time.time()

# get the execution time
elapsed_time = et - st
final_res = elapsed_time * 1000
print('Execution time:', final_res, 'ms')
44 changes: 44 additions & 0 deletions Day11P2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import time
import math
from operator import mod
st = time.time()

items = [[96, 60, 68, 91, 83, 57, 85],[75, 78, 68, 81, 73, 99],[69, 86, 67, 55, 96, 69, 94, 85],[88, 75, 74, 98, 80],[82],[72, 92, 92],[74, 61],[76, 86, 83, 55]]
opperation = [['*',2],['+',3],['+',6],['+',5],['+',8],['*',5],['**',2],['+',4]]
test = [[17,2,5],[13,7,4],[19,6,5],[7,7,1],[11,0,2],[3,6,3],[2,3,1],[5,4,0]]
busy = [0,0,0,0,0,0,0,0]
lcm = math.lcm(17,13,19,7,11,3,2,5)

for x in range (1,10001):
for i in range(0,8):
pops = 0
for item in items[i]:
opperator, val = opperation[i]
match opperator:
case '*':
item = item * val
case '+':
item = item + val
case '**':
item = item ** val
item = mod(item, lcm)
if item % test[i][0] == 0:
items[test[i][1]].append(item)
else:
items[test[i][2]].append(item)
busy[i] += 1
pops += 1

items[i] = items[i][:-pops or None]

busy_max_1 = max(busy)
busy.remove(busy_max_1)
busy_max_2 = max(busy)
print('Max 1(' + str(busy_max_1) + ') * Max 2(' + str(busy_max_2) + ') = ' + str(busy_max_1 * busy_max_2))

et = time.time()

# get the execution time
elapsed_time = et - st
final_res = elapsed_time * 1000
print('Execution time:', final_res, 'ms')

0 comments on commit 5bec952

Please sign in to comment.