Added day2 part1
This commit is contained in:
parent
b5bcd40fe2
commit
25d17915cf
10
2023/day2/part1/exp
Normal file
10
2023/day2/part1/exp
Normal file
@ -0,0 +1,10 @@
|
||||
Game 1: 12 blue; 13 red, 3 green, 14 blue; 2 green, 13 blue, 19 red
|
||||
Game 2: 2 blue, 1 red, 1 green; 1 red, 12 blue, 3 green; 5 green, 1 red, 9 blue; 1 red, 7 blue, 4 green
|
||||
Game 3: 1 red; 12 blue, 15 red; 1 green, 10 red, 2 blue; 1 green, 3 red, 9 blue
|
||||
Game 4: 16 blue, 5 green; 2 blue, 6 green, 6 red; 11 blue, 5 red; 6 green, 11 red, 7 blue; 4 green, 10 red; 1 green, 7 red, 13 blue
|
||||
Game 5: 10 green, 1 red, 2 blue; 3 red, 4 green, 4 blue; 5 green, 5 red
|
||||
Game 6: 1 green, 6 blue, 14 red; 9 blue, 5 red; 14 red, 12 blue
|
||||
Game 7: 1 green, 9 red, 8 blue; 9 blue, 1 green, 6 red; 1 green, 15 blue, 19 red
|
||||
Game 8: 9 red, 7 green, 2 blue; 6 red, 17 green; 18 red, 16 green, 2 blue; 10 red, 14 green
|
||||
Game 9: 1 blue, 11 red, 9 green; 8 red, 1 blue, 9 green; 4 blue, 16 red, 9 green; 8 green, 3 blue, 6 red; 8 green, 11 red, 3 blue; 11 red, 2 blue
|
||||
Game 10: 18 green, 14 blue; 1 red, 6 blue, 9 green; 6 blue, 4 green, 1 red; 16 green, 9 blue
|
100
2023/day2/part1/input
Normal file
100
2023/day2/part1/input
Normal file
@ -0,0 +1,100 @@
|
||||
Game 1: 12 blue; 2 green, 13 blue, 19 red; 13 red, 3 green, 14 blue
|
||||
Game 2: 12 blue, 1 red, 1 green; 1 red, 12 blue, 3 green; 5 green, 1 red, 9 blue; 1 red, 7 blue, 4 green
|
||||
Game 3: 1 red; 12 blue, 15 red; 1 green, 10 red, 2 blue; 1 green, 3 red, 9 blue
|
||||
Game 4: 6 blue, 5 green; 2 blue, 6 green, 6 red; 11 blue, 5 red; 6 green, 11 red, 7 blue; 4 green, 10 red; 1 green, 7 red, 13 blue
|
||||
Game 5: 10 green, 1 red, 2 blue; 3 red, 4 green, 4 blue; 5 green, 5 red
|
||||
Game 6: 1 green, 6 blue, 14 red; 9 blue, 5 red; 14 red, 12 blue
|
||||
Game 7: 1 green, 9 red, 8 blue; 9 blue, 1 green, 6 red; 1 green, 15 blue, 19 red
|
||||
Game 8: 9 red, 7 green, 2 blue; 6 red, 17 green; 18 red, 16 green, 2 blue; 10 red, 14 green
|
||||
Game 9: 1 blue, 11 red, 9 green; 8 red, 1 blue, 9 green; 4 blue, 16 red, 9 green; 8 green, 3 blue, 6 red; 8 green, 11 red, 3 blue; 11 red, 2 blue
|
||||
Game 10: 8 green, 14 blue; 1 red, 6 blue, 9 green; 6 blue, 4 green, 1 red; 16 green, 9 blue
|
||||
Game 11: 6 green, 11 blue, 1 red; 10 green, 1 red; 7 blue, 2 green, 1 red
|
||||
Game 12: 3 green, 5 blue, 2 red; 14 blue, 16 green, 4 red; 8 green, 14 blue, 4 red
|
||||
Game 13: 5 red, 12 blue, 2 green; 2 green, 1 red, 9 blue; 1 red, 2 blue, 3 green; 3 green, 3 red, 7 blue; 2 red, 13 blue; 1 red, 10 blue, 2 green
|
||||
Game 14: 5 blue, 1 red, 2 green; 8 blue, 1 green, 1 red; 1 blue, 2 green
|
||||
Game 15: 14 blue, 9 green, 1 red; 2 red, 15 blue, 12 green; 1 blue, 2 green, 1 red; 1 red, 16 green, 15 blue; 1 red, 12 green, 8 blue; 1 red, 17 blue
|
||||
Game 16: 7 red, 1 green, 18 blue; 7 blue, 5 green, 17 red; 14 blue, 8 red, 6 green
|
||||
Game 17: 4 green, 5 blue; 5 green, 1 red, 7 blue; 3 green, 6 blue, 4 red; 2 green, 5 blue; 9 green, 6 red, 6 blue
|
||||
Game 18: 8 red, 6 blue; 4 blue, 19 red; 4 blue, 9 red; 9 blue, 10 red; 2 green, 9 blue, 13 red; 3 blue, 7 red
|
||||
Game 19: 8 green, 2 red, 17 blue; 11 blue, 4 red, 5 green; 8 blue, 8 green, 10 red; 9 green, 4 blue, 2 red; 4 green, 10 red, 6 blue
|
||||
Game 20: 9 green, 3 blue, 1 red; 5 blue, 16 green, 3 red; 3 green, 3 red; 2 blue, 1 red, 5 green
|
||||
Game 21: 7 green, 1 red, 10 blue; 7 green, 5 blue, 7 red; 7 green, 9 blue
|
||||
Game 22: 5 red, 2 blue, 9 green; 6 red, 11 green; 6 green, 6 red
|
||||
Game 23: 14 red, 2 blue, 9 green; 9 green, 1 blue, 4 red; 9 red, 1 green, 1 blue; 6 green; 3 blue, 1 green, 9 red; 1 blue, 2 red
|
||||
Game 24: 3 red, 7 green, 6 blue; 1 green, 5 blue; 6 blue, 1 red, 2 green; 5 red, 1 blue, 4 green; 6 red, 2 blue, 11 green; 2 green, 2 red, 1 blue
|
||||
Game 25: 5 green, 1 red, 3 blue; 3 blue, 6 green, 3 red; 3 red, 4 green, 1 blue; 6 green, 1 blue, 9 red; 2 blue, 2 red, 1 green
|
||||
Game 26: 3 green, 4 red, 12 blue; 2 red, 1 green, 15 blue; 7 red, 16 green, 4 blue; 11 blue, 11 green, 3 red; 8 green, 15 blue, 10 red
|
||||
Game 27: 9 red; 10 red, 2 blue; 3 red; 8 red, 1 green, 2 blue; 1 red, 2 blue; 1 blue, 4 red
|
||||
Game 28: 5 blue, 8 red, 5 green; 10 blue, 4 red, 5 green; 8 red, 14 blue, 10 green; 10 blue, 4 red, 1 green; 5 red, 17 green, 4 blue
|
||||
Game 29: 16 green, 11 red, 5 blue; 11 red, 14 blue, 13 green; 13 blue, 8 green; 3 red, 18 green, 15 blue
|
||||
Game 30: 2 red, 4 blue, 8 green; 6 green, 2 red, 2 blue; 6 green, 6 blue, 2 red
|
||||
Game 31: 2 red, 1 blue, 16 green; 10 green, 1 blue, 7 red; 1 blue, 14 green, 7 red; 2 blue, 1 green, 1 red; 6 red, 13 green; 2 blue, 6 red, 10 green
|
||||
Game 32: 4 green, 4 blue; 1 green, 5 red; 6 green, 1 red; 3 green, 5 red, 2 blue; 4 red, 1 blue, 4 green; 6 green, 2 blue, 6 red
|
||||
Game 33: 5 blue, 2 red, 1 green; 5 blue; 1 blue, 1 green, 10 red; 8 red, 3 blue, 1 green
|
||||
Game 34: 15 blue, 7 green; 12 green, 17 blue; 10 blue, 11 green; 1 red, 5 blue, 9 green; 2 red, 10 blue, 11 green
|
||||
Game 35: 2 red, 6 blue; 2 red, 5 blue, 4 green; 2 red, 8 green, 10 blue
|
||||
Game 36: 4 red, 9 green, 3 blue; 4 red, 6 green; 6 red; 11 red, 4 green
|
||||
Game 37: 3 blue, 12 green, 14 red; 3 red, 5 green, 7 blue; 2 blue, 2 green, 16 red
|
||||
Game 38: 17 blue, 16 red, 8 green; 4 green, 17 blue, 4 red; 8 red, 7 blue, 6 green; 2 blue, 9 green, 17 red; 10 blue, 8 green, 11 red
|
||||
Game 39: 10 blue, 1 red, 4 green; 4 green, 4 red, 6 blue; 11 blue
|
||||
Game 40: 5 green, 17 blue; 11 blue, 4 green, 7 red; 2 green, 6 red, 13 blue; 7 blue, 12 green, 16 red; 15 red, 3 green, 8 blue; 12 green, 3 blue, 12 red
|
||||
Game 41: 13 blue, 3 red, 1 green; 2 green, 10 red; 1 blue, 5 red, 3 green; 5 green, 16 blue; 9 blue, 2 green; 14 blue, 4 green, 5 red
|
||||
Game 42: 2 blue, 15 green, 3 red; 3 red, 17 green; 6 red, 1 blue, 8 green
|
||||
Game 43: 8 green, 9 red, 3 blue; 1 blue, 13 red; 5 red, 1 blue, 6 green; 2 red, 2 blue; 17 red, 2 blue, 6 green
|
||||
Game 44: 10 red, 3 blue; 10 blue, 5 green; 4 red, 4 blue, 1 green; 16 blue, 6 red, 7 green; 3 green, 12 blue
|
||||
Game 45: 12 blue, 2 red; 2 blue, 3 red, 2 green; 8 blue, 3 green; 4 green, 8 blue, 5 red; 3 red, 2 blue, 1 green; 1 red, 2 blue, 7 green
|
||||
Game 46: 1 blue, 11 red, 6 green; 2 blue, 11 red, 6 green; 8 red, 5 green
|
||||
Game 47: 2 blue, 9 red; 1 green, 5 blue; 10 red, 2 blue, 2 green; 10 red, 3 green, 3 blue; 3 red, 6 blue, 2 green; 1 red, 1 green, 5 blue
|
||||
Game 48: 1 red, 7 green; 1 blue, 10 green, 5 red; 4 red, 8 green; 10 red, 10 green; 2 red, 16 green; 11 red, 14 green, 1 blue
|
||||
Game 49: 1 red, 1 blue, 5 green; 6 green, 5 red; 3 blue, 4 red, 3 green; 3 red, 5 green, 2 blue; 3 blue, 3 red
|
||||
Game 50: 17 red, 1 green, 7 blue; 4 blue, 1 red, 5 green; 10 red, 13 blue; 17 red
|
||||
Game 51: 2 red, 1 green; 1 green, 10 blue, 2 red; 5 red, 1 green, 7 blue; 7 blue, 1 red; 9 blue, 5 red, 2 green
|
||||
Game 52: 8 green, 1 blue; 14 green, 1 red; 10 green, 1 red
|
||||
Game 53: 17 green, 6 blue; 17 blue, 9 green; 1 red, 12 blue
|
||||
Game 54: 4 blue, 7 red, 9 green; 7 red, 2 green; 14 green, 10 red, 3 blue; 9 green, 6 blue, 5 red; 2 blue, 3 green, 11 red
|
||||
Game 55: 11 green, 4 red; 14 green; 3 red, 3 green; 3 green, 4 red, 1 blue; 15 green, 6 red, 2 blue; 4 red, 3 blue, 15 green
|
||||
Game 56: 8 blue, 5 red, 9 green; 11 green, 5 blue, 6 red; 1 green, 1 blue, 7 red; 7 green, 4 red, 1 blue; 9 blue, 5 red, 1 green; 5 red, 2 blue
|
||||
Game 57: 11 green, 19 blue, 5 red; 15 green, 5 red, 18 blue; 16 green, 5 red, 10 blue; 19 blue, 3 red; 9 green, 8 blue
|
||||
Game 58: 4 blue, 12 green; 11 green, 4 blue; 6 blue, 6 green; 1 red, 2 green; 11 green, 3 blue; 13 blue, 6 green
|
||||
Game 59: 10 blue, 1 red; 1 green, 4 blue; 4 blue
|
||||
Game 60: 7 red, 2 green, 6 blue; 1 green, 13 red, 12 blue; 9 blue, 9 green, 8 red
|
||||
Game 61: 7 green, 3 red, 2 blue; 1 red, 1 blue; 5 green, 3 blue; 4 blue, 1 red, 4 green
|
||||
Game 62: 1 green, 8 blue, 6 red; 7 blue, 3 red, 12 green; 2 blue, 7 red, 6 green
|
||||
Game 63: 3 red, 2 green; 3 green, 4 blue, 9 red; 3 blue, 3 green, 16 red; 4 red, 1 blue
|
||||
Game 64: 10 red, 2 green, 15 blue; 4 red, 14 green; 6 red, 14 green, 2 blue
|
||||
Game 65: 11 red, 14 green, 5 blue; 7 blue, 14 green, 15 red; 1 blue, 14 green; 4 green, 4 blue, 7 red
|
||||
Game 66: 6 blue, 9 green, 6 red; 6 blue, 2 red, 4 green; 3 blue; 8 blue, 5 green, 8 red; 17 blue, 11 green; 12 green, 11 blue, 4 red
|
||||
Game 67: 8 red, 4 blue, 6 green; 4 blue, 8 red, 2 green; 1 green, 6 red, 2 blue; 10 red, 1 green, 2 blue; 1 blue, 5 red; 2 red, 1 green, 2 blue
|
||||
Game 68: 10 green, 9 red, 13 blue; 2 blue, 2 green, 4 red; 11 red, 13 blue; 4 green, 2 red, 8 blue
|
||||
Game 69: 16 red; 12 red, 1 green, 4 blue; 1 green, 14 red, 9 blue; 12 blue, 2 green, 13 red; 14 red, 2 green, 10 blue; 11 blue
|
||||
Game 70: 1 red, 19 green; 4 blue, 6 green; 12 green, 2 red
|
||||
Game 71: 9 green, 2 blue, 3 red; 5 red; 1 red, 1 blue, 5 green
|
||||
Game 72: 1 green, 19 red; 12 red, 1 green, 1 blue; 16 red, 6 blue; 14 red, 7 blue; 11 blue, 1 green, 13 red; 16 blue, 4 red
|
||||
Game 73: 1 green, 1 red, 2 blue; 8 green, 2 red, 4 blue; 7 blue, 7 green, 7 red
|
||||
Game 74: 1 blue, 1 green; 1 red; 1 red, 5 blue, 4 green; 2 blue, 1 red; 1 blue
|
||||
Game 75: 8 green, 1 red; 3 blue, 1 red, 5 green; 12 green
|
||||
Game 76: 8 green, 6 red, 2 blue; 7 red, 1 blue; 2 blue, 9 green, 1 red; 8 red, 13 green; 12 green, 2 red; 7 green, 5 red
|
||||
Game 77: 3 blue, 1 green, 10 red; 13 red; 1 blue, 13 red, 1 green
|
||||
Game 78: 2 red, 3 green, 14 blue; 3 red, 16 blue, 6 green; 3 blue, 3 red, 9 green; 4 blue, 11 green; 6 green, 2 blue; 2 red, 10 green, 11 blue
|
||||
Game 79: 5 green, 10 blue, 2 red; 16 green, 15 blue, 1 red; 1 red, 11 green; 1 red, 11 blue, 16 green; 7 blue, 18 green
|
||||
Game 80: 9 blue, 10 green; 13 green, 9 blue; 1 red, 5 green, 5 blue; 13 green, 5 blue, 1 red
|
||||
Game 81: 9 green, 15 red, 11 blue; 11 blue, 9 red, 5 green; 2 green, 11 blue, 19 red; 14 green, 15 red, 5 blue
|
||||
Game 82: 4 green, 6 red, 13 blue; 5 blue, 5 red, 4 green; 2 green, 7 blue
|
||||
Game 83: 12 blue, 8 red; 6 red, 1 blue, 1 green; 7 red, 1 green, 1 blue; 6 red, 1 green, 9 blue; 10 blue, 3 red; 1 red, 5 blue
|
||||
Game 84: 9 blue, 13 red; 8 blue, 1 green; 9 blue, 1 green; 3 blue, 5 red, 1 green
|
||||
Game 85: 14 green, 5 blue, 8 red; 1 blue, 5 green, 1 red; 10 red, 7 blue, 17 green; 3 blue, 6 green; 6 red, 5 blue, 4 green; 5 blue, 4 green, 6 red
|
||||
Game 86: 14 red; 20 red, 3 blue; 1 green, 12 blue, 15 red; 16 red, 13 blue; 13 red, 12 blue; 2 blue, 20 red
|
||||
Game 87: 2 blue, 2 red, 10 green; 8 green, 9 red, 1 blue; 11 red, 1 green, 4 blue; 13 red, 1 blue; 11 green, 16 red, 3 blue
|
||||
Game 88: 5 green, 4 red, 1 blue; 3 blue, 8 red, 10 green; 11 green, 7 red, 4 blue; 11 green, 5 blue, 4 red; 9 red, 9 green; 4 blue, 6 green, 9 red
|
||||
Game 89: 2 blue, 2 red, 5 green; 2 red, 2 blue, 3 green; 2 red, 1 blue, 7 green; 6 green, 1 red, 2 blue
|
||||
Game 90: 4 green, 1 blue, 5 red; 2 blue, 2 red, 10 green; 2 green, 8 red, 1 blue; 10 green, 5 red; 2 red, 3 green, 2 blue
|
||||
Game 91: 16 blue, 5 red, 15 green; 4 green, 7 red, 3 blue; 4 red, 8 green, 12 blue; 4 green, 8 red, 17 blue
|
||||
Game 92: 13 red, 2 blue, 12 green; 19 green, 7 red; 17 green, 2 blue, 3 red; 6 blue, 11 red, 10 green; 6 red, 15 green, 3 blue; 6 blue, 20 green, 11 red
|
||||
Game 93: 2 blue, 3 green; 1 blue, 4 red; 1 red
|
||||
Game 94: 3 red, 5 green, 6 blue; 7 blue, 5 green, 6 red; 9 blue, 1 green, 2 red; 4 blue, 1 green, 4 red
|
||||
Game 95: 8 green, 9 red, 2 blue; 7 green, 7 red; 2 green, 4 blue, 6 red; 6 blue, 2 red, 2 green
|
||||
Game 96: 11 blue, 4 red; 1 green, 3 red, 14 blue; 2 green, 3 red, 8 blue; 7 red, 1 green, 3 blue; 8 blue, 6 red, 2 green; 9 blue, 3 red, 3 green
|
||||
Game 97: 5 green, 13 red, 7 blue; 2 blue, 12 red, 6 green; 10 blue, 11 red, 3 green; 4 green, 11 blue, 15 red; 8 green, 16 blue, 1 red; 15 blue, 4 red, 5 green
|
||||
Game 98: 3 blue, 1 red; 4 blue; 2 green, 1 blue; 2 green, 1 red, 5 blue
|
||||
Game 99: 4 green, 3 blue, 9 red; 6 blue, 5 red, 3 green; 2 green, 4 blue, 7 red; 8 red, 4 blue; 2 green, 15 red; 4 red, 5 blue, 3 green
|
||||
Game 100: 8 red, 4 blue, 4 green; 10 blue, 3 red, 4 green; 10 green, 4 red; 18 red, 9 blue, 2 green; 12 red, 4 green, 2 blue
|
40
2023/day2/part1/part1.py
Normal file
40
2023/day2/part1/part1.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/python3
|
||||
|
||||
import re
|
||||
import sys
|
||||
import numpy as np
|
||||
from pprint import pprint
|
||||
|
||||
input_f = sys.argv[1]
|
||||
count = 0
|
||||
game=[]
|
||||
count = 0
|
||||
colors= [[12,'red'],[13,'green'],[14,'blue']]
|
||||
imp = False
|
||||
|
||||
with open(input_f) as file:
|
||||
for line in file:
|
||||
tmp = line.rstrip().replace(':',';') #read the line
|
||||
game = tmp.split(';')
|
||||
ngame = []
|
||||
nngame = []
|
||||
for i in game:
|
||||
ngame.append(i.lstrip().split(', '))
|
||||
for idx,i in enumerate(ngame):
|
||||
nngame.append([])
|
||||
for j in i:
|
||||
nngame[idx].append(j.split())
|
||||
print("Starting ",end="")
|
||||
pprint(nngame)
|
||||
for idx, i in enumerate(nngame):
|
||||
if idx != 0 and imp == False:
|
||||
for j in i:
|
||||
for l in range(0,3):
|
||||
if j[1] == colors[l][1] and int(j[0]) > colors[l][0] and imp == False:
|
||||
count = count - int(nngame[0][0][1])
|
||||
imp = True
|
||||
count = count + int(nngame[0][0][1])
|
||||
print("Count is " + str(count) + " and game is " + str(imp))
|
||||
print()
|
||||
imp = False
|
||||
print(count)
|
5
2023/day2/part1/test
Normal file
5
2023/day2/part1/test
Normal file
@ -0,0 +1,5 @@
|
||||
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
|
||||
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
|
||||
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
|
||||
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
|
||||
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
|
100
2023/day2/part2/input
Normal file
100
2023/day2/part2/input
Normal file
@ -0,0 +1,100 @@
|
||||
Game 1: 12 blue; 2 green, 13 blue, 19 red; 13 red, 3 green, 14 blue
|
||||
Game 2: 12 blue, 1 red, 1 green; 1 red, 12 blue, 3 green; 5 green, 1 red, 9 blue; 1 red, 7 blue, 4 green
|
||||
Game 3: 1 red; 12 blue, 15 red; 1 green, 10 red, 2 blue; 1 green, 3 red, 9 blue
|
||||
Game 4: 6 blue, 5 green; 2 blue, 6 green, 6 red; 11 blue, 5 red; 6 green, 11 red, 7 blue; 4 green, 10 red; 1 green, 7 red, 13 blue
|
||||
Game 5: 10 green, 1 red, 2 blue; 3 red, 4 green, 4 blue; 5 green, 5 red
|
||||
Game 6: 1 green, 6 blue, 14 red; 9 blue, 5 red; 14 red, 12 blue
|
||||
Game 7: 1 green, 9 red, 8 blue; 9 blue, 1 green, 6 red; 1 green, 15 blue, 19 red
|
||||
Game 8: 9 red, 7 green, 2 blue; 6 red, 17 green; 18 red, 16 green, 2 blue; 10 red, 14 green
|
||||
Game 9: 1 blue, 11 red, 9 green; 8 red, 1 blue, 9 green; 4 blue, 16 red, 9 green; 8 green, 3 blue, 6 red; 8 green, 11 red, 3 blue; 11 red, 2 blue
|
||||
Game 10: 8 green, 14 blue; 1 red, 6 blue, 9 green; 6 blue, 4 green, 1 red; 16 green, 9 blue
|
||||
Game 11: 6 green, 11 blue, 1 red; 10 green, 1 red; 7 blue, 2 green, 1 red
|
||||
Game 12: 3 green, 5 blue, 2 red; 14 blue, 16 green, 4 red; 8 green, 14 blue, 4 red
|
||||
Game 13: 5 red, 12 blue, 2 green; 2 green, 1 red, 9 blue; 1 red, 2 blue, 3 green; 3 green, 3 red, 7 blue; 2 red, 13 blue; 1 red, 10 blue, 2 green
|
||||
Game 14: 5 blue, 1 red, 2 green; 8 blue, 1 green, 1 red; 1 blue, 2 green
|
||||
Game 15: 14 blue, 9 green, 1 red; 2 red, 15 blue, 12 green; 1 blue, 2 green, 1 red; 1 red, 16 green, 15 blue; 1 red, 12 green, 8 blue; 1 red, 17 blue
|
||||
Game 16: 7 red, 1 green, 18 blue; 7 blue, 5 green, 17 red; 14 blue, 8 red, 6 green
|
||||
Game 17: 4 green, 5 blue; 5 green, 1 red, 7 blue; 3 green, 6 blue, 4 red; 2 green, 5 blue; 9 green, 6 red, 6 blue
|
||||
Game 18: 8 red, 6 blue; 4 blue, 19 red; 4 blue, 9 red; 9 blue, 10 red; 2 green, 9 blue, 13 red; 3 blue, 7 red
|
||||
Game 19: 8 green, 2 red, 17 blue; 11 blue, 4 red, 5 green; 8 blue, 8 green, 10 red; 9 green, 4 blue, 2 red; 4 green, 10 red, 6 blue
|
||||
Game 20: 9 green, 3 blue, 1 red; 5 blue, 16 green, 3 red; 3 green, 3 red; 2 blue, 1 red, 5 green
|
||||
Game 21: 7 green, 1 red, 10 blue; 7 green, 5 blue, 7 red; 7 green, 9 blue
|
||||
Game 22: 5 red, 2 blue, 9 green; 6 red, 11 green; 6 green, 6 red
|
||||
Game 23: 14 red, 2 blue, 9 green; 9 green, 1 blue, 4 red; 9 red, 1 green, 1 blue; 6 green; 3 blue, 1 green, 9 red; 1 blue, 2 red
|
||||
Game 24: 3 red, 7 green, 6 blue; 1 green, 5 blue; 6 blue, 1 red, 2 green; 5 red, 1 blue, 4 green; 6 red, 2 blue, 11 green; 2 green, 2 red, 1 blue
|
||||
Game 25: 5 green, 1 red, 3 blue; 3 blue, 6 green, 3 red; 3 red, 4 green, 1 blue; 6 green, 1 blue, 9 red; 2 blue, 2 red, 1 green
|
||||
Game 26: 3 green, 4 red, 12 blue; 2 red, 1 green, 15 blue; 7 red, 16 green, 4 blue; 11 blue, 11 green, 3 red; 8 green, 15 blue, 10 red
|
||||
Game 27: 9 red; 10 red, 2 blue; 3 red; 8 red, 1 green, 2 blue; 1 red, 2 blue; 1 blue, 4 red
|
||||
Game 28: 5 blue, 8 red, 5 green; 10 blue, 4 red, 5 green; 8 red, 14 blue, 10 green; 10 blue, 4 red, 1 green; 5 red, 17 green, 4 blue
|
||||
Game 29: 16 green, 11 red, 5 blue; 11 red, 14 blue, 13 green; 13 blue, 8 green; 3 red, 18 green, 15 blue
|
||||
Game 30: 2 red, 4 blue, 8 green; 6 green, 2 red, 2 blue; 6 green, 6 blue, 2 red
|
||||
Game 31: 2 red, 1 blue, 16 green; 10 green, 1 blue, 7 red; 1 blue, 14 green, 7 red; 2 blue, 1 green, 1 red; 6 red, 13 green; 2 blue, 6 red, 10 green
|
||||
Game 32: 4 green, 4 blue; 1 green, 5 red; 6 green, 1 red; 3 green, 5 red, 2 blue; 4 red, 1 blue, 4 green; 6 green, 2 blue, 6 red
|
||||
Game 33: 5 blue, 2 red, 1 green; 5 blue; 1 blue, 1 green, 10 red; 8 red, 3 blue, 1 green
|
||||
Game 34: 15 blue, 7 green; 12 green, 17 blue; 10 blue, 11 green; 1 red, 5 blue, 9 green; 2 red, 10 blue, 11 green
|
||||
Game 35: 2 red, 6 blue; 2 red, 5 blue, 4 green; 2 red, 8 green, 10 blue
|
||||
Game 36: 4 red, 9 green, 3 blue; 4 red, 6 green; 6 red; 11 red, 4 green
|
||||
Game 37: 3 blue, 12 green, 14 red; 3 red, 5 green, 7 blue; 2 blue, 2 green, 16 red
|
||||
Game 38: 17 blue, 16 red, 8 green; 4 green, 17 blue, 4 red; 8 red, 7 blue, 6 green; 2 blue, 9 green, 17 red; 10 blue, 8 green, 11 red
|
||||
Game 39: 10 blue, 1 red, 4 green; 4 green, 4 red, 6 blue; 11 blue
|
||||
Game 40: 5 green, 17 blue; 11 blue, 4 green, 7 red; 2 green, 6 red, 13 blue; 7 blue, 12 green, 16 red; 15 red, 3 green, 8 blue; 12 green, 3 blue, 12 red
|
||||
Game 41: 13 blue, 3 red, 1 green; 2 green, 10 red; 1 blue, 5 red, 3 green; 5 green, 16 blue; 9 blue, 2 green; 14 blue, 4 green, 5 red
|
||||
Game 42: 2 blue, 15 green, 3 red; 3 red, 17 green; 6 red, 1 blue, 8 green
|
||||
Game 43: 8 green, 9 red, 3 blue; 1 blue, 13 red; 5 red, 1 blue, 6 green; 2 red, 2 blue; 17 red, 2 blue, 6 green
|
||||
Game 44: 10 red, 3 blue; 10 blue, 5 green; 4 red, 4 blue, 1 green; 16 blue, 6 red, 7 green; 3 green, 12 blue
|
||||
Game 45: 12 blue, 2 red; 2 blue, 3 red, 2 green; 8 blue, 3 green; 4 green, 8 blue, 5 red; 3 red, 2 blue, 1 green; 1 red, 2 blue, 7 green
|
||||
Game 46: 1 blue, 11 red, 6 green; 2 blue, 11 red, 6 green; 8 red, 5 green
|
||||
Game 47: 2 blue, 9 red; 1 green, 5 blue; 10 red, 2 blue, 2 green; 10 red, 3 green, 3 blue; 3 red, 6 blue, 2 green; 1 red, 1 green, 5 blue
|
||||
Game 48: 1 red, 7 green; 1 blue, 10 green, 5 red; 4 red, 8 green; 10 red, 10 green; 2 red, 16 green; 11 red, 14 green, 1 blue
|
||||
Game 49: 1 red, 1 blue, 5 green; 6 green, 5 red; 3 blue, 4 red, 3 green; 3 red, 5 green, 2 blue; 3 blue, 3 red
|
||||
Game 50: 17 red, 1 green, 7 blue; 4 blue, 1 red, 5 green; 10 red, 13 blue; 17 red
|
||||
Game 51: 2 red, 1 green; 1 green, 10 blue, 2 red; 5 red, 1 green, 7 blue; 7 blue, 1 red; 9 blue, 5 red, 2 green
|
||||
Game 52: 8 green, 1 blue; 14 green, 1 red; 10 green, 1 red
|
||||
Game 53: 17 green, 6 blue; 17 blue, 9 green; 1 red, 12 blue
|
||||
Game 54: 4 blue, 7 red, 9 green; 7 red, 2 green; 14 green, 10 red, 3 blue; 9 green, 6 blue, 5 red; 2 blue, 3 green, 11 red
|
||||
Game 55: 11 green, 4 red; 14 green; 3 red, 3 green; 3 green, 4 red, 1 blue; 15 green, 6 red, 2 blue; 4 red, 3 blue, 15 green
|
||||
Game 56: 8 blue, 5 red, 9 green; 11 green, 5 blue, 6 red; 1 green, 1 blue, 7 red; 7 green, 4 red, 1 blue; 9 blue, 5 red, 1 green; 5 red, 2 blue
|
||||
Game 57: 11 green, 19 blue, 5 red; 15 green, 5 red, 18 blue; 16 green, 5 red, 10 blue; 19 blue, 3 red; 9 green, 8 blue
|
||||
Game 58: 4 blue, 12 green; 11 green, 4 blue; 6 blue, 6 green; 1 red, 2 green; 11 green, 3 blue; 13 blue, 6 green
|
||||
Game 59: 10 blue, 1 red; 1 green, 4 blue; 4 blue
|
||||
Game 60: 7 red, 2 green, 6 blue; 1 green, 13 red, 12 blue; 9 blue, 9 green, 8 red
|
||||
Game 61: 7 green, 3 red, 2 blue; 1 red, 1 blue; 5 green, 3 blue; 4 blue, 1 red, 4 green
|
||||
Game 62: 1 green, 8 blue, 6 red; 7 blue, 3 red, 12 green; 2 blue, 7 red, 6 green
|
||||
Game 63: 3 red, 2 green; 3 green, 4 blue, 9 red; 3 blue, 3 green, 16 red; 4 red, 1 blue
|
||||
Game 64: 10 red, 2 green, 15 blue; 4 red, 14 green; 6 red, 14 green, 2 blue
|
||||
Game 65: 11 red, 14 green, 5 blue; 7 blue, 14 green, 15 red; 1 blue, 14 green; 4 green, 4 blue, 7 red
|
||||
Game 66: 6 blue, 9 green, 6 red; 6 blue, 2 red, 4 green; 3 blue; 8 blue, 5 green, 8 red; 17 blue, 11 green; 12 green, 11 blue, 4 red
|
||||
Game 67: 8 red, 4 blue, 6 green; 4 blue, 8 red, 2 green; 1 green, 6 red, 2 blue; 10 red, 1 green, 2 blue; 1 blue, 5 red; 2 red, 1 green, 2 blue
|
||||
Game 68: 10 green, 9 red, 13 blue; 2 blue, 2 green, 4 red; 11 red, 13 blue; 4 green, 2 red, 8 blue
|
||||
Game 69: 16 red; 12 red, 1 green, 4 blue; 1 green, 14 red, 9 blue; 12 blue, 2 green, 13 red; 14 red, 2 green, 10 blue; 11 blue
|
||||
Game 70: 1 red, 19 green; 4 blue, 6 green; 12 green, 2 red
|
||||
Game 71: 9 green, 2 blue, 3 red; 5 red; 1 red, 1 blue, 5 green
|
||||
Game 72: 1 green, 19 red; 12 red, 1 green, 1 blue; 16 red, 6 blue; 14 red, 7 blue; 11 blue, 1 green, 13 red; 16 blue, 4 red
|
||||
Game 73: 1 green, 1 red, 2 blue; 8 green, 2 red, 4 blue; 7 blue, 7 green, 7 red
|
||||
Game 74: 1 blue, 1 green; 1 red; 1 red, 5 blue, 4 green; 2 blue, 1 red; 1 blue
|
||||
Game 75: 8 green, 1 red; 3 blue, 1 red, 5 green; 12 green
|
||||
Game 76: 8 green, 6 red, 2 blue; 7 red, 1 blue; 2 blue, 9 green, 1 red; 8 red, 13 green; 12 green, 2 red; 7 green, 5 red
|
||||
Game 77: 3 blue, 1 green, 10 red; 13 red; 1 blue, 13 red, 1 green
|
||||
Game 78: 2 red, 3 green, 14 blue; 3 red, 16 blue, 6 green; 3 blue, 3 red, 9 green; 4 blue, 11 green; 6 green, 2 blue; 2 red, 10 green, 11 blue
|
||||
Game 79: 5 green, 10 blue, 2 red; 16 green, 15 blue, 1 red; 1 red, 11 green; 1 red, 11 blue, 16 green; 7 blue, 18 green
|
||||
Game 80: 9 blue, 10 green; 13 green, 9 blue; 1 red, 5 green, 5 blue; 13 green, 5 blue, 1 red
|
||||
Game 81: 9 green, 15 red, 11 blue; 11 blue, 9 red, 5 green; 2 green, 11 blue, 19 red; 14 green, 15 red, 5 blue
|
||||
Game 82: 4 green, 6 red, 13 blue; 5 blue, 5 red, 4 green; 2 green, 7 blue
|
||||
Game 83: 12 blue, 8 red; 6 red, 1 blue, 1 green; 7 red, 1 green, 1 blue; 6 red, 1 green, 9 blue; 10 blue, 3 red; 1 red, 5 blue
|
||||
Game 84: 9 blue, 13 red; 8 blue, 1 green; 9 blue, 1 green; 3 blue, 5 red, 1 green
|
||||
Game 85: 14 green, 5 blue, 8 red; 1 blue, 5 green, 1 red; 10 red, 7 blue, 17 green; 3 blue, 6 green; 6 red, 5 blue, 4 green; 5 blue, 4 green, 6 red
|
||||
Game 86: 14 red; 20 red, 3 blue; 1 green, 12 blue, 15 red; 16 red, 13 blue; 13 red, 12 blue; 2 blue, 20 red
|
||||
Game 87: 2 blue, 2 red, 10 green; 8 green, 9 red, 1 blue; 11 red, 1 green, 4 blue; 13 red, 1 blue; 11 green, 16 red, 3 blue
|
||||
Game 88: 5 green, 4 red, 1 blue; 3 blue, 8 red, 10 green; 11 green, 7 red, 4 blue; 11 green, 5 blue, 4 red; 9 red, 9 green; 4 blue, 6 green, 9 red
|
||||
Game 89: 2 blue, 2 red, 5 green; 2 red, 2 blue, 3 green; 2 red, 1 blue, 7 green; 6 green, 1 red, 2 blue
|
||||
Game 90: 4 green, 1 blue, 5 red; 2 blue, 2 red, 10 green; 2 green, 8 red, 1 blue; 10 green, 5 red; 2 red, 3 green, 2 blue
|
||||
Game 91: 16 blue, 5 red, 15 green; 4 green, 7 red, 3 blue; 4 red, 8 green, 12 blue; 4 green, 8 red, 17 blue
|
||||
Game 92: 13 red, 2 blue, 12 green; 19 green, 7 red; 17 green, 2 blue, 3 red; 6 blue, 11 red, 10 green; 6 red, 15 green, 3 blue; 6 blue, 20 green, 11 red
|
||||
Game 93: 2 blue, 3 green; 1 blue, 4 red; 1 red
|
||||
Game 94: 3 red, 5 green, 6 blue; 7 blue, 5 green, 6 red; 9 blue, 1 green, 2 red; 4 blue, 1 green, 4 red
|
||||
Game 95: 8 green, 9 red, 2 blue; 7 green, 7 red; 2 green, 4 blue, 6 red; 6 blue, 2 red, 2 green
|
||||
Game 96: 11 blue, 4 red; 1 green, 3 red, 14 blue; 2 green, 3 red, 8 blue; 7 red, 1 green, 3 blue; 8 blue, 6 red, 2 green; 9 blue, 3 red, 3 green
|
||||
Game 97: 5 green, 13 red, 7 blue; 2 blue, 12 red, 6 green; 10 blue, 11 red, 3 green; 4 green, 11 blue, 15 red; 8 green, 16 blue, 1 red; 15 blue, 4 red, 5 green
|
||||
Game 98: 3 blue, 1 red; 4 blue; 2 green, 1 blue; 2 green, 1 red, 5 blue
|
||||
Game 99: 4 green, 3 blue, 9 red; 6 blue, 5 red, 3 green; 2 green, 4 blue, 7 red; 8 red, 4 blue; 2 green, 15 red; 4 red, 5 blue, 3 green
|
||||
Game 100: 8 red, 4 blue, 4 green; 10 blue, 3 red, 4 green; 10 green, 4 red; 18 red, 9 blue, 2 green; 12 red, 4 green, 2 blue
|
40
2023/day2/part2/part2.py
Normal file
40
2023/day2/part2/part2.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/python3
|
||||
|
||||
import re
|
||||
import sys
|
||||
import numpy as np
|
||||
from pprint import pprint
|
||||
|
||||
input_f = sys.argv[1]
|
||||
count = 0
|
||||
game=[]
|
||||
count = 0
|
||||
colors= [[12,'red'],[13,'green'],[14,'blue']]
|
||||
imp = False
|
||||
|
||||
with open(input_f) as file:
|
||||
for line in file:
|
||||
tmp = line.rstrip().replace(':',';') #read the line
|
||||
game = tmp.split(';')
|
||||
ngame = []
|
||||
nngame = []
|
||||
for i in game:
|
||||
ngame.append(i.lstrip().split(', '))
|
||||
for idx,i in enumerate(ngame):
|
||||
nngame.append([])
|
||||
for j in i:
|
||||
nngame[idx].append(j.split())
|
||||
print("Starting ",end="")
|
||||
pprint(nngame)
|
||||
for idx, i in enumerate(nngame):
|
||||
if idx != 0 and imp == False:
|
||||
for j in i:
|
||||
for l in range(0,3):
|
||||
if j[1] == colors[l][1] and int(j[0]) > colors[l][0] and imp == False:
|
||||
count = count - int(nngame[0][0][1])
|
||||
imp = True
|
||||
count = count + int(nngame[0][0][1])
|
||||
print("Count is " + str(count) + " and game is " + str(imp))
|
||||
print()
|
||||
imp = False
|
||||
print(count)
|
5
2023/day2/part2/test
Normal file
5
2023/day2/part2/test
Normal file
@ -0,0 +1,5 @@
|
||||
Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green
|
||||
Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue
|
||||
Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red
|
||||
Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red
|
||||
Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green
|
Loading…
Reference in New Issue
Block a user