69 changed files with 13272 additions and 0 deletions
File diff suppressed because one or more lines are too long
@ -0,0 +1,31 @@ |
|||
import os |
|||
import sys |
|||
|
|||
file = open('input.txt', 'r') |
|||
input = file.read() |
|||
open = "(" |
|||
close = ")" |
|||
open_count = input.count(open) |
|||
close_count = input.count(close) |
|||
|
|||
print("Open count: " + str(open_count)) |
|||
print("Close count: " + str(close_count)) |
|||
|
|||
floor = open_count - close_count |
|||
|
|||
print("Santa is on floor: " + str(floor)) |
|||
|
|||
floor = 0 |
|||
count = 0; |
|||
for char in input: |
|||
if char == open: |
|||
floor = floor + 1 |
|||
|
|||
if char == close: |
|||
floor = floor - 1 |
|||
|
|||
count = count + 1 |
|||
if floor < 0: |
|||
break; |
|||
|
|||
print("Santa visits the basement first at position: " + str(count)) |
|||
@ -0,0 +1,33 @@ |
|||
input = "3113322113" |
|||
#input = "21" |
|||
|
|||
loop = 0 |
|||
while loop < 50: |
|||
index = 0 |
|||
new_input = "" |
|||
#print("Input: " + input) |
|||
while index != len(input): |
|||
#print("\t Index: " + str(index)) |
|||
char_count = 1 |
|||
char = input[index] |
|||
#print("\t Char: " + char) |
|||
for i in range(index+1, len(input)): |
|||
#print("\t\t I: " + str(i)) |
|||
#print("\t\t Input[i]:" + input[i]) |
|||
if input[i] == char: |
|||
char_count += 1 |
|||
#print("\t\t\tMatch found") |
|||
else: |
|||
#print("\t\t\tBreak") |
|||
break; |
|||
#print("\t Char Count: " + str(char_count)) |
|||
#print("\t There is " + str(char_count) + " number " + char) |
|||
new_input += str(char_count) |
|||
new_input += str(char) |
|||
index += char_count |
|||
#print("New Input: " + new_input) |
|||
input = new_input |
|||
loop += 1 |
|||
|
|||
#print(input) |
|||
print(len(input)) |
|||
@ -0,0 +1,42 @@ |
|||
import re |
|||
input = "cqjxjnds" |
|||
|
|||
mistakeable_letters = re.compile(r"([iol])") |
|||
doubles = re.compile(r"(.)\1") |
|||
|
|||
def gen_new_password(pInput): |
|||
new_password = False |
|||
ret = pInput |
|||
while new_password != True: |
|||
characters = list(ret) |
|||
char = characters[len(characters)-1] |
|||
characters[len(characters)-1] = chr(ord(char) + 1) |
|||
for i in range(len(characters)-1, 0, -1): |
|||
if characters[i] == '{': |
|||
characters[i] = 'a' |
|||
characters[i-1] = chr(ord(characters[i-1]) + 1) |
|||
ret = "".join(characters) |
|||
|
|||
no_mistakable_letter = False |
|||
two_doubles = False |
|||
letter_sequence = False |
|||
mistakeable_letter_count = len(re.findall(mistakeable_letters, ret)) |
|||
if mistakeable_letter_count == 0: |
|||
no_mistakable_letter = True |
|||
|
|||
double_count = len(re.findall(doubles, ret)) |
|||
if double_count >= 2: |
|||
two_doubles = True |
|||
|
|||
for i in range(0, len(characters)-3): |
|||
if ord(characters[i+1]) == ord(characters[i]) + 1 and ord(characters[i+2]) == ord(characters[i]) + 2: |
|||
letter_sequence = True |
|||
|
|||
if no_mistakable_letter == True and two_doubles == True and letter_sequence == True: |
|||
new_password = True |
|||
return ret |
|||
|
|||
password_1 = gen_new_password(input) |
|||
password_2 = gen_new_password(password_1) |
|||
print("First new password: " + password_1) |
|||
print("Second new password: " + password_2) |
|||
File diff suppressed because one or more lines are too long
@ -0,0 +1,37 @@ |
|||
import json |
|||
|
|||
file = open('input.txt', 'r') |
|||
decoded = json.loads(file.read()) |
|||
#decoded = json.loads('{"a":{"b":4},"c":-1}') |
|||
#decoded = json.loads('[1,{"c":"red","b":2},3]') |
|||
|
|||
total = 0 |
|||
|
|||
def contains_red(pIterable): |
|||
contains_red = False |
|||
for k, v in pIterable.items(): |
|||
if isinstance(v, str): |
|||
if v == "red": |
|||
contains_red = True |
|||
return contains_red |
|||
|
|||
def recurse(pIterable): |
|||
global total |
|||
if isinstance(pIterable, dict): |
|||
if contains_red(pIterable): |
|||
return |
|||
for k, v in pIterable.items(): |
|||
if isinstance(v, list) or isinstance(v, dict): |
|||
recurse(v) |
|||
elif isinstance(v, int): |
|||
total += int(v) |
|||
|
|||
elif isinstance(pIterable, list): |
|||
for a in pIterable: |
|||
if isinstance(a, list) or isinstance(a, dict): |
|||
recurse(a) |
|||
elif isinstance(a, int): |
|||
total += int(a) |
|||
|
|||
recurse(decoded) |
|||
print(total) |
|||
@ -0,0 +1,56 @@ |
|||
Alice would gain 54 happiness units by sitting next to Bob. |
|||
Alice would lose 81 happiness units by sitting next to Carol. |
|||
Alice would lose 42 happiness units by sitting next to David. |
|||
Alice would gain 89 happiness units by sitting next to Eric. |
|||
Alice would lose 89 happiness units by sitting next to Frank. |
|||
Alice would gain 97 happiness units by sitting next to George. |
|||
Alice would lose 94 happiness units by sitting next to Mallory. |
|||
Bob would gain 3 happiness units by sitting next to Alice. |
|||
Bob would lose 70 happiness units by sitting next to Carol. |
|||
Bob would lose 31 happiness units by sitting next to David. |
|||
Bob would gain 72 happiness units by sitting next to Eric. |
|||
Bob would lose 25 happiness units by sitting next to Frank. |
|||
Bob would lose 95 happiness units by sitting next to George. |
|||
Bob would gain 11 happiness units by sitting next to Mallory. |
|||
Carol would lose 83 happiness units by sitting next to Alice. |
|||
Carol would gain 8 happiness units by sitting next to Bob. |
|||
Carol would gain 35 happiness units by sitting next to David. |
|||
Carol would gain 10 happiness units by sitting next to Eric. |
|||
Carol would gain 61 happiness units by sitting next to Frank. |
|||
Carol would gain 10 happiness units by sitting next to George. |
|||
Carol would gain 29 happiness units by sitting next to Mallory. |
|||
David would gain 67 happiness units by sitting next to Alice. |
|||
David would gain 25 happiness units by sitting next to Bob. |
|||
David would gain 48 happiness units by sitting next to Carol. |
|||
David would lose 65 happiness units by sitting next to Eric. |
|||
David would gain 8 happiness units by sitting next to Frank. |
|||
David would gain 84 happiness units by sitting next to George. |
|||
David would gain 9 happiness units by sitting next to Mallory. |
|||
Eric would lose 51 happiness units by sitting next to Alice. |
|||
Eric would lose 39 happiness units by sitting next to Bob. |
|||
Eric would gain 84 happiness units by sitting next to Carol. |
|||
Eric would lose 98 happiness units by sitting next to David. |
|||
Eric would lose 20 happiness units by sitting next to Frank. |
|||
Eric would lose 6 happiness units by sitting next to George. |
|||
Eric would gain 60 happiness units by sitting next to Mallory. |
|||
Frank would gain 51 happiness units by sitting next to Alice. |
|||
Frank would gain 79 happiness units by sitting next to Bob. |
|||
Frank would gain 88 happiness units by sitting next to Carol. |
|||
Frank would gain 33 happiness units by sitting next to David. |
|||
Frank would gain 43 happiness units by sitting next to Eric. |
|||
Frank would gain 77 happiness units by sitting next to George. |
|||
Frank would lose 3 happiness units by sitting next to Mallory. |
|||
George would lose 14 happiness units by sitting next to Alice. |
|||
George would lose 12 happiness units by sitting next to Bob. |
|||
George would lose 52 happiness units by sitting next to Carol. |
|||
George would gain 14 happiness units by sitting next to David. |
|||
George would lose 62 happiness units by sitting next to Eric. |
|||
George would lose 18 happiness units by sitting next to Frank. |
|||
George would lose 17 happiness units by sitting next to Mallory. |
|||
Mallory would lose 36 happiness units by sitting next to Alice. |
|||
Mallory would gain 76 happiness units by sitting next to Bob. |
|||
Mallory would lose 34 happiness units by sitting next to Carol. |
|||
Mallory would gain 37 happiness units by sitting next to David. |
|||
Mallory would gain 40 happiness units by sitting next to Eric. |
|||
Mallory would gain 18 happiness units by sitting next to Frank. |
|||
Mallory would gain 7 happiness units by sitting next to George. |
|||
@ -0,0 +1,4 @@ |
|||
{'George': {'relationship': {'Alice': -14, 'Carol': -52, 'Mallory': -17, 'Frank': -18, 'Bob': -12, 'Eric': -62, 'David': 14}}, 'Alice': {'relationship': {'George': 97, 'Carol': -81, 'Mallory': -94, 'Bob': 54, 'Frank': -89, 'Eric': 89, 'David': -42}}, 'Carol': {'relationship': {'George': 10, 'Alice': -83, 'Mallory': 29, 'Bob': 8, 'Frank': 61, 'David': 35, 'Eric': 10}}, 'Mallory': {'relationship': {'George': 7, 'Alice': -36, 'Carol': -34, 'Frank': 18, 'Bob': 76, 'Eric': 40, 'David': 37}}, 'Frank': {'relationship': {'George': 77, 'Alice': 51, 'Carol': 88, 'Mallory': -3, 'Bob': 79, 'Eric': 43, 'David': 33}}, 'Bob': {'relationship': {'George': -95, 'Alice': 3, 'Carol': -70, 'Mallory': 11, 'Frank': -25, 'Eric': 72, 'David': -31}}, 'Eric': {'relationship': {'George': -6, 'Alice': -51, 'Carol': 84, 'Mallory': 60, 'Bob': -39, 'Frank': -20, 'David': -98}}, 'David': {'relationship': {'George': 84, 'Alice': 67, 'Carol': 48, 'Mallory': 9, 'Bob': 25, 'Frank': 8, 'Eric': -65}}} |
|||
[-691, ('Mallory', 'Alice', 'Carol', 'Bob', 'George', 'Eric', 'David', 'Frank')] [751, ('Frank', 'Carol', 'Eric', 'Mallory', 'Bob', 'Alice', 'George', 'David')] |
|||
{'Alice': {'relationship': {'Bob': 54, 'Eric': 89, 'David': -42, 'Mallory': -94, 'George': 97, 'Frank': -89, 'Carol': -81}}, 'Bob': {'relationship': {'Alice': 3, 'Eric': 72, 'David': -31, 'Mallory': 11, 'George': -95, 'Frank': -25, 'Carol': -70}}, 'Eric': {'relationship': {'Alice': -51, 'Bob': -39, 'David': -98, 'Mallory': 60, 'George': -6, 'Frank': -20, 'Carol': 84}}, 'David': {'relationship': {'Alice': 67, 'Bob': 25, 'Eric': -65, 'Mallory': 9, 'George': 84, 'Frank': 8, 'Carol': 48}}, 'Mallory': {'relationship': {'Alice': -36, 'Bob': 76, 'Eric': 40, 'David': 37, 'George': 7, 'Frank': 18, 'Carol': -34}}, 'George': {'relationship': {'Alice': -14, 'Bob': -12, 'Eric': -62, 'David': 14, 'Mallory': -17, 'Frank': -18, 'Carol': -52}}, 'Frank': {'relationship': {'Alice': 51, 'Bob': 79, 'Eric': 43, 'David': 33, 'Mallory': -3, 'George': 77, 'Carol': 88}}, 'Carol': {'relationship': {'Alice': -83, 'Bob': 8, 'Eric': 10, 'David': 35, 'Mallory': 29, 'George': 10, 'Frank': 61}}} |
|||
[751, ('Frank', 'Carol', 'Eric', 'Mallory', 'Bob', 'Alice', 'George', 'David')] [751, ('Frank', 'Carol', 'Eric', 'Mallory', 'Bob', 'Alice', 'George', 'David')] |
|||
@ -0,0 +1,33 @@ |
|||
import itertools |
|||
file = open('input.txt', 'r') |
|||
|
|||
people = {} |
|||
results = [] |
|||
|
|||
for line in file: |
|||
splits = line.split(' ') |
|||
people.setdefault(splits[0], {'relationship' : {} }) |
|||
name = splits[len(splits)-1].strip() |
|||
name = name.strip(".") |
|||
happiness = int(splits[3]) |
|||
if splits[2] == "lose": |
|||
happiness = 0-happiness |
|||
|
|||
people[splits[0]]['relationship'].setdefault(name, happiness) |
|||
|
|||
people.setdefault("Me", {'relationship' : {} }) |
|||
for name in people: |
|||
people["Me"]['relationship'].setdefault(name, 0) |
|||
people[name]['relationship'].setdefault("Me", 0) |
|||
|
|||
print(people) |
|||
for perm in itertools.permutations(people): |
|||
happy = 0 |
|||
for i in range(0, len(perm)-1): |
|||
happy += people[perm[i]]['relationship'][perm[i+1]] |
|||
happy += people[perm[i+1]]['relationship'][perm[i]] |
|||
happy += people[perm[len(perm)-1]]['relationship'][perm[0]] |
|||
happy += people[perm[0]]['relationship'][perm[len(perm)-1]] |
|||
results.append([happy, perm]) |
|||
|
|||
print( min(results), max(results) ) |
|||
@ -0,0 +1,9 @@ |
|||
Rudolph can fly 22 kms for 8 seconds, but then must rest for 165 seconds. |
|||
Cupid can fly 8 kms for 17 seconds, but then must rest for 114 seconds. |
|||
Prancer can fly 18 kms for 6 seconds, but then must rest for 103 seconds. |
|||
Donner can fly 25 kms for 6 seconds, but then must rest for 145 seconds. |
|||
Dasher can fly 11 kms for 12 seconds, but then must rest for 125 seconds. |
|||
Comet can fly 21 kms for 6 seconds, but then must rest for 121 seconds. |
|||
Blitzen can fly 18 kms for 3 seconds, but then must rest for 50 seconds. |
|||
Vixen can fly 20 kms for 4 seconds, but then must rest for 75 seconds. |
|||
Dancer can fly 7 kms for 20 seconds, but then must rest for 119 seconds. |
|||
File diff suppressed because it is too large
@ -0,0 +1,45 @@ |
|||
file = open('input.txt', 'r') |
|||
|
|||
reindeer = {} |
|||
|
|||
def tick_reindeer(key): |
|||
runner = reindeer[key] |
|||
|
|||
if runner['resting']: |
|||
runner['rest_progress'] += 1 |
|||
if runner['rest_progress'] == runner['recovery']: |
|||
runner['rest_progress'] = 0 |
|||
runner['resting'] = False |
|||
return |
|||
|
|||
runner['distance_travelled'] += runner['speed'] |
|||
runner['running_for'] += 1 |
|||
|
|||
if runner['running_for'] == runner['stamina']: |
|||
runner['running_for'] = 0 |
|||
runner['resting'] = True |
|||
|
|||
def award_points(): |
|||
progress = [] |
|||
for key in reindeer: |
|||
progress.append([reindeer[key]['distance_travelled'], key]) |
|||
progress = sorted(progress, reverse=True) |
|||
for i in range(0, len(progress)-1): |
|||
if progress[i][0] == progress[0][0]: |
|||
reindeer[progress[i][1]]['points'] += 1 |
|||
|
|||
|
|||
for line in file: |
|||
splits = line.split(' ') |
|||
reindeer.setdefault(splits[0], {'speed' : int(splits[3]), 'stamina': int(splits[6]), 'recovery': int(splits[13]), 'distance_travelled' : 0, 'rest_progress' : 0, 'running_for' : 0, 'resting' : False, 'points' : 0}) |
|||
|
|||
timer = 0 |
|||
while timer != 2503: |
|||
|
|||
for key in reindeer: |
|||
tick_reindeer(key) |
|||
|
|||
award_points() |
|||
timer += 1 |
|||
|
|||
print(reindeer) |
|||
@ -0,0 +1,4 @@ |
|||
Sugar: capacity 3, durability 0, flavor 0, texture -3, calories 2 |
|||
Sprinkles: capacity -3, durability 3, flavor 0, texture 0, calories 9 |
|||
Candy: capacity -1, durability 0, flavor 4, texture 0, calories 1 |
|||
Chocolate: capacity 0, durability 0, flavor -2, texture 2, calories 8 |
|||
@ -0,0 +1,2 @@ |
|||
Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8 |
|||
Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3 |
|||
@ -0,0 +1,2 @@ |
|||
[222870, ('Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:')] |
|||
[117936, ('Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Candy:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Chocolate:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sugar:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:', 'Sprinkles:')] |
|||
@ -0,0 +1,39 @@ |
|||
import itertools |
|||
|
|||
ingredients = {} |
|||
results = [] |
|||
results_500 = [] |
|||
file = open('_input.txt', 'r') |
|||
|
|||
for line in file: |
|||
splits = line.split(' ') |
|||
ingredients.setdefault(splits[0], {'capacity' : int(splits[2].strip(",")), 'durability': int(splits[4].strip(",")), 'flavor': int(splits[6].strip(",")), 'texture' : int(splits[8].strip(",")), 'calories' : int(splits[10].strip(","))}) |
|||
|
|||
for perm in itertools.combinations_with_replacement(ingredients, 101): |
|||
ingredient_count = {} |
|||
for i in range(0, len(perm)-1): |
|||
ingredient_count.setdefault(perm[i], 0) |
|||
ingredient_count[perm[i]] += 1 |
|||
#print(ingredient_count) |
|||
current_score = 0 |
|||
capacity = 0 |
|||
durability = 0 |
|||
flavor = 0 |
|||
texture = 0 |
|||
calories = 0 |
|||
for k, v in ingredient_count.items(): |
|||
capacity += (v * ingredients[k]['capacity']) |
|||
durability += (v * ingredients[k]['durability']) |
|||
flavor += (v * ingredients[k]['flavor']) |
|||
texture += (v * ingredients[k]['texture']) |
|||
calories += (v * ingredients[k]['calories']) |
|||
|
|||
current_score = max(0, capacity) * max(0, durability) * max(0, flavor) * max(0, texture) |
|||
#print(current_score) |
|||
results.append([current_score, perm]) |
|||
|
|||
if calories == 500: |
|||
results_500.append([current_score, perm]) |
|||
|
|||
print( max(results) ) |
|||
print( max(results_500) ) |
|||
@ -0,0 +1,500 @@ |
|||
Sue 1: goldfish: 6, trees: 9, akitas: 0 |
|||
Sue 2: goldfish: 7, trees: 1, akitas: 0 |
|||
Sue 3: cars: 10, akitas: 6, perfumes: 7 |
|||
Sue 4: perfumes: 2, vizslas: 0, cars: 6 |
|||
Sue 5: goldfish: 1, trees: 3, perfumes: 10 |
|||
Sue 6: children: 9, vizslas: 7, cars: 9 |
|||
Sue 7: cars: 6, vizslas: 5, cats: 3 |
|||
Sue 8: akitas: 10, vizslas: 9, children: 3 |
|||
Sue 9: vizslas: 8, cats: 2, trees: 1 |
|||
Sue 10: perfumes: 10, trees: 6, cars: 4 |
|||
Sue 11: cars: 9, children: 1, cats: 1 |
|||
Sue 12: pomeranians: 4, akitas: 6, goldfish: 8 |
|||
Sue 13: cats: 10, children: 5, trees: 9 |
|||
Sue 14: perfumes: 8, vizslas: 3, samoyeds: 1 |
|||
Sue 15: vizslas: 2, perfumes: 8, trees: 3 |
|||
Sue 16: pomeranians: 10, trees: 9, samoyeds: 4 |
|||
Sue 17: akitas: 7, vizslas: 0, goldfish: 6 |
|||
Sue 18: trees: 5, vizslas: 9, cars: 0 |
|||
Sue 19: akitas: 3, goldfish: 9, trees: 10 |
|||
Sue 20: perfumes: 7, samoyeds: 3, vizslas: 10 |
|||
Sue 21: perfumes: 7, pomeranians: 10, akitas: 8 |
|||
Sue 22: vizslas: 6, trees: 8, akitas: 10 |
|||
Sue 23: goldfish: 0, trees: 4, children: 9 |
|||
Sue 24: goldfish: 7, pomeranians: 9, akitas: 4 |
|||
Sue 25: cars: 7, trees: 4, pomeranians: 4 |
|||
Sue 26: trees: 9, akitas: 9, pomeranians: 7 |
|||
Sue 27: samoyeds: 0, perfumes: 9, goldfish: 10 |
|||
Sue 28: cars: 5, trees: 7, vizslas: 1 |
|||
Sue 29: perfumes: 9, trees: 1, children: 6 |
|||
Sue 30: goldfish: 10, trees: 0, cars: 4 |
|||
Sue 31: akitas: 2, perfumes: 5, goldfish: 5 |
|||
Sue 32: goldfish: 0, akitas: 5, trees: 0 |
|||
Sue 33: vizslas: 2, akitas: 2, samoyeds: 3 |
|||
Sue 34: goldfish: 8, perfumes: 5, cars: 3 |
|||
Sue 35: akitas: 1, cats: 4, trees: 9 |
|||
Sue 36: cars: 4, vizslas: 4, goldfish: 7 |
|||
Sue 37: akitas: 5, perfumes: 7, trees: 3 |
|||
Sue 38: goldfish: 10, trees: 2, vizslas: 9 |
|||
Sue 39: goldfish: 4, pomeranians: 5, vizslas: 5 |
|||
Sue 40: perfumes: 5, samoyeds: 4, akitas: 6 |
|||
Sue 41: goldfish: 9, cars: 4, perfumes: 5 |
|||
Sue 42: trees: 6, pomeranians: 9, goldfish: 8 |
|||
Sue 43: perfumes: 7, pomeranians: 1, akitas: 2 |
|||
Sue 44: vizslas: 9, cars: 5, cats: 0 |
|||
Sue 45: akitas: 1, goldfish: 6, trees: 0 |
|||
Sue 46: akitas: 5, vizslas: 8, trees: 2 |
|||
Sue 47: trees: 9, akitas: 2, vizslas: 9 |
|||
Sue 48: goldfish: 10, trees: 5, akitas: 2 |
|||
Sue 49: cars: 7, vizslas: 2, perfumes: 6 |
|||
Sue 50: akitas: 5, goldfish: 6, perfumes: 0 |
|||
Sue 51: cars: 9, cats: 7, trees: 5 |
|||
Sue 52: akitas: 7, goldfish: 10, cars: 0 |
|||
Sue 53: cars: 10, cats: 4, perfumes: 2 |
|||
Sue 54: goldfish: 2, pomeranians: 5, perfumes: 10 |
|||
Sue 55: vizslas: 5, akitas: 4, cars: 8 |
|||
Sue 56: goldfish: 9, vizslas: 4, akitas: 5 |
|||
Sue 57: perfumes: 8, samoyeds: 7, cars: 9 |
|||
Sue 58: cars: 5, akitas: 7, perfumes: 8 |
|||
Sue 59: samoyeds: 8, cars: 10, vizslas: 10 |
|||
Sue 60: akitas: 6, samoyeds: 0, goldfish: 3 |
|||
Sue 61: trees: 8, pomeranians: 0, akitas: 2 |
|||
Sue 62: trees: 1, perfumes: 3, vizslas: 4 |
|||
Sue 63: vizslas: 6, samoyeds: 9, goldfish: 8 |
|||
Sue 64: goldfish: 7, trees: 6, vizslas: 3 |
|||
Sue 65: cars: 1, vizslas: 0, akitas: 6 |
|||
Sue 66: cats: 6, pomeranians: 4, cars: 9 |
|||
Sue 67: trees: 10, pomeranians: 7, samoyeds: 3 |
|||
Sue 68: pomeranians: 5, goldfish: 9, akitas: 1 |
|||
Sue 69: akitas: 1, vizslas: 0, trees: 9 |
|||
Sue 70: cats: 4, goldfish: 4, vizslas: 10 |
|||
Sue 71: vizslas: 7, perfumes: 7, trees: 8 |
|||
Sue 72: children: 2, vizslas: 9, cats: 3 |
|||
Sue 73: cars: 8, pomeranians: 0, perfumes: 6 |
|||
Sue 74: akitas: 1, pomeranians: 8, vizslas: 10 |
|||
Sue 75: vizslas: 5, perfumes: 5, cars: 7 |
|||
Sue 76: cars: 3, vizslas: 3, goldfish: 0 |
|||
Sue 77: akitas: 9, samoyeds: 1, pomeranians: 3 |
|||
Sue 78: trees: 0, vizslas: 0, akitas: 6 |
|||
Sue 79: pomeranians: 9, cars: 1, perfumes: 0 |
|||
Sue 80: perfumes: 10, trees: 1, cats: 0 |
|||
Sue 81: goldfish: 5, akitas: 9, trees: 0 |
|||
Sue 82: vizslas: 1, akitas: 6, children: 4 |
|||
Sue 83: samoyeds: 7, perfumes: 8, pomeranians: 4 |
|||
Sue 84: perfumes: 3, children: 3, cats: 7 |
|||
Sue 85: goldfish: 9, trees: 3, cars: 9 |
|||
Sue 86: cars: 0, perfumes: 9, vizslas: 0 |
|||
Sue 87: children: 3, trees: 4, akitas: 3 |
|||
Sue 88: trees: 1, samoyeds: 1, goldfish: 0 |
|||
Sue 89: akitas: 8, cars: 3, vizslas: 9 |
|||
Sue 90: pomeranians: 9, trees: 9, goldfish: 8 |
|||
Sue 91: goldfish: 7, trees: 10, children: 0 |
|||
Sue 92: cats: 9, cars: 7, perfumes: 7 |
|||
Sue 93: vizslas: 2, goldfish: 7, cats: 9 |
|||
Sue 94: akitas: 5, cars: 8, vizslas: 4 |
|||
Sue 95: goldfish: 7, vizslas: 1, perfumes: 2 |
|||
Sue 96: goldfish: 5, trees: 6, perfumes: 10 |
|||
Sue 97: trees: 0, perfumes: 7, cars: 0 |
|||
Sue 98: cars: 2, perfumes: 6, trees: 8 |
|||
Sue 99: trees: 10, children: 7, cats: 9 |
|||
Sue 100: samoyeds: 5, goldfish: 6, vizslas: 6 |
|||
Sue 101: cars: 10, perfumes: 9, vizslas: 3 |
|||
Sue 102: pomeranians: 6, trees: 1, samoyeds: 4 |
|||
Sue 103: cars: 2, perfumes: 1, goldfish: 5 |
|||
Sue 104: goldfish: 2, cars: 8, pomeranians: 2 |
|||
Sue 105: goldfish: 6, vizslas: 0, trees: 10 |
|||
Sue 106: trees: 10, akitas: 10, pomeranians: 0 |
|||
Sue 107: vizslas: 2, pomeranians: 10, trees: 3 |
|||
Sue 108: children: 3, vizslas: 8, akitas: 7 |
|||
Sue 109: perfumes: 2, akitas: 2, samoyeds: 3 |
|||
Sue 110: goldfish: 7, trees: 1, perfumes: 1 |
|||
Sue 111: akitas: 2, cars: 9, perfumes: 2 |
|||
Sue 112: children: 10, cars: 0, akitas: 3 |
|||
Sue 113: akitas: 9, vizslas: 4, children: 3 |
|||
Sue 114: pomeranians: 3, trees: 2, goldfish: 5 |
|||
Sue 115: perfumes: 8, cars: 6, trees: 0 |
|||
Sue 116: samoyeds: 6, children: 3, pomeranians: 1 |
|||
Sue 117: goldfish: 1, trees: 2, akitas: 1 |
|||
Sue 118: goldfish: 10, akitas: 10, samoyeds: 0 |
|||
Sue 119: vizslas: 10, perfumes: 6, cars: 0 |
|||
Sue 120: cars: 2, perfumes: 9, goldfish: 5 |
|||
Sue 121: vizslas: 2, trees: 2, cars: 6 |
|||
Sue 122: vizslas: 3, trees: 0, akitas: 2 |
|||
Sue 123: akitas: 5, samoyeds: 7, goldfish: 1 |
|||
Sue 124: goldfish: 8, samoyeds: 7, trees: 8 |
|||
Sue 125: trees: 3, goldfish: 8, perfumes: 5 |
|||
Sue 126: cats: 3, vizslas: 9, goldfish: 0 |
|||
Sue 127: pomeranians: 9, goldfish: 3, perfumes: 6 |
|||
Sue 128: vizslas: 4, cars: 8, goldfish: 5 |
|||
Sue 129: vizslas: 8, children: 5, perfumes: 8 |
|||
Sue 130: cars: 7, children: 7, cats: 3 |
|||
Sue 131: perfumes: 1, akitas: 8, vizslas: 9 |
|||
Sue 132: perfumes: 7, samoyeds: 10, pomeranians: 6 |
|||
Sue 133: cars: 5, perfumes: 3, goldfish: 7 |
|||
Sue 134: perfumes: 9, akitas: 2, cats: 3 |
|||
Sue 135: perfumes: 1, trees: 9, vizslas: 9 |
|||
Sue 136: akitas: 7, cars: 3, perfumes: 7 |
|||
Sue 137: vizslas: 9, goldfish: 8, cars: 5 |
|||
Sue 138: trees: 0, samoyeds: 1, cars: 3 |
|||
Sue 139: cars: 0, perfumes: 6, trees: 0 |
|||
Sue 140: pomeranians: 4, cars: 1, perfumes: 7 |
|||
Sue 141: vizslas: 10, akitas: 8, cats: 3 |
|||
Sue 142: trees: 1, cats: 6, vizslas: 5 |
|||
Sue 143: pomeranians: 9, cars: 7, perfumes: 9 |
|||
Sue 144: cars: 0, perfumes: 2, pomeranians: 1 |
|||
Sue 145: trees: 1, goldfish: 9, perfumes: 8 |
|||
Sue 146: cars: 8, children: 5, vizslas: 2 |
|||
Sue 147: perfumes: 2, goldfish: 5, cars: 0 |
|||
Sue 148: akitas: 2, perfumes: 7, pomeranians: 6 |
|||
Sue 149: goldfish: 8, cars: 0, trees: 1 |
|||
Sue 150: akitas: 6, perfumes: 5, trees: 0 |
|||
Sue 151: vizslas: 6, samoyeds: 8, akitas: 10 |
|||
Sue 152: trees: 7, akitas: 7, perfumes: 6 |
|||
Sue 153: goldfish: 9, cats: 9, cars: 3 |
|||
Sue 154: vizslas: 10, trees: 0, cars: 9 |
|||
Sue 155: perfumes: 3, children: 2, goldfish: 1 |
|||
Sue 156: goldfish: 7, perfumes: 5, akitas: 6 |
|||
Sue 157: cats: 10, trees: 1, goldfish: 0 |
|||
Sue 158: cats: 7, children: 7, vizslas: 6 |
|||
Sue 159: perfumes: 9, akitas: 0, cars: 0 |
|||
Sue 160: akitas: 3, goldfish: 10, pomeranians: 2 |
|||
Sue 161: goldfish: 10, cars: 6, perfumes: 3 |
|||
Sue 162: trees: 0, cars: 9, goldfish: 1 |
|||
Sue 163: cars: 8, perfumes: 9, vizslas: 5 |
|||
Sue 164: goldfish: 1, trees: 10, children: 6 |
|||
Sue 165: goldfish: 0, vizslas: 6, cars: 0 |
|||
Sue 166: akitas: 5, vizslas: 1, cars: 5 |
|||
Sue 167: vizslas: 1, samoyeds: 1, children: 4 |
|||
Sue 168: samoyeds: 7, vizslas: 7, akitas: 3 |
|||
Sue 169: goldfish: 3, cats: 9, trees: 2 |
|||
Sue 170: cars: 5, perfumes: 9, vizslas: 5 |
|||
Sue 171: goldfish: 7, cars: 6, perfumes: 10 |
|||
Sue 172: cats: 6, akitas: 1, children: 6 |
|||
Sue 173: cats: 4, goldfish: 1, children: 3 |
|||
Sue 174: cars: 2, pomeranians: 2, vizslas: 7 |
|||
Sue 175: trees: 0, children: 4, goldfish: 7 |
|||
Sue 176: children: 8, cars: 5, cats: 9 |
|||
Sue 177: pomeranians: 4, vizslas: 7, trees: 3 |
|||
Sue 178: vizslas: 6, perfumes: 10, akitas: 6 |
|||
Sue 179: cars: 4, akitas: 4, trees: 4 |
|||
Sue 180: akitas: 8, goldfish: 6, trees: 9 |
|||
Sue 181: perfumes: 3, vizslas: 10, cars: 3 |
|||
Sue 182: vizslas: 3, samoyeds: 3, goldfish: 7 |
|||
Sue 183: goldfish: 10, perfumes: 2, cats: 1 |
|||
Sue 184: goldfish: 5, trees: 1, perfumes: 1 |
|||
Sue 185: vizslas: 10, trees: 9, perfumes: 2 |
|||
Sue 186: goldfish: 6, perfumes: 9, trees: 1 |
|||
Sue 187: cars: 0, trees: 9, goldfish: 6 |
|||
Sue 188: cars: 0, trees: 1, vizslas: 9 |
|||
Sue 189: akitas: 7, vizslas: 2, trees: 0 |
|||
Sue 190: pomeranians: 5, perfumes: 8, akitas: 10 |
|||
Sue 191: vizslas: 5, akitas: 3, cats: 0 |
|||
Sue 192: children: 1, trees: 1, cars: 2 |
|||
Sue 193: cars: 3, goldfish: 9, trees: 2 |
|||
Sue 194: samoyeds: 3, akitas: 4, perfumes: 8 |
|||
Sue 195: trees: 1, vizslas: 8, akitas: 10 |
|||
Sue 196: akitas: 6, cars: 5, pomeranians: 0 |
|||
Sue 197: akitas: 5, vizslas: 5, cats: 1 |
|||
Sue 198: trees: 4, cars: 6, goldfish: 6 |
|||
Sue 199: cats: 7, cars: 5, goldfish: 6 |
|||
Sue 200: vizslas: 4, cats: 0, akitas: 9 |
|||
Sue 201: pomeranians: 1, perfumes: 4, children: 2 |
|||
Sue 202: cats: 1, perfumes: 4, vizslas: 3 |
|||
Sue 203: vizslas: 1, akitas: 9, children: 5 |
|||
Sue 204: perfumes: 8, cars: 7, trees: 4 |
|||
Sue 205: perfumes: 7, pomeranians: 5, cats: 9 |
|||
Sue 206: vizslas: 8, trees: 2, akitas: 2 |
|||
Sue 207: akitas: 6, vizslas: 2, perfumes: 10 |
|||
Sue 208: vizslas: 1, children: 7, akitas: 4 |
|||
Sue 209: perfumes: 4, trees: 2, children: 1 |
|||
Sue 210: goldfish: 0, vizslas: 2, samoyeds: 10 |
|||
Sue 211: cars: 8, perfumes: 3, trees: 1 |
|||
Sue 212: cars: 8, samoyeds: 5, pomeranians: 8 |
|||
Sue 213: akitas: 2, goldfish: 8, pomeranians: 2 |
|||
Sue 214: akitas: 6, pomeranians: 2, cars: 0 |
|||
Sue 215: trees: 10, pomeranians: 4, vizslas: 0 |
|||
Sue 216: perfumes: 0, cars: 8, trees: 0 |
|||
Sue 217: samoyeds: 8, akitas: 7, children: 10 |
|||
Sue 218: perfumes: 1, vizslas: 6, children: 0 |
|||
Sue 219: children: 1, goldfish: 4, trees: 1 |
|||
Sue 220: akitas: 10, goldfish: 10, trees: 5 |
|||
Sue 221: cars: 7, pomeranians: 6, perfumes: 3 |
|||
Sue 222: vizslas: 6, children: 0, akitas: 5 |
|||
Sue 223: perfumes: 9, cars: 1, trees: 6 |
|||
Sue 224: pomeranians: 1, trees: 0, vizslas: 0 |
|||
Sue 225: goldfish: 8, akitas: 4, perfumes: 10 |
|||
Sue 226: pomeranians: 7, cats: 7, children: 4 |
|||
Sue 227: trees: 0, akitas: 2, perfumes: 1 |
|||
Sue 228: vizslas: 6, cars: 10, perfumes: 9 |
|||
Sue 229: cars: 0, perfumes: 6, trees: 4 |
|||
Sue 230: pomeranians: 7, perfumes: 5, trees: 2 |
|||
Sue 231: goldfish: 9, cars: 6, trees: 7 |
|||
Sue 232: akitas: 1, vizslas: 5, cars: 3 |
|||
Sue 233: akitas: 7, samoyeds: 2, vizslas: 5 |
|||
Sue 234: akitas: 6, cats: 8, pomeranians: 0 |
|||
Sue 235: pomeranians: 5, akitas: 5, vizslas: 3 |
|||
Sue 236: goldfish: 5, trees: 6, akitas: 5 |
|||
Sue 237: goldfish: 9, perfumes: 5, cats: 5 |
|||
Sue 238: cats: 8, goldfish: 4, perfumes: 0 |
|||
Sue 239: samoyeds: 8, children: 6, pomeranians: 6 |
|||
Sue 240: akitas: 4, samoyeds: 10, trees: 8 |
|||
Sue 241: trees: 2, goldfish: 8, cars: 1 |
|||
Sue 242: perfumes: 2, cars: 0, akitas: 10 |
|||
Sue 243: pomeranians: 1, cars: 7, trees: 2 |
|||
Sue 244: trees: 9, vizslas: 2, akitas: 10 |
|||
Sue 245: cars: 9, pomeranians: 4, trees: 0 |
|||
Sue 246: cars: 9, pomeranians: 7, perfumes: 1 |
|||
Sue 247: trees: 0, goldfish: 1, akitas: 8 |
|||
Sue 248: vizslas: 1, cats: 4, akitas: 4 |
|||
Sue 249: cats: 6, children: 4, goldfish: 9 |
|||
Sue 250: vizslas: 1, cars: 10, samoyeds: 5 |
|||
Sue 251: cars: 0, goldfish: 1, vizslas: 7 |
|||
Sue 252: cars: 7, akitas: 9, vizslas: 10 |
|||
Sue 253: akitas: 7, vizslas: 2, perfumes: 5 |
|||
Sue 254: vizslas: 10, akitas: 5, samoyeds: 0 |
|||
Sue 255: pomeranians: 8, goldfish: 0, cats: 6 |
|||
Sue 256: cars: 10, goldfish: 8, vizslas: 9 |
|||
Sue 257: goldfish: 3, perfumes: 9, cats: 3 |
|||
Sue 258: trees: 6, goldfish: 6, cars: 6 |
|||
Sue 259: trees: 0, goldfish: 2, perfumes: 8 |
|||
Sue 260: trees: 5, akitas: 0, cars: 0 |
|||
Sue 261: pomeranians: 9, goldfish: 7, perfumes: 8 |
|||
Sue 262: perfumes: 8, vizslas: 6, goldfish: 2 |
|||
Sue 263: vizslas: 6, trees: 5, goldfish: 9 |
|||
Sue 264: vizslas: 4, perfumes: 7, cars: 9 |
|||
Sue 265: goldfish: 10, trees: 3, perfumes: 1 |
|||
Sue 266: trees: 10, akitas: 8, goldfish: 8 |
|||
Sue 267: goldfish: 4, trees: 0, samoyeds: 9 |
|||
Sue 268: vizslas: 1, trees: 0, goldfish: 8 |
|||
Sue 269: cars: 2, perfumes: 10, goldfish: 5 |
|||
Sue 270: perfumes: 7, cars: 2, vizslas: 1 |
|||
Sue 271: cars: 6, perfumes: 10, goldfish: 6 |
|||
Sue 272: samoyeds: 4, goldfish: 2, vizslas: 9 |
|||
Sue 273: perfumes: 4, goldfish: 4, vizslas: 1 |
|||
Sue 274: children: 4, cars: 4, perfumes: 3 |
|||
Sue 275: children: 8, vizslas: 3, trees: 2 |
|||
Sue 276: vizslas: 5, children: 7, perfumes: 3 |
|||
Sue 277: perfumes: 3, cats: 4, vizslas: 5 |
|||
Sue 278: cars: 1, samoyeds: 10, akitas: 2 |
|||
Sue 279: trees: 9, perfumes: 9, cars: 10 |
|||
Sue 280: vizslas: 5, trees: 0, perfumes: 6 |
|||
Sue 281: vizslas: 3, akitas: 10, pomeranians: 7 |
|||
Sue 282: trees: 1, children: 2, akitas: 8 |
|||
Sue 283: akitas: 9, goldfish: 6, cats: 5 |
|||
Sue 284: cars: 9, children: 10, pomeranians: 2 |
|||
Sue 285: pomeranians: 0, perfumes: 4, cars: 7 |
|||
Sue 286: perfumes: 0, vizslas: 10, akitas: 10 |
|||
Sue 287: cats: 2, perfumes: 3, trees: 5 |
|||
Sue 288: akitas: 9, vizslas: 8, samoyeds: 9 |
|||
Sue 289: perfumes: 6, children: 2, cars: 7 |
|||
Sue 290: akitas: 0, children: 5, cars: 5 |
|||
Sue 291: cars: 4, perfumes: 0, trees: 1 |
|||
Sue 292: cats: 0, cars: 8, perfumes: 6 |
|||
Sue 293: akitas: 9, cats: 5, children: 5 |
|||
Sue 294: akitas: 4, cars: 9, goldfish: 3 |
|||
Sue 295: cars: 2, akitas: 3, perfumes: 7 |
|||
Sue 296: perfumes: 4, cars: 7, goldfish: 10 |
|||
Sue 297: trees: 5, akitas: 8, vizslas: 1 |
|||
Sue 298: perfumes: 0, goldfish: 6, trees: 9 |
|||
Sue 299: perfumes: 6, samoyeds: 8, cars: 1 |
|||
Sue 300: goldfish: 10, perfumes: 4, akitas: 2 |
|||
Sue 301: cars: 3, trees: 0, goldfish: 8 |
|||
Sue 302: perfumes: 7, samoyeds: 2, vizslas: 7 |
|||
Sue 303: children: 10, goldfish: 7, perfumes: 2 |
|||
Sue 304: samoyeds: 8, vizslas: 2, cars: 1 |
|||
Sue 305: trees: 1, cats: 0, goldfish: 10 |
|||
Sue 306: trees: 4, perfumes: 2, cars: 7 |
|||
Sue 307: cars: 6, vizslas: 2, children: 6 |
|||
Sue 308: vizslas: 2, cars: 0, akitas: 7 |
|||
Sue 309: cars: 3, vizslas: 8, perfumes: 6 |
|||
Sue 310: goldfish: 7, perfumes: 7, vizslas: 3 |
|||
Sue 311: pomeranians: 10, trees: 2, cars: 0 |
|||
Sue 312: samoyeds: 2, vizslas: 9, akitas: 1 |
|||
Sue 313: cars: 4, pomeranians: 7, goldfish: 7 |
|||
Sue 314: akitas: 2, pomeranians: 9, samoyeds: 10 |
|||
Sue 315: akitas: 3, vizslas: 2, trees: 0 |
|||
Sue 316: cars: 0, perfumes: 4, pomeranians: 6 |
|||
Sue 317: akitas: 10, goldfish: 3, pomeranians: 7 |
|||
Sue 318: cars: 9, trees: 0, pomeranians: 9 |
|||
Sue 319: akitas: 3, vizslas: 7, children: 10 |
|||
Sue 320: vizslas: 0, akitas: 8, pomeranians: 4 |
|||
Sue 321: cars: 10, akitas: 9, vizslas: 3 |
|||
Sue 322: perfumes: 0, akitas: 8, vizslas: 6 |
|||
Sue 323: vizslas: 10, perfumes: 5, cars: 3 |
|||
Sue 324: akitas: 0, goldfish: 6, vizslas: 7 |
|||
Sue 325: perfumes: 9, vizslas: 5, pomeranians: 2 |
|||
Sue 326: vizslas: 6, goldfish: 10, pomeranians: 8 |
|||
Sue 327: vizslas: 10, cars: 1, akitas: 7 |
|||
Sue 328: trees: 1, perfumes: 10, cars: 10 |
|||
Sue 329: pomeranians: 5, samoyeds: 3, cars: 10 |
|||
Sue 330: akitas: 6, cars: 1, pomeranians: 4 |
|||
Sue 331: cars: 5, children: 2, trees: 0 |
|||
Sue 332: vizslas: 6, pomeranians: 1, perfumes: 0 |
|||
Sue 333: akitas: 7, trees: 1, cats: 9 |
|||
Sue 334: vizslas: 6, goldfish: 9, akitas: 7 |
|||
Sue 335: akitas: 3, samoyeds: 3, cars: 3 |
|||
Sue 336: samoyeds: 10, perfumes: 9, trees: 6 |
|||
Sue 337: vizslas: 2, cars: 9, akitas: 0 |
|||
Sue 338: akitas: 6, perfumes: 9, vizslas: 3 |
|||
Sue 339: cars: 3, samoyeds: 8, trees: 2 |
|||
Sue 340: cats: 7, perfumes: 8, cars: 9 |
|||
Sue 341: goldfish: 9, perfumes: 5, cars: 10 |
|||
Sue 342: trees: 0, akitas: 3, perfumes: 5 |
|||
Sue 343: perfumes: 2, children: 0, cars: 6 |
|||
Sue 344: goldfish: 8, trees: 8, perfumes: 0 |
|||
Sue 345: perfumes: 6, cars: 6, goldfish: 5 |
|||
Sue 346: vizslas: 8, trees: 1, cars: 6 |
|||
Sue 347: cars: 0, cats: 3, perfumes: 7 |
|||
Sue 348: children: 7, perfumes: 10, cars: 7 |
|||
Sue 349: pomeranians: 8, akitas: 5, children: 2 |
|||
Sue 350: perfumes: 9, pomeranians: 4, goldfish: 3 |
|||
Sue 351: perfumes: 8, pomeranians: 7, trees: 4 |
|||
Sue 352: samoyeds: 1, goldfish: 9, akitas: 8 |
|||
Sue 353: akitas: 6, goldfish: 10, vizslas: 8 |
|||
Sue 354: akitas: 7, cars: 2, goldfish: 6 |
|||
Sue 355: cars: 3, goldfish: 6, akitas: 5 |
|||
Sue 356: akitas: 2, goldfish: 9, pomeranians: 1 |
|||
Sue 357: goldfish: 10, cars: 6, pomeranians: 9 |
|||
Sue 358: trees: 0, children: 2, goldfish: 6 |
|||
Sue 359: samoyeds: 3, cars: 2, akitas: 4 |
|||
Sue 360: trees: 1, goldfish: 8, cars: 5 |
|||
Sue 361: akitas: 5, vizslas: 7, perfumes: 1 |
|||
Sue 362: cats: 5, vizslas: 9, children: 4 |
|||
Sue 363: goldfish: 9, perfumes: 3, vizslas: 9 |
|||
Sue 364: children: 7, samoyeds: 2, pomeranians: 10 |
|||
Sue 365: perfumes: 9, akitas: 10, pomeranians: 4 |
|||
Sue 366: cars: 10, trees: 3, cats: 4 |
|||
Sue 367: vizslas: 6, akitas: 10, perfumes: 5 |
|||
Sue 368: akitas: 9, vizslas: 9, children: 4 |
|||
Sue 369: goldfish: 8, trees: 2, perfumes: 5 |
|||
Sue 370: trees: 0, children: 4, cars: 8 |
|||
Sue 371: cats: 6, perfumes: 0, vizslas: 2 |
|||
Sue 372: akitas: 7, cars: 5, perfumes: 3 |
|||
Sue 373: cars: 0, perfumes: 4, pomeranians: 10 |
|||
Sue 374: akitas: 5, perfumes: 5, vizslas: 2 |
|||
Sue 375: goldfish: 7, trees: 10, pomeranians: 7 |
|||
Sue 376: cars: 8, trees: 1, pomeranians: 8 |
|||
Sue 377: cars: 0, akitas: 9, vizslas: 1 |
|||
Sue 378: akitas: 5, perfumes: 3, vizslas: 7 |
|||
Sue 379: trees: 2, goldfish: 8, pomeranians: 8 |
|||
Sue 380: akitas: 5, cars: 9, perfumes: 9 |
|||
Sue 381: cars: 2, perfumes: 6, trees: 3 |
|||
Sue 382: perfumes: 6, vizslas: 2, goldfish: 9 |
|||
Sue 383: akitas: 8, vizslas: 7, cats: 1 |
|||
Sue 384: akitas: 9, trees: 10, vizslas: 7 |
|||
Sue 385: cars: 0, perfumes: 7, vizslas: 2 |
|||
Sue 386: vizslas: 10, akitas: 4, perfumes: 9 |
|||
Sue 387: perfumes: 6, pomeranians: 5, samoyeds: 8 |
|||
Sue 388: vizslas: 10, trees: 9, goldfish: 9 |
|||
Sue 389: goldfish: 8, akitas: 4, perfumes: 10 |
|||
Sue 390: goldfish: 6, trees: 8, akitas: 1 |
|||
Sue 391: vizslas: 4, akitas: 10, goldfish: 7 |
|||
Sue 392: akitas: 1, vizslas: 6, samoyeds: 5 |
|||
Sue 393: trees: 6, cars: 3, akitas: 5 |
|||
Sue 394: goldfish: 9, trees: 3, cars: 5 |
|||
Sue 395: akitas: 6, samoyeds: 4, goldfish: 4 |
|||
Sue 396: akitas: 2, trees: 1, cats: 5 |
|||
Sue 397: cars: 0, children: 9, trees: 10 |
|||
Sue 398: pomeranians: 3, samoyeds: 9, goldfish: 10 |
|||
Sue 399: cars: 7, akitas: 4, goldfish: 8 |
|||
Sue 400: cars: 4, akitas: 5, vizslas: 4 |
|||
Sue 401: pomeranians: 5, akitas: 8, vizslas: 5 |
|||
Sue 402: cats: 7, cars: 6, goldfish: 6 |
|||
Sue 403: samoyeds: 8, perfumes: 4, cars: 5 |
|||
Sue 404: akitas: 10, goldfish: 4, trees: 2 |
|||
Sue 405: trees: 8, perfumes: 1, cars: 2 |
|||
Sue 406: trees: 0, perfumes: 9, pomeranians: 10 |
|||
Sue 407: perfumes: 4, trees: 7, goldfish: 3 |
|||
Sue 408: akitas: 1, perfumes: 3, cars: 5 |
|||
Sue 409: trees: 6, samoyeds: 3, cars: 9 |
|||
Sue 410: vizslas: 3, goldfish: 5, akitas: 7 |
|||
Sue 411: goldfish: 10, trees: 1, vizslas: 9 |
|||
Sue 412: cars: 0, akitas: 6, trees: 6 |
|||
Sue 413: goldfish: 7, trees: 0, cars: 3 |
|||
Sue 414: pomeranians: 10, samoyeds: 3, cars: 10 |
|||
Sue 415: perfumes: 6, trees: 9, cars: 4 |
|||
Sue 416: trees: 2, cars: 4, goldfish: 8 |
|||
Sue 417: goldfish: 2, cars: 9, cats: 5 |
|||
Sue 418: vizslas: 1, cars: 9, akitas: 0 |
|||
Sue 419: perfumes: 6, cats: 3, children: 9 |
|||
Sue 420: cats: 5, goldfish: 7, akitas: 9 |
|||
Sue 421: trees: 1, samoyeds: 6, pomeranians: 1 |
|||
Sue 422: trees: 10, goldfish: 6, children: 7 |
|||
Sue 423: cars: 8, goldfish: 7, vizslas: 3 |
|||
Sue 424: samoyeds: 9, akitas: 7, trees: 5 |
|||
Sue 425: akitas: 5, children: 4, perfumes: 9 |
|||
Sue 426: goldfish: 1, children: 9, cats: 2 |
|||
Sue 427: vizslas: 9, akitas: 7, goldfish: 9 |
|||
Sue 428: pomeranians: 7, akitas: 5, vizslas: 1 |
|||
Sue 429: vizslas: 7, goldfish: 7, cars: 9 |
|||
Sue 430: trees: 7, perfumes: 0, pomeranians: 5 |
|||
Sue 431: children: 9, perfumes: 5, vizslas: 7 |
|||
Sue 432: trees: 6, samoyeds: 7, cats: 1 |
|||
Sue 433: goldfish: 5, trees: 5, children: 6 |
|||
Sue 434: goldfish: 9, akitas: 7, cars: 3 |
|||
Sue 435: samoyeds: 10, perfumes: 2, cars: 0 |
|||
Sue 436: akitas: 5, pomeranians: 4, perfumes: 7 |
|||
Sue 437: vizslas: 5, cats: 6, perfumes: 5 |
|||
Sue 438: trees: 2, goldfish: 6, vizslas: 7 |
|||
Sue 439: samoyeds: 8, pomeranians: 10, goldfish: 1 |
|||
Sue 440: akitas: 6, children: 9, perfumes: 4 |
|||
Sue 441: cars: 2, goldfish: 9, children: 0 |
|||
Sue 442: goldfish: 7, cars: 2, vizslas: 8 |
|||
Sue 443: goldfish: 6, samoyeds: 3, perfumes: 2 |
|||
Sue 444: trees: 2, goldfish: 7, cars: 8 |
|||
Sue 445: trees: 2, pomeranians: 0, children: 0 |
|||
Sue 446: perfumes: 4, akitas: 4, goldfish: 6 |
|||
Sue 447: vizslas: 7, akitas: 9, cars: 3 |
|||
Sue 448: goldfish: 6, trees: 9, cars: 0 |
|||
Sue 449: samoyeds: 7, perfumes: 4, vizslas: 10 |
|||
Sue 450: akitas: 7, cars: 10, goldfish: 7 |
|||
Sue 451: goldfish: 4, children: 7, pomeranians: 4 |
|||
Sue 452: cats: 4, vizslas: 6, trees: 7 |
|||
Sue 453: cars: 1, trees: 10, goldfish: 9 |
|||
Sue 454: trees: 2, goldfish: 3, vizslas: 10 |
|||
Sue 455: pomeranians: 9, vizslas: 3, akitas: 2 |
|||
Sue 456: vizslas: 10, akitas: 2, goldfish: 1 |
|||
Sue 457: trees: 5, cats: 5, children: 8 |
|||
Sue 458: cars: 6, goldfish: 3, akitas: 9 |
|||
Sue 459: goldfish: 7, akitas: 2, cats: 7 |
|||
Sue 460: akitas: 1, cars: 5, children: 8 |
|||
Sue 461: cars: 8, perfumes: 0, goldfish: 6 |
|||
Sue 462: pomeranians: 6, cats: 2, perfumes: 6 |
|||
Sue 463: vizslas: 7, perfumes: 3, goldfish: 3 |
|||
Sue 464: akitas: 10, goldfish: 10, trees: 1 |
|||
Sue 465: vizslas: 0, akitas: 2, trees: 2 |
|||
Sue 466: perfumes: 6, akitas: 8, cars: 2 |
|||
Sue 467: goldfish: 1, cars: 10, perfumes: 3 |
|||
Sue 468: goldfish: 4, trees: 2, cars: 9 |
|||
Sue 469: perfumes: 6, pomeranians: 0, vizslas: 10 |
|||
Sue 470: samoyeds: 8, children: 0, akitas: 7 |
|||
Sue 471: children: 3, goldfish: 9, cats: 9 |
|||
Sue 472: samoyeds: 0, goldfish: 0, trees: 0 |
|||
Sue 473: trees: 3, goldfish: 4, vizslas: 1 |
|||
Sue 474: perfumes: 10, cars: 3, trees: 7 |
|||
Sue 475: akitas: 5, vizslas: 4, goldfish: 5 |
|||
Sue 476: children: 2, akitas: 7, vizslas: 3 |
|||
Sue 477: vizslas: 6, pomeranians: 9, trees: 6 |
|||
Sue 478: vizslas: 7, pomeranians: 6, akitas: 7 |
|||
Sue 479: trees: 2, perfumes: 2, children: 2 |
|||
Sue 480: cars: 8, cats: 5, vizslas: 0 |
|||
Sue 481: trees: 5, goldfish: 0, akitas: 3 |
|||
Sue 482: cars: 8, perfumes: 6, goldfish: 10 |
|||
Sue 483: goldfish: 0, cars: 3, perfumes: 10 |
|||
Sue 484: pomeranians: 1, samoyeds: 1, perfumes: 3 |
|||
Sue 485: trees: 0, akitas: 2, vizslas: 4 |
|||
Sue 486: cars: 3, vizslas: 8, goldfish: 1 |
|||
Sue 487: pomeranians: 9, vizslas: 2, children: 10 |
|||
Sue 488: akitas: 6, vizslas: 10, perfumes: 9 |
|||
Sue 489: goldfish: 6, vizslas: 4, cars: 2 |
|||
Sue 490: vizslas: 10, cats: 8, samoyeds: 1 |
|||
Sue 491: cats: 9, cars: 1, perfumes: 10 |
|||
Sue 492: goldfish: 6, cars: 9, pomeranians: 9 |
|||
Sue 493: children: 10, goldfish: 10, vizslas: 0 |
|||
Sue 494: pomeranians: 5, cars: 0, vizslas: 0 |
|||
Sue 495: vizslas: 7, perfumes: 6, samoyeds: 3 |
|||
Sue 496: trees: 1, cats: 4, cars: 10 |
|||
Sue 497: cats: 1, perfumes: 0, cars: 7 |
|||
Sue 498: perfumes: 7, vizslas: 6, cats: 9 |
|||
Sue 499: vizslas: 8, perfumes: 1, akitas: 3 |
|||
Sue 500: perfumes: 4, cars: 9, trees: 4 |
|||
@ -0,0 +1 @@ |
|||
[0, '100:'] [3, '405:'] |
|||
@ -0,0 +1,37 @@ |
|||
knowable_facts = [ 'children:', 'cats:', 'samoyeds:', 'pomeranians:', 'akitas:', 'vizslas:', 'goldfish:', 'trees:', 'cars:', 'perfumes:'] |
|||
known_facts = { 'children:' : 3, 'cats:' : 7, 'samoyeds:' : 2, 'pomeranians:' : 3, 'akitas:' : 0, 'vizslas:' : 0, 'goldfish:' : 5, 'trees:' : 3 , 'cars:' : 2, 'perfumes:' : 1 } |
|||
file = open('input.txt', 'r') |
|||
sues = {} |
|||
sue_score = [] |
|||
def fact_remembered(sue_key, key): |
|||
if sues[sue_key][key] == -1: |
|||
return False |
|||
else: |
|||
return True |
|||
|
|||
for line in file: |
|||
splits = line.split(' ') |
|||
sues.setdefault(splits[1], { 'children:' : -1, 'cats:' : -1, 'samoyeds:' : -1, 'pomeranians:' : -1, 'akitas:' : -1, 'vizslas:' : -1, 'goldfish:' : -1, 'trees:' : -1 , 'cars:' : -1, 'perfumes:' : -1 }) |
|||
|
|||
|
|||
for i in range(2, len(splits)-1, 2): |
|||
key = splits[i] |
|||
value = splits[i+1] |
|||
value = int(value.strip(',')) |
|||
sues[splits[1]][key] = value |
|||
|
|||
score = 0 |
|||
for fact in knowable_facts: |
|||
if fact_remembered(splits[1], fact): |
|||
if fact == 'cats:' or fact == 'trees:': |
|||
if sues[splits[1]][fact] > known_facts[fact]: |
|||
score += 1 |
|||
elif fact == 'pomeranians:' or fact == 'trees:': |
|||
if sues[splits[1]][fact] < known_facts[fact]: |
|||
score += 1 |
|||
elif sues[splits[1]][fact] == known_facts[fact]: |
|||
score += 1 |
|||
|
|||
sue_score.append([score, splits[1]]) |
|||
|
|||
print( min(sue_score), max(sue_score) ) |
|||
@ -0,0 +1,20 @@ |
|||
11 |
|||
30 |
|||
47 |
|||
31 |
|||
32 |
|||
36 |
|||
3 |
|||
1 |
|||
5 |
|||
3 |
|||
32 |
|||
36 |
|||
15 |
|||
11 |
|||
46 |
|||
26 |
|||
28 |
|||
1 |
|||
19 |
|||
3 |
|||
@ -0,0 +1,17 @@ |
|||
import itertools |
|||
containers = [] |
|||
combos = {} |
|||
file = open('input.txt', 'r') |
|||
|
|||
for line in file: |
|||
containers.append(int(line)) |
|||
|
|||
count = 0 |
|||
for i in range(2, len(containers)-1): |
|||
for perm in itertools.combinations(containers, i): |
|||
if sum(perm) == 150: |
|||
count += 1 |
|||
combos.setdefault(i, 0) |
|||
combos[i] += 1 |
|||
print(count) |
|||
print(combos) |
|||
File diff suppressed because it is too large
@ -0,0 +1,26 @@ |
|||
import os |
|||
import sys |
|||
|
|||
file = open('input.txt', 'r') |
|||
|
|||
wrapping_paper_area = 0; |
|||
ribbon_required = 0 |
|||
for line in file: |
|||
lwh_s = line.split('x') |
|||
lwh = [int(lwh_s[0]), int(lwh_s[1]), int(lwh_s[2])] |
|||
lwh.sort() |
|||
abc = {} |
|||
abc[0] = int(lwh[0])*int(lwh[1]) |
|||
abc[1] = int(lwh[1])*int(lwh[2]) |
|||
abc[2] = int(lwh[2])*int(lwh[0]) |
|||
|
|||
print("A: " + str(abc[0]) + " B: " + str(abc[1]) + " C: " + str(abc[2])) |
|||
smallest = min(abc[0], abc[1], abc[2]) |
|||
print("Smallest side: " + str(smallest)) |
|||
|
|||
wrapping_paper_area = wrapping_paper_area + ((abc[0]*2) + (abc[1]*2) +(abc[2]*2)) + smallest |
|||
ribbon_required = ribbon_required + ((lwh[0]*2) + (lwh[1]*2)) + (lwh[0]*lwh[1]*lwh[2]) |
|||
|
|||
|
|||
print("The elves need " + str(wrapping_paper_area) + " square feet of wrapping paper") |
|||
print("The elves need " + str(ribbon_required) + " feet of ribbon") |
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,71 @@ |
|||
import os |
|||
import sys |
|||
|
|||
file = open('in.txt', 'r') |
|||
input = file.read() |
|||
|
|||
x = 0 |
|||
y = 0 |
|||
|
|||
deliveries = {} |
|||
deliveries[str(x) + "," + str(y)] = 1 |
|||
|
|||
for char in input: |
|||
if char == "^": |
|||
y = y + 1 |
|||
elif char == "v": |
|||
y = y - 1 |
|||
elif char == ">": |
|||
x = x + 1 |
|||
elif char == "<": |
|||
x = x - 1 |
|||
|
|||
value = deliveries.get(str(x) + "," + str(y), 0) |
|||
deliveries[str(x) + "," + str(y)] = value + 1 |
|||
|
|||
print("Santa made it to " + str(len(deliveries)) + " houses") |
|||
|
|||
santa_x = 0 |
|||
santa_y = 0 |
|||
|
|||
robo_santa_x = 0 |
|||
robo_santa_y = 0 |
|||
|
|||
deliveries = {} |
|||
deliveries[str(santa_x) + "," + str(santa_y)] = 1 |
|||
deliveries[str(robo_santa_x) + "," + str(robo_santa_y)] = deliveries[str(santa_x) + "," + str(santa_y)] + 1 |
|||
|
|||
real_santa = True |
|||
|
|||
for char in input: |
|||
x = 0 |
|||
y = 0 |
|||
if real_santa == True: |
|||
x = santa_x |
|||
y = santa_y |
|||
else: |
|||
x = robo_santa_x |
|||
y = robo_santa_y |
|||
|
|||
if char == "^": |
|||
y = y + 1 |
|||
elif char == "v": |
|||
y = y - 1 |
|||
elif char == ">": |
|||
x = x + 1 |
|||
elif char == "<": |
|||
x = x - 1 |
|||
|
|||
value = deliveries.get(str(x) + "," + str(y), 0) |
|||
deliveries[str(x) + "," + str(y)] = value + 1 |
|||
|
|||
if real_santa == True: |
|||
santa_x = x |
|||
santa_y = y |
|||
else: |
|||
robo_santa_x = x |
|||
robo_santa_y = y |
|||
|
|||
real_santa = (not real_santa) |
|||
|
|||
print("Santa and Robo Santa made it to " + str(len(deliveries)) + " houses") |
|||
@ -0,0 +1,13 @@ |
|||
import hashlib |
|||
component = 1 |
|||
fount_it = False |
|||
while fount_it == False: |
|||
m = hashlib.md5() |
|||
m.update(str('iwrupvqb').encode('utf-8') + str(component).encode('utf-8')) |
|||
result = m.hexdigest() |
|||
print("Component: " + str(component) + " Result: " + result) |
|||
if(result.startswith('000000')): |
|||
fount_it = True |
|||
else: |
|||
component += 1 |
|||
print("Santa needs the number " + str(component)) |
|||
@ -0,0 +1,84 @@ |
|||
import threading |
|||
import queue |
|||
import hashlib |
|||
|
|||
Qin = queue.Queue() |
|||
Qout = queue.Queue() |
|||
Pool = [] |
|||
|
|||
def err_msg(): |
|||
trace= sys.exc_info()[2] |
|||
try: |
|||
exc_value=str(sys.exc_value) |
|||
except: |
|||
exc_value='' |
|||
return str(traceback.format_tb(trace)),str(sys.exc_type),exc_value |
|||
|
|||
def get_errors(): |
|||
try: |
|||
while 1: |
|||
yield Qerr.get_nowait() |
|||
except Queue.Empty: |
|||
pass |
|||
|
|||
def process_queue(): |
|||
flag='ok' |
|||
while flag !='stop': |
|||
try: |
|||
flag,item=Qin.get() #will wait here! |
|||
if flag=='ok': |
|||
m = hashlib.md5() |
|||
m.update(str('iwrupvqb').encode('utf-8') + str(component).encode('utf-8')) |
|||
result = m.hexdigest() |
|||
#print("Thread: " + str() + "Component: " + str(component) + " Result: " + result) |
|||
if(result.startswith('00000')): |
|||
Qout.put({'result': False, 'component': component}) |
|||
else: |
|||
Qout.put({'result': False, 'component': component}) |
|||
|
|||
except: |
|||
Qerr.put(err_msg()) |
|||
|
|||
def start_threads(amount=5): |
|||
for i in range(amount): |
|||
thread = threading.Thread(target=process_queue) |
|||
thread.start() |
|||
Pool.append(thread) |
|||
def put(data,flag='ok'): |
|||
Qin.put([flag,data]) |
|||
|
|||
def get(): return Qout.get() #will wait here! |
|||
|
|||
def get_all(): |
|||
try: |
|||
while 1: |
|||
yield Qout.get_nowait() |
|||
except Queue.Empty: |
|||
pass |
|||
def stop_threads(): |
|||
for i in range(len(Pool)): |
|||
Qin.put(('stop',None)) |
|||
while Pool: |
|||
time.sleep(1) |
|||
for index,the_thread in enumerate(Pool): |
|||
if the_thread.isAlive(): |
|||
continue |
|||
else: |
|||
del Pool[index] |
|||
break |
|||
|
|||
component = 9 |
|||
for i in (0,1,2,3,4,5,6,7,8,9): put(i) |
|||
|
|||
start_threads() |
|||
|
|||
found_it = False |
|||
while found_it == False: |
|||
ret = get() |
|||
if ret['result'] == True: |
|||
stop_threads() |
|||
found_it = True |
|||
print("Santa needs the number " + str(ret['component'])) |
|||
else: |
|||
component += 1 |
|||
put(component) |
|||
File diff suppressed because it is too large
@ -0,0 +1,45 @@ |
|||
import sys |
|||
import os |
|||
import re |
|||
|
|||
file = open('input.txt', 'r') |
|||
|
|||
vowles = re.compile(r"([aeiou])") |
|||
doubles = re.compile(r"(.)\1") |
|||
naughty_combos = re.compile(r"(ab)|(cd)|(pq)|(xy)") |
|||
|
|||
nice_words = 0 |
|||
for line in file: |
|||
vowel_count = len(re.findall(vowles, line)) |
|||
if vowel_count < 3: |
|||
continue |
|||
double_match = re.search(doubles, line) |
|||
if not double_match: |
|||
continue |
|||
naughty_match = re.search(naughty_combos, line) |
|||
if naughty_match: |
|||
continue |
|||
|
|||
nice_words += 1 |
|||
|
|||
file.close() |
|||
print("Santas list has " + str(nice_words) + " nice words on it") |
|||
|
|||
|
|||
file = open('input.txt', 'r') |
|||
|
|||
rule_1 = re.compile(r"(\w\w).*\1") |
|||
rule_2 = re.compile(r"(\w)\w\1") |
|||
|
|||
new_nice_words = 0 |
|||
for line in file: |
|||
rule_1_match = re.search(rule_1, line) |
|||
if not rule_1_match: |
|||
continue |
|||
rule_2_match = re.search(rule_2, line) |
|||
if not rule_2_match: |
|||
continue |
|||
|
|||
new_nice_words += 1 |
|||
|
|||
print("Santas list has " + str(new_nice_words) + " new nice words on it") |
|||
@ -0,0 +1,300 @@ |
|||
turn off 660,55 through 986,197 |
|||
turn off 341,304 through 638,850 |
|||
turn off 199,133 through 461,193 |
|||
toggle 322,558 through 977,958 |
|||
toggle 537,781 through 687,941 |
|||
turn on 226,196 through 599,390 |
|||
turn on 240,129 through 703,297 |
|||
turn on 317,329 through 451,798 |
|||
turn on 957,736 through 977,890 |
|||
turn on 263,530 through 559,664 |
|||
turn on 158,270 through 243,802 |
|||
toggle 223,39 through 454,511 |
|||
toggle 544,218 through 979,872 |
|||
turn on 313,306 through 363,621 |
|||
toggle 173,401 through 496,407 |
|||
toggle 333,60 through 748,159 |
|||
turn off 87,577 through 484,608 |
|||
turn on 809,648 through 826,999 |
|||
toggle 352,432 through 628,550 |
|||
turn off 197,408 through 579,569 |
|||
turn off 1,629 through 802,633 |
|||
turn off 61,44 through 567,111 |
|||
toggle 880,25 through 903,973 |
|||
turn on 347,123 through 864,746 |
|||
toggle 728,877 through 996,975 |
|||
turn on 121,895 through 349,906 |
|||
turn on 888,547 through 931,628 |
|||
toggle 398,782 through 834,882 |
|||
turn on 966,850 through 989,953 |
|||
turn off 891,543 through 914,991 |
|||
toggle 908,77 through 916,117 |
|||
turn on 576,900 through 943,934 |
|||
turn off 580,170 through 963,206 |
|||
turn on 184,638 through 192,944 |
|||
toggle 940,147 through 978,730 |
|||
turn off 854,56 through 965,591 |
|||
toggle 717,172 through 947,995 |
|||
toggle 426,987 through 705,998 |
|||
turn on 987,157 through 992,278 |
|||
toggle 995,774 through 997,784 |
|||
turn off 796,96 through 845,182 |
|||
turn off 451,87 through 711,655 |
|||
turn off 380,93 through 968,676 |
|||
turn on 263,468 through 343,534 |
|||
turn on 917,936 through 928,959 |
|||
toggle 478,7 through 573,148 |
|||
turn off 428,339 through 603,624 |
|||
turn off 400,880 through 914,953 |
|||
toggle 679,428 through 752,779 |
|||
turn off 697,981 through 709,986 |
|||
toggle 482,566 through 505,725 |
|||
turn off 956,368 through 993,516 |
|||
toggle 735,823 through 783,883 |
|||
turn off 48,487 through 892,496 |
|||
turn off 116,680 through 564,819 |
|||
turn on 633,865 through 729,930 |
|||
turn off 314,618 through 571,922 |
|||
toggle 138,166 through 936,266 |
|||
turn on 444,732 through 664,960 |
|||
turn off 109,337 through 972,497 |
|||
turn off 51,432 through 77,996 |
|||
turn off 259,297 through 366,744 |
|||
toggle 801,130 through 917,544 |
|||
toggle 767,982 through 847,996 |
|||
turn on 216,507 through 863,885 |
|||
turn off 61,441 through 465,731 |
|||
turn on 849,970 through 944,987 |
|||
toggle 845,76 through 852,951 |
|||
toggle 732,615 through 851,936 |
|||
toggle 251,128 through 454,778 |
|||
turn on 324,429 through 352,539 |
|||
toggle 52,450 through 932,863 |
|||
turn off 449,379 through 789,490 |
|||
turn on 317,319 through 936,449 |
|||
toggle 887,670 through 957,838 |
|||
toggle 671,613 through 856,664 |
|||
turn off 186,648 through 985,991 |
|||
turn off 471,689 through 731,717 |
|||
toggle 91,331 through 750,758 |
|||
toggle 201,73 through 956,524 |
|||
toggle 82,614 through 520,686 |
|||
toggle 84,287 through 467,734 |
|||
turn off 132,367 through 208,838 |
|||
toggle 558,684 through 663,920 |
|||
turn on 237,952 through 265,997 |
|||
turn on 694,713 through 714,754 |
|||
turn on 632,523 through 862,827 |
|||
turn on 918,780 through 948,916 |
|||
turn on 349,586 through 663,976 |
|||
toggle 231,29 through 257,589 |
|||
toggle 886,428 through 902,993 |
|||
turn on 106,353 through 236,374 |
|||
turn on 734,577 through 759,684 |
|||
turn off 347,843 through 696,912 |
|||
turn on 286,699 through 964,883 |
|||
turn on 605,875 through 960,987 |
|||
turn off 328,286 through 869,461 |
|||
turn off 472,569 through 980,848 |
|||
toggle 673,573 through 702,884 |
|||
turn off 398,284 through 738,332 |
|||
turn on 158,50 through 284,411 |
|||
turn off 390,284 through 585,663 |
|||
turn on 156,579 through 646,581 |
|||
turn on 875,493 through 989,980 |
|||
toggle 486,391 through 924,539 |
|||
turn on 236,722 through 272,964 |
|||
toggle 228,282 through 470,581 |
|||
toggle 584,389 through 750,761 |
|||
turn off 899,516 through 900,925 |
|||
turn on 105,229 through 822,846 |
|||
turn off 253,77 through 371,877 |
|||
turn on 826,987 through 906,992 |
|||
turn off 13,152 through 615,931 |
|||
turn on 835,320 through 942,399 |
|||
turn on 463,504 through 536,720 |
|||
toggle 746,942 through 786,998 |
|||
turn off 867,333 through 965,403 |
|||
turn on 591,477 through 743,692 |
|||
turn off 403,437 through 508,908 |
|||
turn on 26,723 through 368,814 |
|||
turn on 409,485 through 799,809 |
|||
turn on 115,630 through 704,705 |
|||
turn off 228,183 through 317,220 |
|||
toggle 300,649 through 382,842 |
|||
turn off 495,365 through 745,562 |
|||
turn on 698,346 through 744,873 |
|||
turn on 822,932 through 951,934 |
|||
toggle 805,30 through 925,421 |
|||
toggle 441,152 through 653,274 |
|||
toggle 160,81 through 257,587 |
|||
turn off 350,781 through 532,917 |
|||
toggle 40,583 through 348,636 |
|||
turn on 280,306 through 483,395 |
|||
toggle 392,936 through 880,955 |
|||
toggle 496,591 through 851,934 |
|||
turn off 780,887 through 946,994 |
|||
turn off 205,735 through 281,863 |
|||
toggle 100,876 through 937,915 |
|||
turn on 392,393 through 702,878 |
|||
turn on 956,374 through 976,636 |
|||
toggle 478,262 through 894,775 |
|||
turn off 279,65 through 451,677 |
|||
turn on 397,541 through 809,847 |
|||
turn on 444,291 through 451,586 |
|||
toggle 721,408 through 861,598 |
|||
turn on 275,365 through 609,382 |
|||
turn on 736,24 through 839,72 |
|||
turn off 86,492 through 582,712 |
|||
turn on 676,676 through 709,703 |
|||
turn off 105,710 through 374,817 |
|||
toggle 328,748 through 845,757 |
|||
toggle 335,79 through 394,326 |
|||
toggle 193,157 through 633,885 |
|||
turn on 227,48 through 769,743 |
|||
toggle 148,333 through 614,568 |
|||
toggle 22,30 through 436,263 |
|||
toggle 547,447 through 688,969 |
|||
toggle 576,621 through 987,740 |
|||
turn on 711,334 through 799,515 |
|||
turn on 541,448 through 654,951 |
|||
toggle 792,199 through 798,990 |
|||
turn on 89,956 through 609,960 |
|||
toggle 724,433 through 929,630 |
|||
toggle 144,895 through 201,916 |
|||
toggle 226,730 through 632,871 |
|||
turn off 760,819 through 828,974 |
|||
toggle 887,180 through 940,310 |
|||
toggle 222,327 through 805,590 |
|||
turn off 630,824 through 885,963 |
|||
turn on 940,740 through 954,946 |
|||
turn on 193,373 through 779,515 |
|||
toggle 304,955 through 469,975 |
|||
turn off 405,480 through 546,960 |
|||
turn on 662,123 through 690,669 |
|||
turn off 615,238 through 750,714 |
|||
turn on 423,220 through 930,353 |
|||
turn on 329,769 through 358,970 |
|||
toggle 590,151 through 704,722 |
|||
turn off 884,539 through 894,671 |
|||
toggle 449,241 through 984,549 |
|||
toggle 449,260 through 496,464 |
|||
turn off 306,448 through 602,924 |
|||
turn on 286,805 through 555,901 |
|||
toggle 722,177 through 922,298 |
|||
toggle 491,554 through 723,753 |
|||
turn on 80,849 through 174,996 |
|||
turn off 296,561 through 530,856 |
|||
toggle 653,10 through 972,284 |
|||
toggle 529,236 through 672,614 |
|||
toggle 791,598 through 989,695 |
|||
turn on 19,45 through 575,757 |
|||
toggle 111,55 through 880,871 |
|||
turn off 197,897 through 943,982 |
|||
turn on 912,336 through 977,605 |
|||
toggle 101,221 through 537,450 |
|||
turn on 101,104 through 969,447 |
|||
toggle 71,527 through 587,717 |
|||
toggle 336,445 through 593,889 |
|||
toggle 214,179 through 575,699 |
|||
turn on 86,313 through 96,674 |
|||
toggle 566,427 through 906,888 |
|||
turn off 641,597 through 850,845 |
|||
turn on 606,524 through 883,704 |
|||
turn on 835,775 through 867,887 |
|||
toggle 547,301 through 897,515 |
|||
toggle 289,930 through 413,979 |
|||
turn on 361,122 through 457,226 |
|||
turn on 162,187 through 374,746 |
|||
turn on 348,461 through 454,675 |
|||
turn off 966,532 through 985,537 |
|||
turn on 172,354 through 630,606 |
|||
turn off 501,880 through 680,993 |
|||
turn off 8,70 through 566,592 |
|||
toggle 433,73 through 690,651 |
|||
toggle 840,798 through 902,971 |
|||
toggle 822,204 through 893,760 |
|||
turn off 453,496 through 649,795 |
|||
turn off 969,549 through 990,942 |
|||
turn off 789,28 through 930,267 |
|||
toggle 880,98 through 932,434 |
|||
toggle 568,674 through 669,753 |
|||
turn on 686,228 through 903,271 |
|||
turn on 263,995 through 478,999 |
|||
toggle 534,675 through 687,955 |
|||
turn off 342,434 through 592,986 |
|||
toggle 404,768 through 677,867 |
|||
toggle 126,723 through 978,987 |
|||
toggle 749,675 through 978,959 |
|||
turn off 445,330 through 446,885 |
|||
turn off 463,205 through 924,815 |
|||
turn off 417,430 through 915,472 |
|||
turn on 544,990 through 912,999 |
|||
turn off 201,255 through 834,789 |
|||
turn off 261,142 through 537,862 |
|||
turn off 562,934 through 832,984 |
|||
turn off 459,978 through 691,980 |
|||
turn off 73,911 through 971,972 |
|||
turn on 560,448 through 723,810 |
|||
turn on 204,630 through 217,854 |
|||
turn off 91,259 through 611,607 |
|||
turn on 877,32 through 978,815 |
|||
turn off 950,438 through 974,746 |
|||
toggle 426,30 through 609,917 |
|||
toggle 696,37 through 859,201 |
|||
toggle 242,417 through 682,572 |
|||
turn off 388,401 through 979,528 |
|||
turn off 79,345 through 848,685 |
|||
turn off 98,91 through 800,434 |
|||
toggle 650,700 through 972,843 |
|||
turn off 530,450 through 538,926 |
|||
turn on 428,559 through 962,909 |
|||
turn on 78,138 through 92,940 |
|||
toggle 194,117 through 867,157 |
|||
toggle 785,355 through 860,617 |
|||
turn off 379,441 through 935,708 |
|||
turn off 605,133 through 644,911 |
|||
toggle 10,963 through 484,975 |
|||
turn off 359,988 through 525,991 |
|||
turn off 509,138 through 787,411 |
|||
toggle 556,467 through 562,773 |
|||
turn on 119,486 through 246,900 |
|||
turn on 445,561 through 794,673 |
|||
turn off 598,681 through 978,921 |
|||
turn off 974,230 through 995,641 |
|||
turn off 760,75 through 800,275 |
|||
toggle 441,215 through 528,680 |
|||
turn off 701,636 through 928,877 |
|||
turn on 165,753 through 202,780 |
|||
toggle 501,412 through 998,516 |
|||
toggle 161,105 through 657,395 |
|||
turn on 113,340 through 472,972 |
|||
toggle 384,994 through 663,999 |
|||
turn on 969,994 through 983,997 |
|||
turn on 519,600 through 750,615 |
|||
turn off 363,899 through 948,935 |
|||
turn on 271,845 through 454,882 |
|||
turn off 376,528 through 779,640 |
|||
toggle 767,98 through 854,853 |
|||
toggle 107,322 through 378,688 |
|||
turn off 235,899 through 818,932 |
|||
turn on 445,611 through 532,705 |
|||
toggle 629,387 through 814,577 |
|||
toggle 112,414 through 387,421 |
|||
toggle 319,184 through 382,203 |
|||
turn on 627,796 through 973,940 |
|||
toggle 602,45 through 763,151 |
|||
turn off 441,375 through 974,545 |
|||
toggle 871,952 through 989,998 |
|||
turn on 717,272 through 850,817 |
|||
toggle 475,711 through 921,882 |
|||
toggle 66,191 through 757,481 |
|||
turn off 50,197 through 733,656 |
|||
toggle 83,575 through 915,728 |
|||
turn on 777,812 through 837,912 |
|||
turn on 20,984 through 571,994 |
|||
turn off 446,432 through 458,648 |
|||
turn on 715,871 through 722,890 |
|||
toggle 424,675 through 740,862 |
|||
toggle 580,592 through 671,900 |
|||
toggle 296,687 through 906,775 |
|||
@ -0,0 +1,57 @@ |
|||
import sys |
|||
import os |
|||
import time |
|||
start = time.time() |
|||
grid = {} |
|||
brightness_grid = {} |
|||
for i in range(0, 1000): |
|||
for j in range (0, 1000): |
|||
grid[str(i)+','+str(j)] = False |
|||
brightness_grid[str(i)+','+str(j)] = 0 |
|||
|
|||
file = open('input.txt', 'r') |
|||
action = 0; |
|||
for line in file: |
|||
working_line = "" |
|||
if line.find("turn on") != -1: |
|||
action = 1 |
|||
working_line = line.replace('turn on', '') |
|||
elif line.find("turn off") != -1: |
|||
action = 0 |
|||
working_line = line.replace('turn off', '') |
|||
elif line.find("toggle") != -1: |
|||
action = 2 |
|||
working_line = line.replace('toggle', '') |
|||
|
|||
splits = working_line.split(' ') |
|||
start = splits[1].split(',') |
|||
end = splits[3].split(',') |
|||
|
|||
for i in range(int(start[0]), int(end[0])+1): |
|||
for j in range(int(start[1]), int(end[1])+1): |
|||
if action == 1: |
|||
grid[str(i)+','+str(j)] = True |
|||
brightness_grid[str(i)+','+str(j)] += 1 |
|||
elif action == 0: |
|||
grid[str(i)+','+str(j)] = False |
|||
brightness_grid[str(i)+','+str(j)] -= 1 |
|||
if brightness_grid[str(i)+','+str(j)] < 0: |
|||
brightness_grid[str(i)+','+str(j)] = 0 |
|||
elif action == 2: |
|||
if grid[str(i)+','+str(j)] == True: |
|||
grid[str(i)+','+str(j)] = False |
|||
elif grid[str(i)+','+str(j)] == False: |
|||
grid[str(i)+','+str(j)] = True |
|||
|
|||
brightness_grid[str(i)+','+str(j)] += 2 |
|||
|
|||
lights_on = 0 |
|||
lumens = 0 |
|||
for i in range(0, 1000): |
|||
for j in range (0, 1000): |
|||
if grid[str(i)+','+str(j)] == True: |
|||
lights_on += 1 |
|||
lumens += brightness_grid[str(i)+','+str(j)] |
|||
print("Santa left " + str(lights_on) + " lights on") |
|||
print("Santa is prodcing " + str(lumens) + " lumens of light") |
|||
print(time.time() - start) |
|||
@ -0,0 +1,339 @@ |
|||
NOT dq -> dr |
|||
kg OR kf -> kh |
|||
ep OR eo -> eq |
|||
3176 -> b |
|||
NOT gs -> gt |
|||
dd OR do -> dp |
|||
eg AND ei -> ej |
|||
y AND ae -> ag |
|||
jx AND jz -> ka |
|||
lf RSHIFT 2 -> lg |
|||
z AND aa -> ac |
|||
dy AND ej -> el |
|||
bj OR bi -> bk |
|||
kk RSHIFT 3 -> km |
|||
NOT cn -> co |
|||
gn AND gp -> gq |
|||
cq AND cs -> ct |
|||
eo LSHIFT 15 -> es |
|||
lg OR lm -> ln |
|||
dy OR ej -> ek |
|||
NOT di -> dj |
|||
1 AND fi -> fj |
|||
kf LSHIFT 15 -> kj |
|||
NOT jy -> jz |
|||
NOT ft -> fu |
|||
fs AND fu -> fv |
|||
NOT hr -> hs |
|||
ck OR cl -> cm |
|||
jp RSHIFT 5 -> js |
|||
iv OR jb -> jc |
|||
is OR it -> iu |
|||
ld OR le -> lf |
|||
NOT fc -> fd |
|||
NOT dm -> dn |
|||
bn OR by -> bz |
|||
aj AND al -> am |
|||
cd LSHIFT 15 -> ch |
|||
jp AND ka -> kc |
|||
ci OR ct -> cu |
|||
gv AND gx -> gy |
|||
de AND dk -> dm |
|||
x RSHIFT 5 -> aa |
|||
et RSHIFT 2 -> eu |
|||
x RSHIFT 1 -> aq |
|||
ia OR ig -> ih |
|||
bk LSHIFT 1 -> ce |
|||
y OR ae -> af |
|||
NOT ca -> cb |
|||
e AND f -> h |
|||
ia AND ig -> ii |
|||
ck AND cl -> cn |
|||
NOT jh -> ji |
|||
z OR aa -> ab |
|||
1 AND en -> eo |
|||
ib AND ic -> ie |
|||
NOT eh -> ei |
|||
iy AND ja -> jb |
|||
NOT bb -> bc |
|||
ha OR gz -> hb |
|||
1 AND cx -> cy |
|||
NOT ax -> ay |
|||
ev OR ew -> ex |
|||
bn RSHIFT 2 -> bo |
|||
er OR es -> et |
|||
eu OR fa -> fb |
|||
jp OR ka -> kb |
|||
ea AND eb -> ed |
|||
k AND m -> n |
|||
et RSHIFT 3 -> ev |
|||
et RSHIFT 5 -> ew |
|||
hz RSHIFT 1 -> is |
|||
ki OR kj -> kk |
|||
NOT h -> i |
|||
lv LSHIFT 15 -> lz |
|||
as RSHIFT 1 -> bl |
|||
hu LSHIFT 15 -> hy |
|||
iw AND ix -> iz |
|||
lf RSHIFT 1 -> ly |
|||
fp OR fv -> fw |
|||
1 AND am -> an |
|||
ap LSHIFT 1 -> bj |
|||
u LSHIFT 1 -> ao |
|||
b RSHIFT 5 -> f |
|||
jq AND jw -> jy |
|||
iu RSHIFT 3 -> iw |
|||
ih AND ij -> ik |
|||
NOT iz -> ja |
|||
de OR dk -> dl |
|||
iu OR jf -> jg |
|||
as AND bd -> bf |
|||
b RSHIFT 3 -> e |
|||
jq OR jw -> jx |
|||
iv AND jb -> jd |
|||
cg OR ch -> ci |
|||
iu AND jf -> jh |
|||
lx -> a |
|||
1 AND cc -> cd |
|||
ly OR lz -> ma |
|||
NOT el -> em |
|||
1 AND bh -> bi |
|||
fb AND fd -> fe |
|||
lf OR lq -> lr |
|||
bn RSHIFT 3 -> bp |
|||
bn AND by -> ca |
|||
af AND ah -> ai |
|||
cf LSHIFT 1 -> cz |
|||
dw OR dx -> dy |
|||
gj AND gu -> gw |
|||
jg AND ji -> jj |
|||
jr OR js -> jt |
|||
bl OR bm -> bn |
|||
gj RSHIFT 2 -> gk |
|||
cj OR cp -> cq |
|||
gj OR gu -> gv |
|||
b OR n -> o |
|||
o AND q -> r |
|||
bi LSHIFT 15 -> bm |
|||
dy RSHIFT 1 -> er |
|||
cu AND cw -> cx |
|||
iw OR ix -> iy |
|||
hc OR hd -> he |
|||
0 -> c |
|||
db OR dc -> dd |
|||
kk RSHIFT 2 -> kl |
|||
eq LSHIFT 1 -> fk |
|||
dz OR ef -> eg |
|||
NOT ed -> ee |
|||
lw OR lv -> lx |
|||
fw AND fy -> fz |
|||
dz AND ef -> eh |
|||
jp RSHIFT 3 -> jr |
|||
lg AND lm -> lo |
|||
ci RSHIFT 2 -> cj |
|||
be AND bg -> bh |
|||
lc LSHIFT 1 -> lw |
|||
hm AND ho -> hp |
|||
jr AND js -> ju |
|||
1 AND io -> ip |
|||
cm AND co -> cp |
|||
ib OR ic -> id |
|||
NOT bf -> bg |
|||
fo RSHIFT 5 -> fr |
|||
ip LSHIFT 15 -> it |
|||
jt AND jv -> jw |
|||
jc AND je -> jf |
|||
du OR dt -> dv |
|||
NOT fx -> fy |
|||
aw AND ay -> az |
|||
ge LSHIFT 15 -> gi |
|||
NOT ak -> al |
|||
fm OR fn -> fo |
|||
ff AND fh -> fi |
|||
ci RSHIFT 5 -> cl |
|||
cz OR cy -> da |
|||
NOT ey -> ez |
|||
NOT ju -> jv |
|||
NOT ls -> lt |
|||
kk AND kv -> kx |
|||
NOT ii -> ij |
|||
kl AND kr -> kt |
|||
jk LSHIFT 15 -> jo |
|||
e OR f -> g |
|||
NOT bs -> bt |
|||
hi AND hk -> hl |
|||
hz OR ik -> il |
|||
ek AND em -> en |
|||
ao OR an -> ap |
|||
dv LSHIFT 1 -> ep |
|||
an LSHIFT 15 -> ar |
|||
fo RSHIFT 1 -> gh |
|||
NOT im -> in |
|||
kk RSHIFT 1 -> ld |
|||
hw LSHIFT 1 -> iq |
|||
ec AND ee -> ef |
|||
hb LSHIFT 1 -> hv |
|||
kb AND kd -> ke |
|||
x AND ai -> ak |
|||
dd AND do -> dq |
|||
aq OR ar -> as |
|||
iq OR ip -> ir |
|||
dl AND dn -> do |
|||
iu RSHIFT 5 -> ix |
|||
as OR bd -> be |
|||
NOT go -> gp |
|||
fk OR fj -> fl |
|||
jm LSHIFT 1 -> kg |
|||
NOT cv -> cw |
|||
dp AND dr -> ds |
|||
dt LSHIFT 15 -> dx |
|||
et RSHIFT 1 -> fm |
|||
dy RSHIFT 3 -> ea |
|||
fp AND fv -> fx |
|||
NOT p -> q |
|||
dd RSHIFT 2 -> de |
|||
eu AND fa -> fc |
|||
ba AND bc -> bd |
|||
dh AND dj -> dk |
|||
lr AND lt -> lu |
|||
he RSHIFT 1 -> hx |
|||
ex AND ez -> fa |
|||
df OR dg -> dh |
|||
fj LSHIFT 15 -> fn |
|||
NOT kx -> ky |
|||
gk OR gq -> gr |
|||
dy RSHIFT 2 -> dz |
|||
gh OR gi -> gj |
|||
lj AND ll -> lm |
|||
x OR ai -> aj |
|||
bz AND cb -> cc |
|||
1 AND lu -> lv |
|||
as RSHIFT 3 -> au |
|||
ce OR cd -> cf |
|||
il AND in -> io |
|||
dd RSHIFT 1 -> dw |
|||
NOT lo -> lp |
|||
c LSHIFT 1 -> t |
|||
dd RSHIFT 3 -> df |
|||
dd RSHIFT 5 -> dg |
|||
lh AND li -> lk |
|||
lf RSHIFT 5 -> li |
|||
dy RSHIFT 5 -> eb |
|||
NOT kt -> ku |
|||
at OR az -> ba |
|||
x RSHIFT 3 -> z |
|||
NOT lk -> ll |
|||
lb OR la -> lc |
|||
1 AND r -> s |
|||
lh OR li -> lj |
|||
ln AND lp -> lq |
|||
kk RSHIFT 5 -> kn |
|||
ea OR eb -> ec |
|||
ci AND ct -> cv |
|||
b RSHIFT 2 -> d |
|||
jp RSHIFT 1 -> ki |
|||
NOT cr -> cs |
|||
NOT jd -> je |
|||
jp RSHIFT 2 -> jq |
|||
jn OR jo -> jp |
|||
lf RSHIFT 3 -> lh |
|||
1 AND ds -> dt |
|||
lf AND lq -> ls |
|||
la LSHIFT 15 -> le |
|||
NOT fg -> fh |
|||
at AND az -> bb |
|||
au AND av -> ax |
|||
kw AND ky -> kz |
|||
v OR w -> x |
|||
kk OR kv -> kw |
|||
ks AND ku -> kv |
|||
kh LSHIFT 1 -> lb |
|||
1 AND kz -> la |
|||
NOT kc -> kd |
|||
x RSHIFT 2 -> y |
|||
et OR fe -> ff |
|||
et AND fe -> fg |
|||
NOT ac -> ad |
|||
jl OR jk -> jm |
|||
1 AND jj -> jk |
|||
bn RSHIFT 1 -> cg |
|||
NOT kp -> kq |
|||
ci RSHIFT 3 -> ck |
|||
ev AND ew -> ey |
|||
1 AND ke -> kf |
|||
cj AND cp -> cr |
|||
ir LSHIFT 1 -> jl |
|||
NOT gw -> gx |
|||
as RSHIFT 2 -> at |
|||
iu RSHIFT 1 -> jn |
|||
cy LSHIFT 15 -> dc |
|||
hg OR hh -> hi |
|||
ci RSHIFT 1 -> db |
|||
au OR av -> aw |
|||
km AND kn -> kp |
|||
gj RSHIFT 1 -> hc |
|||
iu RSHIFT 2 -> iv |
|||
ab AND ad -> ae |
|||
da LSHIFT 1 -> du |
|||
NOT bw -> bx |
|||
km OR kn -> ko |
|||
ko AND kq -> kr |
|||
bv AND bx -> by |
|||
kl OR kr -> ks |
|||
1 AND ht -> hu |
|||
df AND dg -> di |
|||
NOT ag -> ah |
|||
d OR j -> k |
|||
d AND j -> l |
|||
b AND n -> p |
|||
gf OR ge -> gg |
|||
gg LSHIFT 1 -> ha |
|||
bn RSHIFT 5 -> bq |
|||
bo OR bu -> bv |
|||
1 AND gy -> gz |
|||
s LSHIFT 15 -> w |
|||
NOT ie -> if |
|||
as RSHIFT 5 -> av |
|||
bo AND bu -> bw |
|||
hz AND ik -> im |
|||
bp AND bq -> bs |
|||
b RSHIFT 1 -> v |
|||
NOT l -> m |
|||
bp OR bq -> br |
|||
g AND i -> j |
|||
br AND bt -> bu |
|||
t OR s -> u |
|||
hz RSHIFT 5 -> ic |
|||
gk AND gq -> gs |
|||
fl LSHIFT 1 -> gf |
|||
he RSHIFT 3 -> hg |
|||
gz LSHIFT 15 -> hd |
|||
hf OR hl -> hm |
|||
1 AND gd -> ge |
|||
fo OR fz -> ga |
|||
id AND if -> ig |
|||
fo AND fz -> gb |
|||
gr AND gt -> gu |
|||
he OR hp -> hq |
|||
fq AND fr -> ft |
|||
ga AND gc -> gd |
|||
fo RSHIFT 2 -> fp |
|||
gl OR gm -> gn |
|||
hg AND hh -> hj |
|||
NOT hn -> ho |
|||
gl AND gm -> go |
|||
he RSHIFT 5 -> hh |
|||
NOT gb -> gc |
|||
hq AND hs -> ht |
|||
hz RSHIFT 3 -> ib |
|||
hz RSHIFT 2 -> ia |
|||
fq OR fr -> fs |
|||
hx OR hy -> hz |
|||
he AND hp -> hr |
|||
gj RSHIFT 5 -> gm |
|||
hf AND hl -> hn |
|||
hv OR hu -> hw |
|||
NOT hj -> hk |
|||
gj RSHIFT 3 -> gl |
|||
fo RSHIFT 3 -> fq |
|||
he RSHIFT 2 -> hf |
|||
@ -0,0 +1,339 @@ |
|||
NOT dq -> dr |
|||
kg OR kf -> kh |
|||
ep OR eo -> eq |
|||
3176 -> b |
|||
NOT gs -> gt |
|||
dd OR do -> dp |
|||
eg AND ei -> ej |
|||
y AND ae -> ag |
|||
jx AND jz -> ka |
|||
lf RSHIFT 2 -> lg |
|||
z AND aa -> ac |
|||
dy AND ej -> el |
|||
bj OR bi -> bk |
|||
kk RSHIFT 3 -> km |
|||
NOT cn -> co |
|||
gn AND gp -> gq |
|||
cq AND cs -> ct |
|||
eo LSHIFT 15 -> es |
|||
lg OR lm -> ln |
|||
dy OR ej -> ek |
|||
NOT di -> dj |
|||
1 AND fi -> fj |
|||
kf LSHIFT 15 -> kj |
|||
NOT jy -> jz |
|||
NOT ft -> fu |
|||
fs AND fu -> fv |
|||
NOT hr -> hs |
|||
ck OR cl -> cm |
|||
jp RSHIFT 5 -> js |
|||
iv OR jb -> jc |
|||
is OR it -> iu |
|||
ld OR le -> lf |
|||
NOT fc -> fd |
|||
NOT dm -> dn |
|||
bn OR by -> bz |
|||
aj AND al -> am |
|||
cd LSHIFT 15 -> ch |
|||
jp AND ka -> kc |
|||
ci OR ct -> cu |
|||
gv AND gx -> gy |
|||
de AND dk -> dm |
|||
x RSHIFT 5 -> aa |
|||
et RSHIFT 2 -> eu |
|||
x RSHIFT 1 -> aq |
|||
ia OR ig -> ih |
|||
bk LSHIFT 1 -> ce |
|||
y OR ae -> af |
|||
NOT ca -> cb |
|||
e AND f -> h |
|||
ia AND ig -> ii |
|||
ck AND cl -> cn |
|||
NOT jh -> ji |
|||
z OR aa -> ab |
|||
1 AND en -> eo |
|||
ib AND ic -> ie |
|||
NOT eh -> ei |
|||
iy AND ja -> jb |
|||
NOT bb -> bc |
|||
ha OR gz -> hb |
|||
1 AND cx -> cy |
|||
NOT ax -> ay |
|||
ev OR ew -> ex |
|||
bn RSHIFT 2 -> bo |
|||
er OR es -> et |
|||
eu OR fa -> fb |
|||
jp OR ka -> kb |
|||
ea AND eb -> ed |
|||
k AND m -> n |
|||
et RSHIFT 3 -> ev |
|||
et RSHIFT 5 -> ew |
|||
hz RSHIFT 1 -> is |
|||
ki OR kj -> kk |
|||
NOT h -> i |
|||
lv LSHIFT 15 -> lz |
|||
as RSHIFT 1 -> bl |
|||
hu LSHIFT 15 -> hy |
|||
iw AND ix -> iz |
|||
lf RSHIFT 1 -> ly |
|||
fp OR fv -> fw |
|||
1 AND am -> an |
|||
ap LSHIFT 1 -> bj |
|||
u LSHIFT 1 -> ao |
|||
b RSHIFT 5 -> f |
|||
jq AND jw -> jy |
|||
iu RSHIFT 3 -> iw |
|||
ih AND ij -> ik |
|||
NOT iz -> ja |
|||
de OR dk -> dl |
|||
iu OR jf -> jg |
|||
as AND bd -> bf |
|||
b RSHIFT 3 -> e |
|||
jq OR jw -> jx |
|||
iv AND jb -> jd |
|||
cg OR ch -> ci |
|||
iu AND jf -> jh |
|||
lx -> a |
|||
1 AND cc -> cd |
|||
ly OR lz -> ma |
|||
NOT el -> em |
|||
1 AND bh -> bi |
|||
fb AND fd -> fe |
|||
lf OR lq -> lr |
|||
bn RSHIFT 3 -> bp |
|||
bn AND by -> ca |
|||
af AND ah -> ai |
|||
cf LSHIFT 1 -> cz |
|||
dw OR dx -> dy |
|||
gj AND gu -> gw |
|||
jg AND ji -> jj |
|||
jr OR js -> jt |
|||
bl OR bm -> bn |
|||
gj RSHIFT 2 -> gk |
|||
cj OR cp -> cq |
|||
gj OR gu -> gv |
|||
b OR n -> o |
|||
o AND q -> r |
|||
bi LSHIFT 15 -> bm |
|||
dy RSHIFT 1 -> er |
|||
cu AND cw -> cx |
|||
iw OR ix -> iy |
|||
hc OR hd -> he |
|||
0 -> c |
|||
db OR dc -> dd |
|||
kk RSHIFT 2 -> kl |
|||
eq LSHIFT 1 -> fk |
|||
dz OR ef -> eg |
|||
NOT ed -> ee |
|||
lw OR lv -> lx |
|||
fw AND fy -> fz |
|||
dz AND ef -> eh |
|||
jp RSHIFT 3 -> jr |
|||
lg AND lm -> lo |
|||
ci RSHIFT 2 -> cj |
|||
be AND bg -> bh |
|||
lc LSHIFT 1 -> lw |
|||
hm AND ho -> hp |
|||
jr AND js -> ju |
|||
1 AND io -> ip |
|||
cm AND co -> cp |
|||
ib OR ic -> id |
|||
NOT bf -> bg |
|||
fo RSHIFT 5 -> fr |
|||
ip LSHIFT 15 -> it |
|||
jt AND jv -> jw |
|||
jc AND je -> jf |
|||
du OR dt -> dv |
|||
NOT fx -> fy |
|||
aw AND ay -> az |
|||
ge LSHIFT 15 -> gi |
|||
NOT ak -> al |
|||
fm OR fn -> fo |
|||
ff AND fh -> fi |
|||
ci RSHIFT 5 -> cl |
|||
cz OR cy -> da |
|||
NOT ey -> ez |
|||
NOT ju -> jv |
|||
NOT ls -> lt |
|||
kk AND kv -> kx |
|||
NOT ii -> ij |
|||
kl AND kr -> kt |
|||
jk LSHIFT 15 -> jo |
|||
e OR f -> g |
|||
NOT bs -> bt |
|||
hi AND hk -> hl |
|||
hz OR ik -> il |
|||
ek AND em -> en |
|||
ao OR an -> ap |
|||
dv LSHIFT 1 -> ep |
|||
an LSHIFT 15 -> ar |
|||
fo RSHIFT 1 -> gh |
|||
NOT im -> in |
|||
kk RSHIFT 1 -> ld |
|||
hw LSHIFT 1 -> iq |
|||
ec AND ee -> ef |
|||
hb LSHIFT 1 -> hv |
|||
kb AND kd -> ke |
|||
x AND ai -> ak |
|||
dd AND do -> dq |
|||
aq OR ar -> as |
|||
iq OR ip -> ir |
|||
dl AND dn -> do |
|||
iu RSHIFT 5 -> ix |
|||
as OR bd -> be |
|||
NOT go -> gp |
|||
fk OR fj -> fl |
|||
jm LSHIFT 1 -> kg |
|||
NOT cv -> cw |
|||
dp AND dr -> ds |
|||
dt LSHIFT 15 -> dx |
|||
et RSHIFT 1 -> fm |
|||
dy RSHIFT 3 -> ea |
|||
fp AND fv -> fx |
|||
NOT p -> q |
|||
dd RSHIFT 2 -> de |
|||
eu AND fa -> fc |
|||
ba AND bc -> bd |
|||
dh AND dj -> dk |
|||
lr AND lt -> lu |
|||
he RSHIFT 1 -> hx |
|||
ex AND ez -> fa |
|||
df OR dg -> dh |
|||
fj LSHIFT 15 -> fn |
|||
NOT kx -> ky |
|||
gk OR gq -> gr |
|||
dy RSHIFT 2 -> dz |
|||
gh OR gi -> gj |
|||
lj AND ll -> lm |
|||
x OR ai -> aj |
|||
bz AND cb -> cc |
|||
1 AND lu -> lv |
|||
as RSHIFT 3 -> au |
|||
ce OR cd -> cf |
|||
il AND in -> io |
|||
dd RSHIFT 1 -> dw |
|||
NOT lo -> lp |
|||
c LSHIFT 1 -> t |
|||
dd RSHIFT 3 -> df |
|||
dd RSHIFT 5 -> dg |
|||
lh AND li -> lk |
|||
lf RSHIFT 5 -> li |
|||
dy RSHIFT 5 -> eb |
|||
NOT kt -> ku |
|||
at OR az -> ba |
|||
x RSHIFT 3 -> z |
|||
NOT lk -> ll |
|||
lb OR la -> lc |
|||
1 AND r -> s |
|||
lh OR li -> lj |
|||
ln AND lp -> lq |
|||
kk RSHIFT 5 -> kn |
|||
ea OR eb -> ec |
|||
ci AND ct -> cv |
|||
b RSHIFT 2 -> d |
|||
jp RSHIFT 1 -> ki |
|||
NOT cr -> cs |
|||
NOT jd -> je |
|||
jp RSHIFT 2 -> jq |
|||
jn OR jo -> jp |
|||
lf RSHIFT 3 -> lh |
|||
1 AND ds -> dt |
|||
lf AND lq -> ls |
|||
la LSHIFT 15 -> le |
|||
NOT fg -> fh |
|||
at AND az -> bb |
|||
au AND av -> ax |
|||
kw AND ky -> kz |
|||
v OR w -> x |
|||
kk OR kv -> kw |
|||
ks AND ku -> kv |
|||
kh LSHIFT 1 -> lb |
|||
1 AND kz -> la |
|||
NOT kc -> kd |
|||
x RSHIFT 2 -> y |
|||
et OR fe -> ff |
|||
et AND fe -> fg |
|||
NOT ac -> ad |
|||
jl OR jk -> jm |
|||
1 AND jj -> jk |
|||
bn RSHIFT 1 -> cg |
|||
NOT kp -> kq |
|||
ci RSHIFT 3 -> ck |
|||
ev AND ew -> ey |
|||
1 AND ke -> kf |
|||
cj AND cp -> cr |
|||
ir LSHIFT 1 -> jl |
|||
NOT gw -> gx |
|||
as RSHIFT 2 -> at |
|||
iu RSHIFT 1 -> jn |
|||
cy LSHIFT 15 -> dc |
|||
hg OR hh -> hi |
|||
ci RSHIFT 1 -> db |
|||
au OR av -> aw |
|||
km AND kn -> kp |
|||
gj RSHIFT 1 -> hc |
|||
iu RSHIFT 2 -> iv |
|||
ab AND ad -> ae |
|||
da LSHIFT 1 -> du |
|||
NOT bw -> bx |
|||
km OR kn -> ko |
|||
ko AND kq -> kr |
|||
bv AND bx -> by |
|||
kl OR kr -> ks |
|||
1 AND ht -> hu |
|||
df AND dg -> di |
|||
NOT ag -> ah |
|||
d OR j -> k |
|||
d AND j -> l |
|||
b AND n -> p |
|||
gf OR ge -> gg |
|||
gg LSHIFT 1 -> ha |
|||
bn RSHIFT 5 -> bq |
|||
bo OR bu -> bv |
|||
1 AND gy -> gz |
|||
s LSHIFT 15 -> w |
|||
NOT ie -> if |
|||
as RSHIFT 5 -> av |
|||
bo AND bu -> bw |
|||
hz AND ik -> im |
|||
bp AND bq -> bs |
|||
b RSHIFT 1 -> v |
|||
NOT l -> m |
|||
bp OR bq -> br |
|||
g AND i -> j |
|||
br AND bt -> bu |
|||
t OR s -> u |
|||
hz RSHIFT 5 -> ic |
|||
gk AND gq -> gs |
|||
fl LSHIFT 1 -> gf |
|||
he RSHIFT 3 -> hg |
|||
gz LSHIFT 15 -> hd |
|||
hf OR hl -> hm |
|||
1 AND gd -> ge |
|||
fo OR fz -> ga |
|||
id AND if -> ig |
|||
fo AND fz -> gb |
|||
gr AND gt -> gu |
|||
he OR hp -> hq |
|||
fq AND fr -> ft |
|||
ga AND gc -> gd |
|||
fo RSHIFT 2 -> fp |
|||
gl OR gm -> gn |
|||
hg AND hh -> hj |
|||
NOT hn -> ho |
|||
gl AND gm -> go |
|||
he RSHIFT 5 -> hh |
|||
NOT gb -> gc |
|||
hq AND hs -> ht |
|||
hz RSHIFT 3 -> ib |
|||
hz RSHIFT 2 -> ia |
|||
fq OR fr -> fs |
|||
hx OR hy -> hz |
|||
he AND hp -> hr |
|||
gj RSHIFT 5 -> gm |
|||
hf AND hl -> hn |
|||
hv OR hu -> hw |
|||
NOT hj -> hk |
|||
gj RSHIFT 3 -> gl |
|||
fo RSHIFT 3 -> fq |
|||
he RSHIFT 2 -> hf |
|||
@ -0,0 +1,55 @@ |
|||
import time |
|||
start = time.time() |
|||
file = open('input.txt', 'r') |
|||
commands = {} |
|||
cached_output = {} |
|||
def string_or_int(value): |
|||
if value.isdigit(): return int(value) |
|||
else: return value |
|||
|
|||
def parse_command(output, operator, string): |
|||
splits = string.split(" ") |
|||
commands[output] = {} |
|||
commands[output]['operator'] = operator |
|||
if operator == "ASSIGN": |
|||
commands[output]['value_1'] = string_or_int(splits[0]) |
|||
elif operator == "NOT": |
|||
commands[output]['value_1'] = string_or_int(splits[1]) |
|||
elif operator == "AND" or operator == "OR" or operator == "LSHIFT" or operator == "RSHIFT": |
|||
commands[output]['value_1'] = string_or_int(splits[0]) |
|||
commands[output]['value_2'] = string_or_int(splits[2]) |
|||
|
|||
for line in file: |
|||
splits = line.split(" ") |
|||
output = splits[len(splits)-1] |
|||
output = output.strip() |
|||
if line.find("NOT") != -1: parse_command(output, "NOT", line) |
|||
elif line.find("AND") != -1: parse_command(output, "AND", line) |
|||
elif line.find("OR") != -1: parse_command(output, "OR", line) |
|||
elif line.find("LSHIFT") != -1: parse_command(output, "LSHIFT", line) |
|||
elif line.find("RSHIFT") != -1: parse_command(output, "RSHIFT", line) |
|||
else: parse_command(output, "ASSIGN", line) |
|||
|
|||
def calc_and_cache_output(key): |
|||
if isinstance( key, int ): cached_output[key] = key |
|||
else: cached_output[key] = calc_output(key) |
|||
return cached_output[key] |
|||
|
|||
def calc_output(key): |
|||
if key in cached_output: return cached_output[key] |
|||
command = commands[key] |
|||
operator = command['operator'] |
|||
if operator == "ASSIGN": return calc_and_cache_output(command['value_1']) |
|||
elif operator == "NOT": return ~calc_and_cache_output(command['value_1']) |
|||
elif operator == "AND": return calc_and_cache_output(command['value_1']) & calc_and_cache_output(command['value_2']) |
|||
elif operator == "OR": return calc_and_cache_output(command['value_1']) | calc_and_cache_output(command['value_2']) |
|||
elif operator == "LSHIFT": return calc_and_cache_output(command['value_1']) << calc_and_cache_output(command['value_2']) |
|||
elif operator == "RSHIFT": return calc_and_cache_output(command['value_1']) >> calc_and_cache_output(command['value_2']) |
|||
|
|||
value = calc_output('a') |
|||
print("Value of a is: " + str(value)) |
|||
cached_output = {} |
|||
cached_output['b'] = value |
|||
value = calc_output('a') |
|||
print("Value of a is: " + str(value)) |
|||
print(time.time() - start) |
|||
@ -0,0 +1,300 @@ |
|||
"qxfcsmh" |
|||
"ffsfyxbyuhqkpwatkjgudo" |
|||
"byc\x9dyxuafof\\\xa6uf\\axfozomj\\olh\x6a" |
|||
"jtqvz" |
|||
"uzezxa\"jgbmojtwyfbfguz" |
|||
"vqsremfk\x8fxiknektafj" |
|||
"wzntebpxnnt\"vqndz\"i\x47vvjqo\"" |
|||
"higvez\"k\"riewqk" |
|||
"dlkrbhbrlfrp\\damiauyucwhty" |
|||
"d\"" |
|||
"qlz" |
|||
"ku" |
|||
"yy\"\"uoao\"uripabop" |
|||
"saduyrntuswlnlkuppdro\\sicxosted" |
|||
"tj" |
|||
"zzphopswlwdhebwkxeurvizdv" |
|||
"xfoheirjoakrpofles\"nfu" |
|||
"q\xb7oh\"p\xce\"n" |
|||
"qeendp\"ercwgywdjeylxcv" |
|||
"dcmem" |
|||
"\"i\x13r\"l" |
|||
"ikso\xdcbvqnbrjduh\"uqudzki\xderwk" |
|||
"wfdsn" |
|||
"pwynglklryhtsqbno" |
|||
"hcoj\x63iccz\"v\"ttr" |
|||
"zf\x23\\hlj\\kkce\\d\\asy\"yyfestwcdxyfj" |
|||
"xs" |
|||
"m\"tvltapxdvtrxiy" |
|||
"bmud" |
|||
"k\"a" |
|||
"b\"oas" |
|||
"\"yexnjjupoqsxyqnquy\"uzfdvetqrc" |
|||
"vdw\xe3olxfgujaj" |
|||
"qomcxdnd\"\\cfoe\"" |
|||
"fpul" |
|||
"m\"avamefphkpv" |
|||
"vvdnb\\x\\uhnxfw\"dpubfkxfmeuhnxisd" |
|||
"hey\\" |
|||
"ldaeigghlfey" |
|||
"eure\"hoy\xa5iezjp\\tm" |
|||
"yygb\"twbj\\r\"\x10gmxuhmp\"" |
|||
"weirebp\x39mqonbtmfmd" |
|||
"ltuz\\hs\"e" |
|||
"ysvmpc" |
|||
"g\x8amjtt\"megl\"omsaihifwa" |
|||
"yimmm" |
|||
"iiyqfalh" |
|||
"cwknlaaf" |
|||
"q\x37feg\xc6s\"xx" |
|||
"uayrgeurgyp\\oi" |
|||
"xhug\"pt\"axugllbdiggzhvy" |
|||
"kdaarqmsjfx\xc3d" |
|||
"\"vkwla" |
|||
"d\"" |
|||
"tmroz\"bvfinxoe\\mum\"wmm" |
|||
"\"n\"bbswxne\\p\\yr\"qhwpdd" |
|||
"skzlkietklkqovjhvj\xfe" |
|||
"pbg\\pab\"bubqaf\"obzcwxwywbs\\dhtq" |
|||
"xxjidvqh\"lx\\wu\"ij" |
|||
"daef\x5fe\x5b\\kbeeb\x13qnydtboof" |
|||
"ogvazaqy\"j\x73" |
|||
"y" |
|||
"n\"tibetedldy\\gsamm\"nwu" |
|||
"wldkvgdtqulwkad" |
|||
"dpmxnj" |
|||
"twybw\"cdvf\"mjdajurokbce" |
|||
"ru\"\\lasij\"i" |
|||
"roc\\vra\\lhrm" |
|||
"pbkt\x60booz\"fjlkc" |
|||
"j\x4dytvjwrzt" |
|||
"\\uiwjkniumxcs" |
|||
"cbhm\"nexccior\"v\"j\"nazxilmfp\x47" |
|||
"qdxngevzrlgoq" |
|||
"\"lrzxftytpobsdfyrtdqpjbpuwmm\x9e" |
|||
"mdag\x0asnck\xc2ggj\"slb\"fjy" |
|||
"wyqkhjuazdtcgkcxvjkpnjdae" |
|||
"aixfk\xc0iom\x21vueob" |
|||
"dkiiakyjpkffqlluhaetires" |
|||
"ysspv\"lysgkvnmwbbsy" |
|||
"gy\"ryexcjjxdm\"xswssgtr" |
|||
"s" |
|||
"ddxv" |
|||
"qwt\"\x27puilb\"pslmbrsxhrz" |
|||
"qdg\xc9e\\qwtknlvkol\x54oqvmchn\\" |
|||
"lvo" |
|||
"b" |
|||
"fk\"aa\"\"yenwch\\\\on" |
|||
"srig\x63hpwaavs\\\x80qzk\"xa\"\xe6u\\wr" |
|||
"yxjxuj\"ghyhhxfj\"\xa6qvatre" |
|||
"yoktqxjxkzrklkoeroil" |
|||
"\"jfmik\"" |
|||
"smgseztzdwldikbqrh\"" |
|||
"jftahgctf\"hoqy" |
|||
"tcnhicr\"znpgckt\"ble" |
|||
"vqktnkodh\"lo\"a\\bkmdjqqnsqr" |
|||
"ztnirfzqq" |
|||
"s" |
|||
"xx" |
|||
"iqj\"y\\hqgzflwrdsusasekyrxbp\\ad" |
|||
"\\xzjhlaiynkioz\"\"bxepzimvgwt" |
|||
"s\x36rbw" |
|||
"mniieztwrisvdx" |
|||
"atyfxioy\x2b\\" |
|||
"irde\x85\x5cvbah\\jekw\"ia" |
|||
"bdmftlhkwrprmpat\"prfaocvp" |
|||
"w\\k" |
|||
"umbpausy" |
|||
"zfauhpsangy" |
|||
"p\"zqyw" |
|||
"wtztypyqvnnxzvlvipnq\"zu" |
|||
"deicgwq\\oqvajpbov\\or\"kgplwu" |
|||
"mbzlfgpi\\\\zqcidjpzqdzxityxa" |
|||
"lfkxvhma" |
|||
"\xf2yduqzqr\"\\fak\"p\"n" |
|||
"mpajacfuxotonpadvng" |
|||
"anb\\telzvcdu\\a\xf2flfq" |
|||
"lrs\"ebethwpmuuc\"\x86ygr" |
|||
"qmvdbhtumzc\"ci" |
|||
"meet" |
|||
"yopg\x0fdxdq\"h\\ugsu\xffmolxjv" |
|||
"uhy" |
|||
"fzgidrtzycsireghazscvmwcfmw\\t" |
|||
"cqohkhpgvpru" |
|||
"bihyigtnvmevx\"xx" |
|||
"xz" |
|||
"zofomwotzuxsjk\"q\"mc\"js\"dnmalhxd" |
|||
"\\ktnddux\\fqvt\"ibnjntjcbn" |
|||
"ia" |
|||
"htjadnefwetyp\xd5kbrwfycbyy" |
|||
"\"\\hkuxqddnao" |
|||
"meqqsz\x83luecpgaem" |
|||
"cvks\x87frvxo\"svqivqsdpgwhukmju" |
|||
"sgmxiai\\o\"riufxwjfigr\xdf" |
|||
"fgywdfecqufccpcdn" |
|||
"faghjoq\x28abxnpxj" |
|||
"zuppgzcfb\"dctvp\"elup\"zxkopx" |
|||
"xqs\x45xxdqcihbwghmzoa" |
|||
"anbnlp\\cgcvm\"hc" |
|||
"xf\"fgrngwzys" |
|||
"nrxsjduedcy\x24" |
|||
"\x71sxl\"gj\"sds\"ulcruguz\\t\\ssvjcwhi" |
|||
"jhj\"msch" |
|||
"qpovolktfwyiuyicbfeeju\x01" |
|||
"nkyxmb\"qyqultgt\"nmvzvvnxnb" |
|||
"ycsrkbstgzqb\"uv\\cisn" |
|||
"s" |
|||
"ueptjnn\"\"sh" |
|||
"lp\"z\"d\"mxtxiy" |
|||
"yzjtvockdnvbubqabjourf\"k\"uoxwle" |
|||
"\x82\"wqm\"" |
|||
"\xb5cwtuks\x5fpgh" |
|||
"wd" |
|||
"tbvf" |
|||
"ttbmzdgn" |
|||
"vfpiyfdejyrlbgcdtwzbnm" |
|||
"uc" |
|||
"otdcmhpjagqix" |
|||
"\\\xb1qso\"s" |
|||
"scowax" |
|||
"behpstjdh\xccqlgnqjyz\"eesn" |
|||
"r\xe1cbnjwzveoomkzlo\\kxlfouhm" |
|||
"jgrl" |
|||
"kzqs\\r" |
|||
"ctscb\x7fthwkdyko\"\x62pkf\"d\xe6knmhurg" |
|||
"tc\"kw\x3ftt" |
|||
"bxb\x5ccl" |
|||
"jyrmfbphsldwpq" |
|||
"jylpvysl\"\"juducjg" |
|||
"en\\m\"kxpq\"wpb\\\"" |
|||
"madouht\"bmdwvnyqvpnawiphgac\"" |
|||
"vuxpk\"ltucrw" |
|||
"aae\x60arr" |
|||
"ttitnne\"kilkrgssnr\xfdurzh" |
|||
"oalw" |
|||
"pc\"\"gktkdykzbdpkwigucqni\"nxiqx" |
|||
"dbrsaj" |
|||
"bgzsowyxcbrvhtvekhsh\"qgd" |
|||
"kudfemvk\"\"\"hkbrbil\"chkqoa" |
|||
"zjzgj\\ekbhyfzufy" |
|||
"\\acos\"fqekuxqzxbmkbnn\x1ejzwrm" |
|||
"elxahvudn\"txtmomotgw" |
|||
"\x2eoxmwdhelpr\"cgi\xf7pzvb" |
|||
"eapheklx" |
|||
"hfvma\"mietvc\"tszbbm\"czex" |
|||
"h\"iiockj\\\xc1et" |
|||
"d\"rmjjftm" |
|||
"qlvhdcbqtyrhlc\\" |
|||
"yy\"rsucjtulm\"coryri\"eqjlbmk" |
|||
"tv" |
|||
"r\"bfuht\\jjgujp\"" |
|||
"kukxvuauamtdosngdjlkauylttaokaj" |
|||
"srgost\"\"rbkcqtlccu\x65ohjptstrjkzy" |
|||
"yxwxl\\yjilwwxffrjjuazmzjs" |
|||
"dxlw\\fkstu\"hjrtiafhyuoh\"sewabne" |
|||
"\x88sj\"v" |
|||
"rfzprz\xec\"oxqclu\"krzefp\\q" |
|||
"cfmhdbjuhrcymgxpylllyvpni" |
|||
"ucrmjvmimmcq\x88\xd9\"lz" |
|||
"lujtt\"" |
|||
"gvbqoixn\"pmledpjmo\"flydnwkfxllf" |
|||
"dvxqlbshhmelsk\x8big\"l" |
|||
"mx\x54lma\x8bbguxejg" |
|||
"\x66jdati\xeceieo" |
|||
"\"iyyupixei\x54ff" |
|||
"xohzf\"rbxsoksxamiu" |
|||
"vlhthspeshzbppa\x4drhqnohjop\"\"mfjd" |
|||
"f\"tvxxla\"vurian\"\"idjq\x3aptm\xc3olep" |
|||
"gzqz" |
|||
"kbq\\wogye\\altvi\\hbvmodny" |
|||
"j\xd8" |
|||
"ofjozdhkblvndl" |
|||
"hbitoupimbawimxlxqze" |
|||
"ypeleimnme" |
|||
"xfwdrzsc\\oxqamawyizvi\\y" |
|||
"enoikppx\xa1ixe\"yo\"gumye" |
|||
"fb" |
|||
"vzf" |
|||
"zxidr" |
|||
"cu\x31beirsywtskq" |
|||
"lxpjbvqzztafwezd" |
|||
"\\jyxeuo\x18bv" |
|||
"b\"vawc\"p\\\\giern\"b" |
|||
"odizunx\"\"t\\yicdn\"x\"sdiz" |
|||
"\"\"tebrtsi" |
|||
"ctyzsxv\xa6pegfkwsi\"tgyltaakytccb" |
|||
"htxwbofchvmzbppycccliyik\xe5a" |
|||
"ggsslefamsklezqkrd" |
|||
"rcep\"fnimwvvdx\"l" |
|||
"zyrzlqmd\x12egvqs\\llqyie" |
|||
"\x07gsqyrr\\rcyhyspsvn" |
|||
"butg\"" |
|||
"gb" |
|||
"gywkoxf\"jsg\\wtopxvumirqxlwz" |
|||
"rj\"ir\"wldwveair\x2es\"dhjrdehbqnzl" |
|||
"ru\"elktnsbxufk\\ejufjfjlevt\\lrzd" |
|||
"\"widsvok" |
|||
"oy\"\x81nuesvw" |
|||
"ay" |
|||
"syticfac\x1cfjsivwlmy\"pumsqlqqzx" |
|||
"m" |
|||
"rjjkfh\x78cf\x2brgceg\"jmdyas\"\\xlv\xb6p" |
|||
"tmuvo\"\x3ffdqdovjmdmkgpstotojkv\"as" |
|||
"jd\\ojvynhxllfzzxvbn\"wrpphcvx" |
|||
"pz" |
|||
"\"twr" |
|||
"n\\hdzmxe\"mzjjeadlz" |
|||
"fb\"rprxuagvahjnri" |
|||
"rfmexmjjgh\\xrnmyvnatrvfruflaqjnd" |
|||
"obbbde\"co\"qr\"qpiwjgqahqm\\jjp\"" |
|||
"vpbq\"\"y\"czk\\b\x52ed\"lnzepobp" |
|||
"syzeajzfarplydipny\"y\"\xe8ad" |
|||
"mpyodwb" |
|||
"\x47rakphlqqptd" |
|||
"wa\"oj\"aiy" |
|||
"a" |
|||
"ropozx" |
|||
"q\x51nbtlwa" |
|||
"etukvgx\\jqxlkq" |
|||
"\"tp\"rah\"pg\"s\"bpdtes\\tkasdhqd" |
|||
"dn\"qqpkikadowssb\xcah\"dzpsf\\ect\"jdh" |
|||
"pxunovbbrrn\\vullyn\"bno\"\"\"myfxlp\"" |
|||
"qaixyazuryvkmoulhcqaotegfj\\mpzm" |
|||
"bvfrbicutzbjwn\\oml\"cf\"d\"ezcpv\"j" |
|||
"rmbrdtneudemigdhelmb" |
|||
"aq\\aurmbhy" |
|||
"wujqvzw" |
|||
"gf\"tssmvm\"gm\"hu\x9a\xb7yjawsa" |
|||
"hrhqqxow\xe2gsydtdspcfqy\"zw\\ou" |
|||
"ianwwf\\yko\\tdujhhqdi" |
|||
"xylz\"zpvpab" |
|||
"lwuopbeeegp" |
|||
"aoop\x49jhhcexdmdtun" |
|||
"\\\\mouqqcsgmz" |
|||
"tltuvwhveau\x43b\"ymxjlcgiymcynwt" |
|||
"gsugerumpyuhtjljbhrdyoj" |
|||
"lnjm\xb8wg\"ajh" |
|||
"zmspue\"nfttdon\\b\"eww" |
|||
"\"w\x67jwaq\x7ernmyvs\\rmdsuwydsd\"th" |
|||
"ogtgvtlmcvgllyv" |
|||
"z\"fqi\"rvddoehrciyl" |
|||
"yustxxtot\"muec\"xvfdbzunzvveq" |
|||
"mqslw" |
|||
"txqnyvzmibqgjs\xb6xy\x86nfalfyx" |
|||
"kzhehlmkholov" |
|||
"plpmywcnirrjutjguosh\\" |
|||
"pydbnqofv\"dn\\m" |
|||
"aegqof" |
|||
"eambmxt\\dxagoogl\\zapfwwlmk" |
|||
"afbmqitxxqhddlozuxcpjxgh" |
|||
"vgts" |
|||
"bfdpqtoxzzhmzcilehnflna" |
|||
"s\"idpz" |
|||
"\xcfhgly\"nlmztwybx\"ecezmsxaqw" |
|||
"aackfgndqcqiy" |
|||
"\x22unqdlsrvgzfaohoffgxzfpir\"s" |
|||
"abh\"ydv\"kbpdhrerl" |
|||
"bdzpg" |
|||
"ekwgkywtmzp" |
|||
"wtoodejqmrrgslhvnk\"pi\"ldnogpth" |
|||
"njro\x68qgbx\xe4af\"\\suan" |
|||
@ -0,0 +1,12 @@ |
|||
import time |
|||
import codecs |
|||
start = time.time() |
|||
file = codecs.open('input.txt', encoding='ascii') |
|||
count = {'literals': 0, 'representations': 0, 'escaped': 0} |
|||
for line in file: |
|||
line = line.strip() |
|||
count['literals'] += len(line) |
|||
count['representations'] += len(codecs.decode(line.encode('ascii'), 'unicode_escape'))-2 |
|||
count['escaped'] += len(line.encode('unicode_escape').replace('"', '\\"'))+2 |
|||
print("Part 1: " + str(count['literals'] - count['representations']) + " Part 2: " + str(count['escaped'] - count['literals'])) |
|||
print(time.time() - start) |
|||
@ -0,0 +1,28 @@ |
|||
Faerun to Norrath = 129 |
|||
Faerun to Tristram = 58 |
|||
Faerun to AlphaCentauri = 13 |
|||
Faerun to Arbre = 24 |
|||
Faerun to Snowdin = 60 |
|||
Faerun to Tambi = 71 |
|||
Faerun to Straylight = 67 |
|||
Norrath to Tristram = 142 |
|||
Norrath to AlphaCentauri = 15 |
|||
Norrath to Arbre = 135 |
|||
Norrath to Snowdin = 75 |
|||
Norrath to Tambi = 82 |
|||
Norrath to Straylight = 54 |
|||
Tristram to AlphaCentauri = 118 |
|||
Tristram to Arbre = 122 |
|||
Tristram to Snowdin = 103 |
|||
Tristram to Tambi = 49 |
|||
Tristram to Straylight = 97 |
|||
AlphaCentauri to Arbre = 116 |
|||
AlphaCentauri to Snowdin = 12 |
|||
AlphaCentauri to Tambi = 18 |
|||
AlphaCentauri to Straylight = 91 |
|||
Arbre to Snowdin = 129 |
|||
Arbre to Tambi = 53 |
|||
Arbre to Straylight = 40 |
|||
Snowdin to Tambi = 15 |
|||
Snowdin to Straylight = 99 |
|||
Tambi to Straylight = 70 |
|||
@ -0,0 +1,28 @@ |
|||
Faerun to Tristram = 65 |
|||
Faerun to Tambi = 129 |
|||
Faerun to Norrath = 144 |
|||
Faerun to Snowdin = 71 |
|||
Faerun to Straylight = 137 |
|||
Faerun to AlphaCentauri = 3 |
|||
Faerun to Arbre = 149 |
|||
Tristram to Tambi = 63 |
|||
Tristram to Norrath = 4 |
|||
Tristram to Snowdin = 105 |
|||
Tristram to Straylight = 125 |
|||
Tristram to AlphaCentauri = 55 |
|||
Tristram to Arbre = 14 |
|||
Tambi to Norrath = 68 |
|||
Tambi to Snowdin = 52 |
|||
Tambi to Straylight = 65 |
|||
Tambi to AlphaCentauri = 22 |
|||
Tambi to Arbre = 143 |
|||
Norrath to Snowdin = 8 |
|||
Norrath to Straylight = 23 |
|||
Norrath to AlphaCentauri = 136 |
|||
Norrath to Arbre = 115 |
|||
Snowdin to Straylight = 101 |
|||
Snowdin to AlphaCentauri = 84 |
|||
Snowdin to Arbre = 96 |
|||
Straylight to AlphaCentauri = 107 |
|||
Straylight to Arbre = 14 |
|||
AlphaCentauri to Arbre = 46 |
|||
@ -0,0 +1,2 @@ |
|||
[207, ('Norrath', 'Straylight', 'Arbre', 'Faerun', 'AlphaCentauri', 'Snowdin', 'Tambi', 'Tristram')] [804, ('Straylight', 'Snowdin', 'Arbre', 'AlphaCentauri', 'Tristram', 'Norrath', 'Faerun', 'Tambi')] |
|||
0.09000015258789062 |
|||
@ -0,0 +1,27 @@ |
|||
import time |
|||
import itertools |
|||
start = time.time() |
|||
locations = {} |
|||
lengths = [] |
|||
cached = {} |
|||
file = open('day9_input.txt', 'r') |
|||
for line in file: |
|||
splits = line.split(" ") |
|||
locations.setdefault(splits[0], {'destinations' : {} }) |
|||
locations.setdefault(splits[2], {'destinations' : {} }) |
|||
locations[splits[0]]['destinations'].setdefault(splits[2], int(splits[4])) |
|||
locations[splits[2]]['destinations'].setdefault(splits[0], int(splits[4])) |
|||
|
|||
for perm in itertools.permutations(locations): |
|||
if perm in cached: |
|||
continue; |
|||
if perm[::-1] in cached: |
|||
continue; |
|||
cached[perm] = 1; |
|||
length = 0 |
|||
for i in range(0, len(perm)-1): |
|||
length += locations[perm[i]]['destinations'][perm[i+1]] |
|||
lengths.append([length, perm]) |
|||
|
|||
print( min(lengths), max(lengths) ) |
|||
print(time.time() - start) |
|||
@ -0,0 +1,18 @@ |
|||
--- Day 1: No Time for a Taxicab --- |
|||
|
|||
Santa's sleigh uses a very high-precision clock to guide its movements, and the clock's oscillator is regulated by stars. Unfortunately, the stars have been stolen... by the Easter Bunny. To save Christmas, Santa needs you to retrieve all fifty stars by December 25th. |
|||
|
|||
Collect stars by solving puzzles. Two puzzles will be made available on each day in the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck! |
|||
|
|||
You're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortunately, is as close as you can get - the instructions on the Easter Bunny Recruiting Document the Elves intercepted start here, and nobody had time to work them out further. |
|||
|
|||
The Document indicates that you should start at the given coordinates (where you just landed) and face North. Then, follow the provided sequence: either turn left (L) or right (R) 90 degrees, then walk forward the given number of blocks, ending at a new intersection. |
|||
|
|||
There's no time to follow such ridiculous instructions on foot, though, so you take a moment and work out the destination. Given that you can only walk on the street grid of the city, how far is the shortest path to the destination? |
|||
|
|||
For example: |
|||
|
|||
Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5 blocks away. |
|||
R2, R2, R2 leaves you 2 blocks due South of your starting position, which is 2 blocks away. |
|||
R5, L5, R5, R3 leaves you 12 blocks away. |
|||
How many blocks away is Easter Bunny HQ? |
|||
@ -0,0 +1 @@ |
|||
R4, R5, L5, L5, L3, R2, R1, R1, L5, R5, R2, L1, L3, L4, R3, L1, L1, R2, R3, R3, R1, L3, L5, R3, R1, L1, R1, R2, L1, L4, L5, R4, R2, L192, R5, L2, R53, R1, L5, R73, R5, L5, R186, L3, L2, R1, R3, L3, L3, R1, L4, L2, R3, L5, R4, R3, R1, L1, R5, R2, R1, R1, R1, R3, R2, L1, R5, R1, L5, R2, L2, L4, R3, L1, R4, L5, R4, R3, L5, L3, R4, R2, L5, L5, R2, R3, R5, R4, R2, R1, L1, L5, L2, L3, L4, L5, L4, L5, L1, R3, R4, R5, R3, L5, L4, L3, L1, L4, R2, R5, R5, R4, L2, L4, R3, R1, L2, R5, L5, R1, R1, L1, L5, L5, L2, L1, R5, R2, L4, L1, R4, R3, L3, R1, R5, L1, L4, R2, L3, R5, R3, R1, L3 |
|||
@ -0,0 +1,7 @@ |
|||
start_dir = "N" |
|||
file = open('Input.txt', 'r') |
|||
|
|||
for line in file: |
|||
print(line) |
|||
bob = line.split(",") |
|||
print(bob) |
|||
File diff suppressed because it is too large
@ -0,0 +1,21 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
input_file = open(os.path.join(dir, './input.txt'), 'r') |
|||
lines = input_file.readlines() |
|||
|
|||
last_depth = -1 |
|||
count = 0 |
|||
for line in lines: |
|||
int_value = int(line) |
|||
if last_depth == -1: |
|||
last_depth = int_value |
|||
continue |
|||
|
|||
if int_value > last_depth: |
|||
count = count+1 |
|||
|
|||
last_depth = int_value |
|||
|
|||
print(count) |
|||
@ -0,0 +1,20 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
input_file = open(os.path.join(dir, './input.txt'), 'r') |
|||
lines = input_file.readlines() |
|||
|
|||
new_list = [] |
|||
num_lines = len(lines) |
|||
count = 0 |
|||
for i in range(num_lines): |
|||
int_value = int(lines[i]) |
|||
if i + 2 >= num_lines: |
|||
break |
|||
|
|||
new_list.append(int(lines[i])+int(lines[i+1])+int(lines[i+2])) |
|||
if i >= 1 and new_list[i] > new_list[i-1]: |
|||
count = count+1 |
|||
|
|||
print(count) |
|||
File diff suppressed because it is too large
@ -0,0 +1,23 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
horizontal = 0 |
|||
depth = 0 |
|||
|
|||
for line in lines: |
|||
parts = line.split(' ') |
|||
command = parts[0] |
|||
distance = int(parts[1]) |
|||
if command == 'forward': |
|||
horizontal = horizontal + distance |
|||
elif command == 'up': |
|||
depth = depth - distance |
|||
elif command == 'down': |
|||
depth = depth + distance |
|||
|
|||
print(horizontal*depth) |
|||
@ -0,0 +1,26 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
horizontal = 0 |
|||
depth = 0 |
|||
aim = 0 |
|||
|
|||
for line in lines: |
|||
parts = line.split(' ') |
|||
command = parts[0] |
|||
distance = int(parts[1]) |
|||
if command == 'forward': |
|||
horizontal = horizontal + distance |
|||
depth = depth + (aim * distance) |
|||
elif command == 'up': |
|||
aim = aim - distance |
|||
elif command == 'down': |
|||
aim = aim + distance |
|||
|
|||
|
|||
print(horizontal*depth) |
|||
File diff suppressed because it is too large
@ -0,0 +1,38 @@ |
|||
import os |
|||
import numpy as np |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
counts = [] |
|||
gamma_string = "" |
|||
epsilon_string = "" |
|||
for line in lines: |
|||
clean_line = line.strip() |
|||
for i in range(len(clean_line)): |
|||
char = line[i] |
|||
if len(counts) <= i: |
|||
counts.append(0) |
|||
if char == '1': |
|||
counts[i] = counts[i]+1 |
|||
print(counts) |
|||
for item in counts: |
|||
if item > (len(lines)*0.5): |
|||
gamma_string = gamma_string + "1" |
|||
epsilon_string = epsilon_string + "0" |
|||
else: |
|||
gamma_string = gamma_string + "0" |
|||
epsilon_string = epsilon_string + "1" |
|||
|
|||
print(gamma_string) |
|||
gamma = int(gamma_string, 2) |
|||
print(gamma) |
|||
|
|||
print(epsilon_string) |
|||
epsilon = int(epsilon_string, 2) |
|||
print(epsilon) |
|||
|
|||
print(gamma*epsilon) |
|||
@ -0,0 +1,101 @@ |
|||
import os |
|||
import numpy as np |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
def countCommonBit(container, bit): |
|||
one_count=0 |
|||
zero_count=0 |
|||
for item in container: |
|||
clean_item = item.strip() |
|||
char = clean_item[bit] |
|||
if char == '1': |
|||
one_count = one_count+1 |
|||
if char == '0': |
|||
zero_count = zero_count+1 |
|||
return one_count, zero_count |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
line_length = len(lines[0].strip()) |
|||
|
|||
gamma_string = "" |
|||
epsilon_string = "" |
|||
for i in range(line_length): |
|||
ones, zeroes = countCommonBit(lines, i) |
|||
if ones > zeroes: |
|||
gamma_string = gamma_string + "1" |
|||
epsilon_string = epsilon_string + "0" |
|||
else: |
|||
gamma_string = gamma_string + "0" |
|||
epsilon_string = epsilon_string + "1" |
|||
|
|||
print(gamma_string) |
|||
gamma = int(gamma_string, 2) |
|||
print(gamma) |
|||
|
|||
print(epsilon_string) |
|||
epsilon = int(epsilon_string, 2) |
|||
print(epsilon) |
|||
|
|||
print(gamma*epsilon) |
|||
|
|||
|
|||
oxygen_candidates = lines.copy() |
|||
o2_string = "" |
|||
|
|||
for i in range(line_length): |
|||
# Calcualte the most common bit at i |
|||
ones, zeroes = countCommonBit(oxygen_candidates, i) |
|||
|
|||
if ones >= zeroes: |
|||
bit = '1' |
|||
else: |
|||
bit = '0' |
|||
|
|||
print(ones, zeroes, bit) |
|||
|
|||
toremove = [] |
|||
for line in oxygen_candidates: |
|||
clean_line = line.strip() |
|||
if clean_line[i] != bit: |
|||
toremove.append(line) |
|||
|
|||
oxygen_candidates = [x for x in oxygen_candidates if x not in toremove] |
|||
if len(oxygen_candidates) == 1: |
|||
o2_string = oxygen_candidates[0] |
|||
|
|||
co2_candidates = lines.copy() |
|||
co2_string = "" |
|||
for i in range(line_length): |
|||
# Calcualte the most common bit at i |
|||
ones, zeroes = countCommonBit(co2_candidates, i) |
|||
|
|||
if zeroes > ones: |
|||
bit = '1' |
|||
else: |
|||
bit = '0' |
|||
|
|||
print(ones, zeroes, bit) |
|||
|
|||
toremove = [] |
|||
for line in co2_candidates: |
|||
clean_line = line.strip() |
|||
if clean_line[i] != bit: |
|||
toremove.append(line) |
|||
|
|||
co2_candidates = [x for x in co2_candidates if x not in toremove] |
|||
if len(co2_candidates) == 1: |
|||
co2_string = co2_candidates[0] |
|||
|
|||
print(o2_string) |
|||
o2 = int(o2_string, 2) |
|||
print(o2) |
|||
|
|||
print(co2_string) |
|||
co2 = int(co2_string, 2) |
|||
print(co2) |
|||
|
|||
print(o2*co2) |
|||
@ -0,0 +1,19 @@ |
|||
7,4,9,5,11,17,23,2,0,14,21,24,10,16,13,6,15,25,12,22,18,20,8,19,3,26,1 |
|||
|
|||
22 13 17 11 0 |
|||
8 2 23 4 24 |
|||
21 9 14 16 7 |
|||
6 10 3 18 5 |
|||
1 12 20 15 19 |
|||
|
|||
3 15 0 2 22 |
|||
9 18 13 17 5 |
|||
19 8 7 25 23 |
|||
20 11 10 24 4 |
|||
14 21 16 12 6 |
|||
|
|||
14 21 17 24 4 |
|||
10 16 15 9 19 |
|||
18 8 23 26 20 |
|||
22 11 13 6 5 |
|||
2 0 12 3 7 |
|||
@ -0,0 +1,601 @@ |
|||
10,80,6,69,22,99,63,92,30,67,28,93,0,50,65,87,38,7,91,60,57,40,84,51,27,12,44,88,64,35,39,74,61,55,31,48,81,89,62,37,94,43,29,14,95,8,78,49,90,97,66,70,25,68,75,45,42,23,9,96,56,72,59,32,85,3,71,79,18,24,33,19,15,20,82,26,21,13,4,98,83,34,86,5,2,73,17,54,1,77,52,58,76,36,16,46,41,47,11,53 |
|||
|
|||
3 82 18 50 90 |
|||
16 37 52 67 28 |
|||
30 54 80 11 10 |
|||
60 79 7 65 58 |
|||
76 83 38 51 1 |
|||
|
|||
83 63 60 88 98 |
|||
70 87 5 99 14 |
|||
85 3 11 16 33 |
|||
72 69 97 36 49 |
|||
26 17 58 13 2 |
|||
|
|||
30 80 64 53 69 |
|||
36 0 32 46 70 |
|||
13 31 22 95 15 |
|||
12 35 5 84 21 |
|||
39 60 68 83 47 |
|||
|
|||
77 93 26 62 88 |
|||
87 76 80 10 63 |
|||
32 7 28 82 44 |
|||
43 30 31 16 74 |
|||
33 86 42 45 47 |
|||
|
|||
95 86 93 45 67 |
|||
20 58 63 35 97 |
|||
84 79 10 54 49 |
|||
48 66 75 23 61 |
|||
5 30 6 56 71 |
|||
|
|||
75 8 85 12 98 |
|||
37 51 91 24 23 |
|||
50 54 81 53 33 |
|||
72 57 52 25 6 |
|||
56 40 95 87 22 |
|||
|
|||
52 19 53 9 32 |
|||
23 99 48 26 73 |
|||
10 8 54 20 79 |
|||
49 45 34 74 90 |
|||
27 72 30 13 57 |
|||
|
|||
1 60 72 85 64 |
|||
62 39 56 93 78 |
|||
90 17 87 48 7 |
|||
9 13 45 23 69 |
|||
44 80 86 55 21 |
|||
|
|||
86 57 25 98 18 |
|||
42 75 38 9 66 |
|||
54 19 99 87 49 |
|||
33 32 53 8 6 |
|||
17 68 24 58 95 |
|||
|
|||
2 5 80 10 61 |
|||
27 16 40 67 78 |
|||
66 13 24 42 75 |
|||
25 7 35 11 85 |
|||
93 38 4 31 77 |
|||
|
|||
52 81 68 88 95 |
|||
82 50 46 87 20 |
|||
3 54 59 75 51 |
|||
92 93 38 72 4 |
|||
8 77 61 31 56 |
|||
|
|||
45 16 8 44 62 |
|||
92 23 42 20 74 |
|||
73 83 65 9 84 |
|||
55 13 21 70 59 |
|||
34 2 98 47 37 |
|||
|
|||
3 54 85 79 76 |
|||
42 29 45 12 46 |
|||
60 59 24 67 80 |
|||
89 15 99 68 48 |
|||
40 7 95 44 70 |
|||
|
|||
75 31 99 16 32 |
|||
80 56 43 30 36 |
|||
66 73 35 20 61 |
|||
67 28 89 23 54 |
|||
47 26 69 70 50 |
|||
|
|||
35 91 81 13 15 |
|||
73 1 37 68 28 |
|||
98 29 9 22 56 |
|||
12 59 82 67 31 |
|||
77 47 32 79 52 |
|||
|
|||
22 73 39 14 46 |
|||
99 0 27 34 40 |
|||
4 5 38 23 18 |
|||
64 26 89 59 79 |
|||
71 76 53 49 62 |
|||
|
|||
14 37 27 67 94 |
|||
76 16 79 61 83 |
|||
8 43 36 28 75 |
|||
10 4 24 56 44 |
|||
26 1 88 9 86 |
|||
|
|||
14 78 43 10 30 |
|||
56 29 1 61 9 |
|||
7 95 39 35 25 |
|||
33 87 71 97 21 |
|||
72 0 4 2 24 |
|||
|
|||
88 0 72 42 6 |
|||
53 79 58 80 20 |
|||
57 84 15 21 64 |
|||
98 17 43 8 95 |
|||
2 22 59 63 78 |
|||
|
|||
78 21 33 57 72 |
|||
10 69 85 73 16 |
|||
92 60 87 39 63 |
|||
40 15 77 80 56 |
|||
6 62 99 50 3 |
|||
|
|||
38 72 34 41 74 |
|||
90 29 9 6 91 |
|||
94 39 56 71 67 |
|||
53 21 22 32 10 |
|||
73 48 79 47 85 |
|||
|
|||
5 49 73 24 8 |
|||
75 12 11 47 69 |
|||
66 70 89 62 48 |
|||
99 3 29 88 30 |
|||
10 40 32 33 43 |
|||
|
|||
61 93 2 58 84 |
|||
47 62 51 16 82 |
|||
80 22 50 31 65 |
|||
76 85 83 4 40 |
|||
86 59 68 14 69 |
|||
|
|||
52 5 74 9 72 |
|||
84 69 38 1 27 |
|||
78 90 46 97 95 |
|||
57 21 32 93 29 |
|||
11 66 20 51 48 |
|||
|
|||
2 3 58 18 53 |
|||
11 96 63 33 13 |
|||
55 47 30 9 46 |
|||
98 85 79 19 65 |
|||
87 94 77 27 75 |
|||
|
|||
54 97 46 33 90 |
|||
99 93 22 0 51 |
|||
83 53 34 29 38 |
|||
35 65 80 82 9 |
|||
56 30 19 49 15 |
|||
|
|||
43 40 51 67 37 |
|||
4 30 85 24 21 |
|||
83 94 69 91 99 |
|||
13 32 82 86 12 |
|||
66 9 60 65 97 |
|||
|
|||
71 96 55 92 6 |
|||
83 8 63 56 18 |
|||
4 0 74 70 34 |
|||
15 87 44 80 29 |
|||
68 33 99 14 47 |
|||
|
|||
76 86 46 6 8 |
|||
90 80 77 30 62 |
|||
97 66 55 59 36 |
|||
1 43 27 15 57 |
|||
54 70 38 21 89 |
|||
|
|||
75 96 97 54 29 |
|||
62 43 69 57 88 |
|||
36 46 73 84 28 |
|||
18 98 38 63 4 |
|||
59 35 99 90 58 |
|||
|
|||
66 29 60 25 95 |
|||
91 4 87 76 41 |
|||
26 19 45 96 74 |
|||
7 82 3 81 31 |
|||
17 64 51 93 71 |
|||
|
|||
41 51 14 70 26 |
|||
35 38 50 25 13 |
|||
95 60 88 36 24 |
|||
66 94 62 97 83 |
|||
21 10 37 1 96 |
|||
|
|||
38 90 81 96 14 |
|||
40 82 71 18 83 |
|||
78 17 65 46 84 |
|||
7 92 63 79 49 |
|||
55 21 89 95 72 |
|||
|
|||
60 35 26 67 42 |
|||
59 77 15 6 75 |
|||
18 16 21 55 4 |
|||
98 49 38 43 30 |
|||
0 85 69 96 19 |
|||
|
|||
93 22 87 66 94 |
|||
7 43 98 18 57 |
|||
29 20 91 60 21 |
|||
28 51 17 10 14 |
|||
96 12 15 25 37 |
|||
|
|||
12 69 27 41 36 |
|||
58 11 42 44 9 |
|||
8 56 33 7 30 |
|||
70 64 78 17 61 |
|||
22 28 94 0 99 |
|||
|
|||
16 64 88 22 48 |
|||
65 42 23 7 26 |
|||
97 12 63 57 45 |
|||
29 94 91 21 54 |
|||
95 43 0 85 46 |
|||
|
|||
9 50 54 98 35 |
|||
45 37 84 87 5 |
|||
40 23 14 17 18 |
|||
73 43 86 41 59 |
|||
69 77 78 15 60 |
|||
|
|||
79 9 45 59 85 |
|||
38 56 64 95 60 |
|||
39 22 14 57 66 |
|||
98 53 83 76 16 |
|||
62 94 72 54 82 |
|||
|
|||
77 44 6 66 46 |
|||
9 89 11 84 63 |
|||
81 94 87 83 21 |
|||
22 90 1 93 92 |
|||
24 65 34 45 99 |
|||
|
|||
36 93 59 5 43 |
|||
76 49 51 0 68 |
|||
71 34 55 7 73 |
|||
14 10 45 63 95 |
|||
30 94 79 67 11 |
|||
|
|||
93 98 82 96 91 |
|||
3 79 55 70 24 |
|||
68 56 87 12 76 |
|||
19 31 67 1 54 |
|||
49 62 23 15 10 |
|||
|
|||
10 74 98 15 6 |
|||
14 31 66 38 86 |
|||
68 84 60 80 26 |
|||
34 72 87 92 61 |
|||
81 56 73 12 53 |
|||
|
|||
11 69 4 6 23 |
|||
38 47 16 99 96 |
|||
7 13 40 41 78 |
|||
12 5 1 18 88 |
|||
20 42 10 82 73 |
|||
|
|||
66 97 72 55 99 |
|||
26 59 6 79 53 |
|||
74 80 98 28 69 |
|||
25 95 17 29 34 |
|||
85 64 84 90 42 |
|||
|
|||
95 50 58 51 66 |
|||
48 27 81 94 0 |
|||
35 82 57 71 16 |
|||
32 93 70 40 25 |
|||
31 73 46 12 90 |
|||
|
|||
39 94 52 9 88 |
|||
3 23 59 77 29 |
|||
2 40 93 85 38 |
|||
74 97 12 50 1 |
|||
22 36 68 65 37 |
|||
|
|||
70 15 44 90 55 |
|||
42 20 82 0 78 |
|||
10 49 62 3 22 |
|||
91 73 84 40 28 |
|||
72 13 11 60 19 |
|||
|
|||
58 95 66 36 22 |
|||
91 99 77 94 44 |
|||
70 14 85 13 52 |
|||
49 6 2 50 35 |
|||
47 42 15 98 63 |
|||
|
|||
35 1 99 21 68 |
|||
93 32 30 76 5 |
|||
79 96 10 85 16 |
|||
19 69 81 78 70 |
|||
66 36 26 94 39 |
|||
|
|||
78 51 55 4 97 |
|||
21 36 53 1 26 |
|||
77 42 20 12 65 |
|||
17 52 6 40 16 |
|||
19 85 2 24 23 |
|||
|
|||
95 68 76 14 30 |
|||
19 11 64 99 60 |
|||
63 55 8 40 65 |
|||
41 75 62 53 83 |
|||
26 34 46 72 79 |
|||
|
|||
68 6 35 62 77 |
|||
43 14 88 7 11 |
|||
40 45 98 86 64 |
|||
3 53 56 87 30 |
|||
28 37 48 10 72 |
|||
|
|||
13 69 72 93 17 |
|||
1 46 8 56 37 |
|||
78 27 49 64 59 |
|||
81 99 33 76 79 |
|||
84 98 51 82 31 |
|||
|
|||
57 41 45 15 10 |
|||
65 72 79 17 29 |
|||
67 0 33 32 69 |
|||
56 96 92 46 53 |
|||
88 3 18 87 51 |
|||
|
|||
97 52 58 67 17 |
|||
51 69 43 20 63 |
|||
1 26 27 47 99 |
|||
53 23 14 90 86 |
|||
4 56 13 36 11 |
|||
|
|||
88 11 57 73 89 |
|||
43 34 91 15 58 |
|||
9 39 18 12 14 |
|||
1 98 29 77 52 |
|||
84 97 96 68 10 |
|||
|
|||
99 5 69 53 45 |
|||
10 43 24 60 55 |
|||
64 57 30 3 0 |
|||
22 65 68 32 83 |
|||
52 38 74 97 20 |
|||
|
|||
27 25 33 41 67 |
|||
54 42 3 1 55 |
|||
66 92 44 98 35 |
|||
14 82 5 10 39 |
|||
52 79 69 76 48 |
|||
|
|||
64 58 60 91 42 |
|||
45 55 35 9 72 |
|||
36 74 99 33 26 |
|||
67 4 25 50 14 |
|||
15 2 96 82 11 |
|||
|
|||
34 84 90 95 26 |
|||
8 66 52 43 63 |
|||
79 98 36 85 41 |
|||
47 24 33 88 71 |
|||
86 91 83 40 18 |
|||
|
|||
79 68 49 64 35 |
|||
23 57 27 77 71 |
|||
95 39 43 19 98 |
|||
78 62 65 58 60 |
|||
52 73 82 4 32 |
|||
|
|||
22 54 57 45 3 |
|||
43 85 30 60 94 |
|||
35 46 28 55 6 |
|||
82 42 13 83 59 |
|||
76 70 41 61 1 |
|||
|
|||
76 89 34 96 1 |
|||
95 60 55 23 88 |
|||
37 13 61 92 62 |
|||
98 77 32 82 31 |
|||
33 74 71 58 86 |
|||
|
|||
73 91 92 49 44 |
|||
53 6 29 8 95 |
|||
4 31 54 20 97 |
|||
98 57 2 65 75 |
|||
43 88 1 58 0 |
|||
|
|||
49 91 70 1 79 |
|||
17 90 33 65 54 |
|||
56 47 63 83 52 |
|||
8 45 72 84 39 |
|||
43 37 71 97 59 |
|||
|
|||
90 93 20 31 96 |
|||
98 84 2 87 73 |
|||
97 16 19 24 38 |
|||
14 11 94 92 36 |
|||
4 10 27 44 30 |
|||
|
|||
20 77 81 80 28 |
|||
35 51 93 24 62 |
|||
54 56 41 68 79 |
|||
29 67 89 60 12 |
|||
63 91 18 90 99 |
|||
|
|||
28 48 94 50 73 |
|||
20 27 34 59 43 |
|||
66 55 35 98 57 |
|||
40 53 21 99 4 |
|||
17 74 80 5 12 |
|||
|
|||
76 22 6 61 23 |
|||
70 67 69 33 9 |
|||
87 2 12 68 27 |
|||
13 52 82 15 84 |
|||
24 51 89 53 38 |
|||
|
|||
96 23 91 97 10 |
|||
50 8 68 67 0 |
|||
65 3 92 4 70 |
|||
53 77 59 86 66 |
|||
41 78 44 52 71 |
|||
|
|||
62 19 17 63 75 |
|||
43 88 15 84 13 |
|||
41 7 47 16 23 |
|||
12 71 8 83 50 |
|||
36 31 22 5 79 |
|||
|
|||
71 95 17 90 63 |
|||
64 52 32 3 93 |
|||
70 13 99 40 5 |
|||
22 18 83 11 55 |
|||
47 59 78 45 29 |
|||
|
|||
9 98 73 46 79 |
|||
5 51 84 26 40 |
|||
64 62 0 66 18 |
|||
33 83 47 1 63 |
|||
89 31 99 54 36 |
|||
|
|||
98 15 86 9 50 |
|||
67 7 75 85 17 |
|||
96 27 64 81 19 |
|||
80 30 29 54 52 |
|||
49 25 36 5 90 |
|||
|
|||
39 29 40 16 69 |
|||
38 55 67 71 59 |
|||
42 72 51 10 45 |
|||
94 75 21 27 0 |
|||
84 6 22 33 30 |
|||
|
|||
33 64 82 97 39 |
|||
79 7 62 49 99 |
|||
26 3 13 66 10 |
|||
37 98 15 80 47 |
|||
1 35 30 50 43 |
|||
|
|||
56 92 41 82 34 |
|||
68 79 11 0 65 |
|||
70 84 26 76 96 |
|||
1 72 31 80 8 |
|||
9 38 98 17 7 |
|||
|
|||
12 19 6 29 89 |
|||
96 87 70 75 77 |
|||
84 74 64 54 13 |
|||
16 68 44 79 43 |
|||
61 47 69 26 50 |
|||
|
|||
43 20 45 21 87 |
|||
80 50 83 26 49 |
|||
64 99 71 75 9 |
|||
18 96 6 94 88 |
|||
76 97 51 11 74 |
|||
|
|||
85 47 25 72 93 |
|||
96 36 81 55 27 |
|||
63 18 57 1 29 |
|||
9 35 83 88 98 |
|||
90 21 3 67 82 |
|||
|
|||
58 94 55 10 98 |
|||
2 24 71 93 57 |
|||
74 34 21 35 73 |
|||
89 88 6 16 8 |
|||
76 81 38 28 83 |
|||
|
|||
36 53 63 67 18 |
|||
51 74 60 69 85 |
|||
32 22 80 58 98 |
|||
34 92 13 12 26 |
|||
46 61 31 96 47 |
|||
|
|||
90 1 5 10 48 |
|||
12 76 95 83 17 |
|||
24 84 65 44 28 |
|||
81 80 41 79 15 |
|||
29 61 75 94 40 |
|||
|
|||
65 22 40 75 86 |
|||
93 77 46 35 87 |
|||
88 5 91 48 74 |
|||
92 28 66 47 30 |
|||
69 2 29 67 94 |
|||
|
|||
78 38 1 53 68 |
|||
84 70 26 7 72 |
|||
92 87 55 47 6 |
|||
51 82 36 73 28 |
|||
75 58 35 49 56 |
|||
|
|||
61 85 60 19 24 |
|||
16 23 71 74 33 |
|||
42 7 57 82 70 |
|||
14 97 59 99 49 |
|||
46 30 89 79 41 |
|||
|
|||
5 24 92 19 65 |
|||
0 80 33 78 23 |
|||
4 37 31 16 41 |
|||
79 73 88 36 67 |
|||
86 29 62 61 71 |
|||
|
|||
40 51 27 57 85 |
|||
53 68 31 60 83 |
|||
48 69 24 17 96 |
|||
54 89 22 77 64 |
|||
95 26 21 65 41 |
|||
|
|||
48 7 20 68 21 |
|||
31 22 1 99 96 |
|||
82 63 78 2 70 |
|||
18 83 58 92 51 |
|||
81 64 98 44 89 |
|||
|
|||
23 74 99 75 6 |
|||
81 14 37 8 85 |
|||
12 36 55 20 47 |
|||
88 7 90 87 43 |
|||
3 44 83 15 2 |
|||
|
|||
97 15 69 76 95 |
|||
13 44 31 10 14 |
|||
40 83 49 11 65 |
|||
43 98 55 92 89 |
|||
90 33 73 32 53 |
|||
|
|||
25 79 77 83 68 |
|||
5 10 23 15 19 |
|||
18 4 92 51 76 |
|||
17 90 70 49 39 |
|||
74 63 75 42 67 |
|||
|
|||
46 66 18 17 28 |
|||
75 76 78 72 44 |
|||
57 39 97 27 99 |
|||
36 58 62 90 82 |
|||
14 45 48 64 1 |
|||
|
|||
51 90 58 6 37 |
|||
28 30 57 54 10 |
|||
45 80 39 4 0 |
|||
29 17 66 18 55 |
|||
96 44 36 76 34 |
|||
|
|||
94 50 0 71 99 |
|||
11 67 96 87 64 |
|||
48 30 31 68 40 |
|||
89 55 23 92 42 |
|||
16 62 37 83 33 |
|||
|
|||
66 42 91 70 72 |
|||
28 69 96 17 71 |
|||
99 5 2 26 19 |
|||
60 87 51 83 76 |
|||
77 33 64 61 54 |
|||
|
|||
61 93 90 82 88 |
|||
80 11 25 40 28 |
|||
60 29 34 39 21 |
|||
24 13 72 77 2 |
|||
19 95 47 17 0 |
|||
|
|||
86 97 50 42 87 |
|||
7 18 80 23 30 |
|||
41 6 96 92 98 |
|||
36 45 77 71 38 |
|||
19 40 47 39 53 |
|||
|
|||
83 7 80 86 65 |
|||
37 22 19 84 92 |
|||
29 17 76 4 33 |
|||
97 50 1 12 21 |
|||
15 58 39 38 74 |
|||
@ -0,0 +1,67 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
random_num_list_str = lines[0].strip() |
|||
random_num_list = random_num_list_str.split(',') |
|||
|
|||
grids = [[[]]] |
|||
grid_sums = [] |
|||
grid = -1 |
|||
row = 0 |
|||
score_id = 5 |
|||
grid_size = 5 |
|||
for i in range(len(lines)): |
|||
if i == 0: |
|||
continue |
|||
line = lines[i].strip() |
|||
if line == "": |
|||
grid = grid+1 |
|||
row = 0 |
|||
grids.append([]) |
|||
grid_sums.append(0) |
|||
continue |
|||
|
|||
grids[grid].append([]) |
|||
chars = line.split() |
|||
for j in range(len(chars)): |
|||
number = chars[j] |
|||
grids[grid][row].append(number) |
|||
grid_sums[grid] = grid_sums[grid] + int(number) |
|||
row = row + 1 |
|||
|
|||
print(f"{i}: {lines[i]}") |
|||
|
|||
for i in range(len(random_num_list)): |
|||
called_number = random_num_list[i] |
|||
|
|||
for a in range(len(grids)): |
|||
grid = grids[a] |
|||
for b in range(len(grid)): |
|||
row = grids[a][b] |
|||
if called_number in row: |
|||
print("found") |
|||
grid_sums[a] = grid_sums[a] - int(called_number) |
|||
if len(row) == 5: |
|||
row.append(0) |
|||
row[grid_size] = row[grid_size]+1 |
|||
if row[grid_size] == score_id: |
|||
print("winner!") |
|||
print(grid_sums[a] * int(called_number)) |
|||
break |
|||
|
|||
|
|||
if len(grid) == grid_size: |
|||
grid.append([]) |
|||
if len(grid[grid_size]) <= grid_size: |
|||
grid[grid_size].extend([0 for x in range(grid_size)]) |
|||
grid[grid_size][b] = grid[grid_size][b]+1 |
|||
if grid[grid_size][b] == score_id: |
|||
print("winner!") |
|||
print(grid_sums[a] * int(called_number)) |
|||
break |
|||
|
|||
@ -0,0 +1,77 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
random_num_list_str = lines[0].strip() |
|||
random_num_list = random_num_list_str.split(',') |
|||
|
|||
grids = [[[]]] |
|||
grid_sums = [] |
|||
grid = -1 |
|||
row = 0 |
|||
score_id = 5 |
|||
grid_size = 5 |
|||
for i in range(len(lines)): |
|||
if i == 0: |
|||
continue |
|||
line = lines[i].strip() |
|||
if line == "": |
|||
grid = grid+1 |
|||
row = 0 |
|||
grids.append([]) |
|||
grid_sums.append(0) |
|||
continue |
|||
|
|||
grids[grid].append([]) |
|||
chars = line.split() |
|||
for j in range(len(chars)): |
|||
number = chars[j] |
|||
grids[grid][row].append(number) |
|||
grid_sums[grid] = grid_sums[grid] + int(number) |
|||
row = row + 1 |
|||
|
|||
print(f"{i}: {lines[i]}") |
|||
|
|||
winning_boards = [] |
|||
|
|||
for i in range(len(random_num_list)): |
|||
called_number = random_num_list[i] |
|||
|
|||
for a in range(len(grids)-1): |
|||
if a in winning_boards: |
|||
continue |
|||
grid = grids[a] |
|||
for b in range(len(grid)): |
|||
row = grids[a][b] |
|||
if called_number in row: |
|||
col = row.index(called_number) |
|||
grid_sums[a] = grid_sums[a] - int(called_number) |
|||
if len(row) == 5: |
|||
row.append(0) |
|||
row[grid_size] = row[grid_size]+1 |
|||
if row[grid_size] == score_id: |
|||
print("winner!") |
|||
print(a) |
|||
print(int(called_number)) |
|||
print(grid_sums[a] * int(called_number)) |
|||
winning_boards.append(a) |
|||
break |
|||
|
|||
if len(grid) == grid_size: |
|||
grid.append([]) |
|||
if len(grid[grid_size]) < grid_size: |
|||
grid[grid_size].extend([0 for x in range(grid_size)]) |
|||
grid[grid_size][col] = grid[grid_size][col]+1 |
|||
if grid[grid_size][col] == score_id: |
|||
print("winner!") |
|||
print(a) |
|||
print(int(called_number)) |
|||
print(grid_sums[a] * int(called_number)) |
|||
winning_boards.append(a) |
|||
break |
|||
print(winning_boards) |
|||
|
|||
@ -0,0 +1,41 @@ |
|||
import os |
|||
import re |
|||
from collections import Counter |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
max_x = 0 |
|||
max_y = 0 |
|||
|
|||
parse_pattern = re.compile("(\d+),(\d+) -> (\d+),(\d+)") |
|||
|
|||
map = Counter() |
|||
for line in lines: |
|||
matches = re.search(parse_pattern, line.strip()) |
|||
x1 = int(matches.group(1)) |
|||
y1 = int(matches.group(2)) |
|||
x2 = int(matches.group(3)) |
|||
y2 = int(matches.group(4)) |
|||
|
|||
if x1 == x2: |
|||
start = min(y1,y2) |
|||
end = max(y1,y2) |
|||
for y in range(start, end+1): |
|||
key = f"{x1},{y}" |
|||
map[key] = map[key] + 1 |
|||
elif y1 == y2: |
|||
start = min(x1,x2) |
|||
end = max(x1,x2) |
|||
for x in range(start, end+1): |
|||
key = f"{x},{y1}" |
|||
map[key] = map[key] + 1 |
|||
|
|||
count = 0 |
|||
for keys in map: |
|||
if map[keys] >= 2: |
|||
count = count + 1 |
|||
print(count) |
|||
@ -0,0 +1,500 @@ |
|||
510,771 -> 510,322 |
|||
753,99 -> 753,280 |
|||
160,330 -> 33,330 |
|||
700,793 -> 700,892 |
|||
327,168 -> 327,690 |
|||
264,203 -> 264,839 |
|||
135,134 -> 314,134 |
|||
209,759 -> 41,759 |
|||
474,514 -> 491,531 |
|||
977,988 -> 42,53 |
|||
924,245 -> 278,891 |
|||
466,952 -> 466,135 |
|||
381,560 -> 822,119 |
|||
339,828 -> 339,730 |
|||
114,775 -> 114,508 |
|||
472,44 -> 472,32 |
|||
815,512 -> 188,512 |
|||
516,579 -> 987,108 |
|||
219,386 -> 219,838 |
|||
456,592 -> 456,496 |
|||
778,300 -> 355,300 |
|||
277,27 -> 69,27 |
|||
889,217 -> 307,799 |
|||
470,471 -> 249,471 |
|||
655,867 -> 20,232 |
|||
845,623 -> 675,623 |
|||
278,281 -> 278,47 |
|||
121,396 -> 541,816 |
|||
61,965 -> 978,48 |
|||
32,689 -> 115,689 |
|||
654,162 -> 654,947 |
|||
355,244 -> 355,796 |
|||
272,805 -> 705,372 |
|||
377,589 -> 500,589 |
|||
505,625 -> 163,625 |
|||
845,851 -> 63,69 |
|||
411,734 -> 411,942 |
|||
545,143 -> 126,562 |
|||
265,799 -> 734,330 |
|||
750,618 -> 750,559 |
|||
987,25 -> 628,25 |
|||
73,931 -> 906,98 |
|||
652,433 -> 652,954 |
|||
612,747 -> 612,621 |
|||
448,915 -> 195,915 |
|||
565,174 -> 565,138 |
|||
218,235 -> 576,593 |
|||
955,732 -> 287,64 |
|||
225,112 -> 969,112 |
|||
773,795 -> 773,718 |
|||
446,150 -> 446,490 |
|||
14,914 -> 437,491 |
|||
950,987 -> 46,83 |
|||
312,818 -> 312,108 |
|||
42,791 -> 165,791 |
|||
448,592 -> 16,592 |
|||
225,389 -> 245,389 |
|||
351,772 -> 651,772 |
|||
531,685 -> 485,731 |
|||
797,773 -> 168,144 |
|||
247,196 -> 28,196 |
|||
273,961 -> 158,961 |
|||
961,877 -> 961,691 |
|||
267,397 -> 267,214 |
|||
553,140 -> 26,667 |
|||
963,71 -> 245,789 |
|||
878,128 -> 749,128 |
|||
33,973 -> 971,35 |
|||
950,152 -> 733,152 |
|||
33,71 -> 811,71 |
|||
757,556 -> 792,556 |
|||
863,617 -> 335,617 |
|||
763,781 -> 11,29 |
|||
592,572 -> 504,660 |
|||
498,899 -> 498,867 |
|||
73,39 -> 569,535 |
|||
179,242 -> 179,734 |
|||
951,128 -> 108,971 |
|||
86,535 -> 758,535 |
|||
886,230 -> 801,230 |
|||
28,39 -> 749,760 |
|||
521,797 -> 551,797 |
|||
870,641 -> 329,100 |
|||
479,650 -> 479,406 |
|||
373,791 -> 923,791 |
|||
294,390 -> 294,623 |
|||
905,759 -> 905,622 |
|||
82,88 -> 928,934 |
|||
171,15 -> 171,560 |
|||
342,61 -> 453,61 |
|||
30,103 -> 777,850 |
|||
899,316 -> 899,818 |
|||
746,493 -> 417,164 |
|||
547,279 -> 557,279 |
|||
330,663 -> 330,882 |
|||
75,696 -> 740,31 |
|||
368,828 -> 912,284 |
|||
816,758 -> 744,758 |
|||
484,753 -> 922,753 |
|||
216,382 -> 216,189 |
|||
835,563 -> 835,827 |
|||
37,955 -> 980,12 |
|||
730,704 -> 836,704 |
|||
647,325 -> 529,325 |
|||
627,647 -> 978,296 |
|||
950,628 -> 455,133 |
|||
349,382 -> 915,382 |
|||
144,530 -> 144,721 |
|||
675,736 -> 675,646 |
|||
55,784 -> 55,829 |
|||
63,724 -> 309,970 |
|||
957,863 -> 51,863 |
|||
86,732 -> 86,959 |
|||
331,223 -> 415,223 |
|||
65,906 -> 65,362 |
|||
877,296 -> 805,224 |
|||
360,85 -> 93,85 |
|||
697,479 -> 697,117 |
|||
965,55 -> 49,971 |
|||
825,188 -> 36,977 |
|||
107,522 -> 129,522 |
|||
171,55 -> 879,763 |
|||
23,615 -> 748,615 |
|||
45,34 -> 972,961 |
|||
241,750 -> 241,251 |
|||
980,184 -> 429,735 |
|||
859,419 -> 859,695 |
|||
474,283 -> 474,204 |
|||
135,100 -> 616,100 |
|||
338,653 -> 450,653 |
|||
304,294 -> 304,285 |
|||
416,602 -> 308,602 |
|||
517,172 -> 978,633 |
|||
872,878 -> 143,149 |
|||
487,314 -> 394,314 |
|||
954,807 -> 453,306 |
|||
701,933 -> 701,655 |
|||
614,70 -> 614,356 |
|||
246,744 -> 61,559 |
|||
444,858 -> 108,858 |
|||
981,954 -> 110,83 |
|||
428,622 -> 56,250 |
|||
813,747 -> 383,317 |
|||
344,295 -> 344,476 |
|||
870,36 -> 870,638 |
|||
76,584 -> 76,934 |
|||
931,802 -> 931,486 |
|||
496,83 -> 521,83 |
|||
341,319 -> 700,678 |
|||
231,722 -> 312,722 |
|||
967,966 -> 103,102 |
|||
78,948 -> 975,51 |
|||
167,146 -> 817,796 |
|||
16,579 -> 189,579 |
|||
68,242 -> 686,860 |
|||
965,182 -> 206,182 |
|||
226,565 -> 226,30 |
|||
128,242 -> 128,136 |
|||
75,395 -> 75,644 |
|||
208,687 -> 24,687 |
|||
46,867 -> 46,765 |
|||
366,802 -> 366,439 |
|||
410,657 -> 698,945 |
|||
158,719 -> 158,11 |
|||
357,462 -> 647,462 |
|||
587,909 -> 305,909 |
|||
927,694 -> 235,694 |
|||
846,243 -> 942,243 |
|||
781,169 -> 30,169 |
|||
329,497 -> 97,497 |
|||
139,120 -> 963,944 |
|||
237,373 -> 95,515 |
|||
512,316 -> 890,316 |
|||
450,975 -> 450,231 |
|||
906,326 -> 554,326 |
|||
21,706 -> 12,706 |
|||
698,384 -> 448,634 |
|||
49,917 -> 676,917 |
|||
790,752 -> 790,36 |
|||
167,610 -> 72,610 |
|||
571,347 -> 313,347 |
|||
830,203 -> 64,969 |
|||
842,731 -> 490,731 |
|||
948,412 -> 841,305 |
|||
259,110 -> 319,110 |
|||
970,277 -> 911,277 |
|||
619,424 -> 326,424 |
|||
877,400 -> 877,303 |
|||
437,612 -> 854,195 |
|||
217,121 -> 217,574 |
|||
734,109 -> 734,235 |
|||
207,406 -> 230,383 |
|||
111,914 -> 981,44 |
|||
673,239 -> 343,239 |
|||
567,258 -> 522,258 |
|||
183,541 -> 562,541 |
|||
834,143 -> 834,545 |
|||
142,220 -> 142,434 |
|||
739,942 -> 312,515 |
|||
155,358 -> 857,358 |
|||
610,709 -> 466,709 |
|||
640,544 -> 65,544 |
|||
211,14 -> 88,14 |
|||
441,524 -> 524,524 |
|||
278,322 -> 259,322 |
|||
365,167 -> 886,688 |
|||
706,971 -> 706,60 |
|||
773,791 -> 773,529 |
|||
833,752 -> 532,451 |
|||
250,913 -> 250,696 |
|||
660,50 -> 360,350 |
|||
235,443 -> 380,443 |
|||
853,56 -> 369,540 |
|||
939,595 -> 377,33 |
|||
935,957 -> 740,957 |
|||
547,87 -> 184,450 |
|||
53,955 -> 974,34 |
|||
957,165 -> 957,524 |
|||
392,956 -> 392,166 |
|||
552,666 -> 171,666 |
|||
949,728 -> 103,728 |
|||
816,85 -> 792,61 |
|||
968,108 -> 103,973 |
|||
88,183 -> 888,983 |
|||
804,788 -> 66,788 |
|||
526,506 -> 417,615 |
|||
822,670 -> 634,482 |
|||
949,143 -> 949,867 |
|||
302,820 -> 302,877 |
|||
107,512 -> 551,68 |
|||
23,123 -> 23,101 |
|||
882,886 -> 16,20 |
|||
216,977 -> 216,522 |
|||
581,420 -> 424,577 |
|||
84,41 -> 113,41 |
|||
157,717 -> 679,195 |
|||
907,270 -> 907,259 |
|||
275,769 -> 275,701 |
|||
389,88 -> 44,433 |
|||
246,190 -> 643,190 |
|||
212,730 -> 235,707 |
|||
976,122 -> 934,122 |
|||
860,179 -> 860,797 |
|||
953,672 -> 592,672 |
|||
680,101 -> 680,714 |
|||
293,424 -> 576,424 |
|||
139,107 -> 55,23 |
|||
885,56 -> 34,907 |
|||
87,74 -> 911,898 |
|||
79,686 -> 79,883 |
|||
936,139 -> 936,937 |
|||
238,585 -> 31,378 |
|||
742,120 -> 883,120 |
|||
203,129 -> 203,338 |
|||
571,665 -> 421,515 |
|||
654,642 -> 51,642 |
|||
797,313 -> 797,850 |
|||
472,25 -> 806,25 |
|||
956,21 -> 13,964 |
|||
334,856 -> 334,932 |
|||
199,904 -> 165,870 |
|||
179,439 -> 179,397 |
|||
657,805 -> 319,467 |
|||
903,38 -> 168,773 |
|||
672,487 -> 326,833 |
|||
727,868 -> 747,868 |
|||
467,637 -> 984,637 |
|||
933,81 -> 293,81 |
|||
786,211 -> 690,115 |
|||
120,276 -> 120,455 |
|||
101,86 -> 975,960 |
|||
579,124 -> 685,124 |
|||
679,346 -> 679,986 |
|||
911,206 -> 911,846 |
|||
401,497 -> 401,375 |
|||
417,101 -> 234,284 |
|||
61,885 -> 315,885 |
|||
744,175 -> 744,814 |
|||
97,496 -> 539,938 |
|||
98,325 -> 98,887 |
|||
14,277 -> 709,972 |
|||
648,456 -> 648,287 |
|||
16,13 -> 988,985 |
|||
69,794 -> 69,343 |
|||
753,148 -> 272,629 |
|||
178,251 -> 366,439 |
|||
431,241 -> 431,32 |
|||
54,235 -> 684,865 |
|||
964,68 -> 91,941 |
|||
406,142 -> 20,142 |
|||
373,490 -> 373,88 |
|||
468,987 -> 612,843 |
|||
981,31 -> 127,885 |
|||
934,382 -> 934,415 |
|||
936,881 -> 936,56 |
|||
891,74 -> 891,886 |
|||
490,346 -> 490,769 |
|||
458,89 -> 110,89 |
|||
754,171 -> 236,689 |
|||
856,539 -> 856,782 |
|||
312,498 -> 312,370 |
|||
986,56 -> 148,894 |
|||
591,777 -> 591,613 |
|||
265,107 -> 493,335 |
|||
916,775 -> 916,193 |
|||
809,535 -> 809,523 |
|||
584,231 -> 61,754 |
|||
926,818 -> 248,140 |
|||
764,443 -> 324,443 |
|||
925,956 -> 90,121 |
|||
536,378 -> 715,557 |
|||
590,125 -> 61,654 |
|||
108,630 -> 535,203 |
|||
585,260 -> 748,260 |
|||
243,86 -> 672,86 |
|||
869,864 -> 245,864 |
|||
332,188 -> 332,709 |
|||
932,457 -> 897,457 |
|||
713,247 -> 460,500 |
|||
741,865 -> 412,865 |
|||
927,742 -> 927,96 |
|||
42,586 -> 662,586 |
|||
577,431 -> 577,273 |
|||
878,415 -> 878,22 |
|||
433,913 -> 742,604 |
|||
710,619 -> 240,619 |
|||
761,317 -> 133,317 |
|||
483,747 -> 929,747 |
|||
83,513 -> 700,513 |
|||
954,818 -> 954,848 |
|||
22,12 -> 620,610 |
|||
514,978 -> 520,978 |
|||
638,582 -> 133,582 |
|||
264,306 -> 515,557 |
|||
416,662 -> 971,662 |
|||
341,540 -> 610,540 |
|||
847,837 -> 294,284 |
|||
555,322 -> 555,893 |
|||
965,981 -> 12,28 |
|||
23,56 -> 797,830 |
|||
712,285 -> 712,856 |
|||
618,137 -> 221,534 |
|||
268,286 -> 268,732 |
|||
732,238 -> 732,121 |
|||
125,452 -> 987,452 |
|||
662,390 -> 390,390 |
|||
485,651 -> 485,922 |
|||
578,433 -> 122,433 |
|||
471,904 -> 471,176 |
|||
285,622 -> 138,769 |
|||
270,889 -> 270,912 |
|||
593,847 -> 593,21 |
|||
749,350 -> 857,350 |
|||
125,532 -> 403,532 |
|||
357,73 -> 807,73 |
|||
671,485 -> 671,933 |
|||
216,501 -> 624,501 |
|||
64,915 -> 969,10 |
|||
801,246 -> 801,870 |
|||
445,904 -> 445,40 |
|||
300,525 -> 540,525 |
|||
142,772 -> 142,810 |
|||
914,711 -> 217,711 |
|||
786,163 -> 102,847 |
|||
715,615 -> 715,169 |
|||
261,474 -> 450,474 |
|||
726,434 -> 726,559 |
|||
783,40 -> 414,409 |
|||
673,171 -> 393,171 |
|||
268,584 -> 186,584 |
|||
189,562 -> 480,562 |
|||
816,34 -> 165,34 |
|||
645,443 -> 645,118 |
|||
508,313 -> 253,58 |
|||
550,164 -> 206,508 |
|||
606,502 -> 209,502 |
|||
345,696 -> 232,809 |
|||
325,936 -> 325,715 |
|||
505,479 -> 537,479 |
|||
362,13 -> 943,13 |
|||
169,507 -> 375,507 |
|||
27,12 -> 985,970 |
|||
980,768 -> 98,768 |
|||
738,793 -> 76,793 |
|||
877,935 -> 886,935 |
|||
321,157 -> 805,157 |
|||
800,595 -> 171,595 |
|||
606,981 -> 716,981 |
|||
57,31 -> 57,158 |
|||
800,97 -> 11,886 |
|||
455,164 -> 455,476 |
|||
137,259 -> 30,259 |
|||
111,495 -> 482,124 |
|||
47,248 -> 747,248 |
|||
299,268 -> 225,268 |
|||
973,52 -> 124,901 |
|||
498,821 -> 498,653 |
|||
272,419 -> 121,570 |
|||
394,48 -> 703,48 |
|||
574,466 -> 574,421 |
|||
918,256 -> 361,256 |
|||
360,583 -> 279,583 |
|||
164,611 -> 406,611 |
|||
453,890 -> 453,838 |
|||
433,562 -> 25,154 |
|||
89,177 -> 89,729 |
|||
138,910 -> 138,674 |
|||
966,711 -> 636,711 |
|||
139,830 -> 139,760 |
|||
76,493 -> 973,493 |
|||
228,910 -> 878,260 |
|||
349,939 -> 141,939 |
|||
742,624 -> 742,472 |
|||
70,714 -> 950,714 |
|||
377,935 -> 621,691 |
|||
363,584 -> 556,584 |
|||
452,517 -> 452,544 |
|||
43,400 -> 496,400 |
|||
608,926 -> 740,794 |
|||
443,787 -> 261,969 |
|||
670,703 -> 326,703 |
|||
59,39 -> 975,955 |
|||
748,96 -> 721,96 |
|||
984,182 -> 243,923 |
|||
780,342 -> 780,801 |
|||
124,134 -> 950,960 |
|||
555,979 -> 777,979 |
|||
68,570 -> 287,570 |
|||
399,977 -> 613,977 |
|||
755,793 -> 380,793 |
|||
88,167 -> 88,132 |
|||
698,571 -> 138,11 |
|||
631,227 -> 842,227 |
|||
254,541 -> 378,541 |
|||
636,238 -> 594,238 |
|||
734,249 -> 899,249 |
|||
524,520 -> 680,520 |
|||
943,98 -> 117,924 |
|||
53,37 -> 121,37 |
|||
67,940 -> 974,33 |
|||
962,157 -> 139,980 |
|||
650,349 -> 650,926 |
|||
77,111 -> 569,111 |
|||
306,812 -> 924,812 |
|||
362,579 -> 756,579 |
|||
462,368 -> 462,618 |
|||
267,803 -> 80,803 |
|||
276,682 -> 276,123 |
|||
599,96 -> 42,96 |
|||
306,818 -> 306,523 |
|||
729,254 -> 82,901 |
|||
65,235 -> 65,927 |
|||
573,774 -> 237,774 |
|||
413,376 -> 522,376 |
|||
103,52 -> 81,52 |
|||
24,722 -> 530,216 |
|||
341,395 -> 467,395 |
|||
937,510 -> 937,435 |
|||
292,385 -> 518,385 |
|||
394,588 -> 572,588 |
|||
561,20 -> 275,20 |
|||
710,862 -> 355,507 |
|||
104,530 -> 916,530 |
|||
160,116 -> 687,116 |
|||
22,952 -> 940,34 |
|||
222,752 -> 45,752 |
|||
873,784 -> 873,475 |
|||
90,235 -> 503,235 |
|||
655,543 -> 580,543 |
|||
169,900 -> 169,326 |
|||
969,724 -> 634,389 |
|||
317,826 -> 920,223 |
|||
705,71 -> 705,970 |
|||
777,239 -> 777,118 |
|||
614,746 -> 614,635 |
|||
910,861 -> 910,733 |
|||
12,23 -> 972,983 |
|||
960,128 -> 347,128 |
|||
821,612 -> 503,294 |
|||
770,705 -> 770,985 |
|||
382,977 -> 726,977 |
|||
730,639 -> 491,639 |
|||
706,333 -> 492,547 |
|||
344,596 -> 344,762 |
|||
729,599 -> 729,630 |
|||
218,469 -> 204,483 |
|||
630,586 -> 630,686 |
|||
98,148 -> 138,148 |
|||
939,110 -> 433,616 |
|||
54,42 -> 988,976 |
|||
987,948 -> 83,44 |
|||
62,625 -> 671,625 |
|||
165,64 -> 950,849 |
|||
245,62 -> 453,270 |
|||
695,244 -> 60,244 |
|||
296,505 -> 117,505 |
|||
522,692 -> 741,692 |
|||
335,407 -> 335,123 |
|||
717,37 -> 600,37 |
|||
772,178 -> 772,889 |
|||
@ -0,0 +1,72 @@ |
|||
import os |
|||
import re |
|||
from collections import Counter |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
max_x = 0 |
|||
max_y = 0 |
|||
|
|||
parse_pattern = re.compile("(\d+),(\d+) -> (\d+),(\d+)") |
|||
|
|||
map = Counter() |
|||
for line in lines: |
|||
matches = re.search(parse_pattern, line.strip()) |
|||
x1 = int(matches.group(1)) |
|||
y1 = int(matches.group(2)) |
|||
x2 = int(matches.group(3)) |
|||
y2 = int(matches.group(4)) |
|||
print(line.strip()) |
|||
|
|||
if x1 == x2: |
|||
start = min(y1,y2) |
|||
end = max(y1,y2) |
|||
for y in range(start, end+1): |
|||
key = f"{x1},{y}" |
|||
map[key] = map[key] + 1 |
|||
elif y1 == y2: |
|||
start = min(x1,x2) |
|||
end = max(x1,x2) |
|||
for x in range(start, end+1): |
|||
key = f"{x},{y1}" |
|||
map[key] = map[key] + 1 |
|||
else: |
|||
if x1 < x2: |
|||
x_start = x1 |
|||
x_end = x2 |
|||
y_start = y1 |
|||
y_end = y2 |
|||
else: |
|||
x_start = x2 |
|||
x_end = x1 |
|||
y_start = y2 |
|||
y_end = y1 |
|||
|
|||
x = x_start |
|||
y = y_start |
|||
|
|||
if y_start < y_end: |
|||
while x != x_end+1 and y != y_end+1: |
|||
key = f"{x},{y}" |
|||
map[key] = map[key] + 1 |
|||
x = x+1 |
|||
y = y+1 |
|||
else: |
|||
while x != x_end+1 and y != y_end-1: |
|||
key = f"{x},{y}" |
|||
print(key) |
|||
map[key] = map[key] + 1 |
|||
x = x+1 |
|||
y = y-1 |
|||
|
|||
|
|||
count = 0 |
|||
for keys in map: |
|||
if map[keys] >= 2: |
|||
count = count + 1 |
|||
print(map) |
|||
print(count) |
|||
@ -0,0 +1 @@ |
|||
1,1,1,1,2,1,1,4,1,4,3,1,1,1,1,1,1,1,1,4,1,3,1,1,1,5,1,3,1,4,1,2,1,1,5,1,1,1,1,1,1,1,1,1,1,3,4,1,5,1,1,1,1,1,1,1,1,1,3,1,4,1,1,1,1,3,5,1,1,2,1,1,1,1,4,4,1,1,1,4,1,1,4,2,4,4,5,1,1,1,1,2,3,1,1,4,1,5,1,1,1,3,1,1,1,1,5,5,1,2,2,2,2,1,1,2,1,1,1,1,1,3,1,1,1,2,3,1,5,1,1,1,2,2,1,1,1,1,1,3,2,1,1,1,4,3,1,1,4,1,5,4,1,4,1,1,1,1,1,1,1,1,1,1,2,2,4,5,1,1,1,1,5,4,1,3,1,1,1,1,4,3,3,3,1,2,3,1,1,1,1,1,1,1,1,2,1,1,1,5,1,3,1,4,3,1,3,1,5,1,1,1,1,3,1,5,1,2,4,1,1,4,1,4,4,2,1,2,1,3,3,1,4,4,1,1,3,4,1,1,1,2,5,2,5,1,1,1,4,1,1,1,1,1,1,3,1,5,1,2,1,1,1,1,1,4,4,1,1,1,5,1,1,5,1,2,1,5,1,1,1,1,1,1,1,1,1,1,1,1,3,2,4,1,1,2,1,1,3,2 |
|||
@ -0,0 +1,37 @@ |
|||
import os |
|||
|
|||
def tick(currentLanturnFish): |
|||
new_fish_to_spawn = 0 |
|||
|
|||
for i in range(len(currentLanturnFish)): |
|||
fish = currentLanturnFish[i] |
|||
fish = fish - 1 |
|||
|
|||
if fish < 0: |
|||
new_fish_to_spawn = new_fish_to_spawn + 1 |
|||
fish = 6 |
|||
|
|||
currentLanturnFish[i] = fish |
|||
for x in range(new_fish_to_spawn): |
|||
currentLanturnFish.append(8) |
|||
|
|||
return currentLanturnFish |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
line = lines[0].strip() |
|||
parts = line.split(',') |
|||
|
|||
fish = [] |
|||
for part in parts: |
|||
fish.append(int(part)) |
|||
|
|||
days_to_predict = 80 |
|||
for x in range(days_to_predict): |
|||
#print(fish) |
|||
fish = tick(fish) |
|||
print(len(fish)) |
|||
@ -0,0 +1,36 @@ |
|||
import os |
|||
from collections import Counter |
|||
|
|||
def tick(currentLanturnFish): |
|||
new_fish_to_spawn = 0 |
|||
|
|||
new_fish = Counter() |
|||
new_fish_to_spawn = currentLanturnFish['0'] |
|||
new_fish['0'] = currentLanturnFish['1'] |
|||
new_fish['1'] = currentLanturnFish['2'] |
|||
new_fish['2'] = currentLanturnFish['3'] |
|||
new_fish['3'] = currentLanturnFish['4'] |
|||
new_fish['4'] = currentLanturnFish['5'] |
|||
new_fish['5'] = currentLanturnFish['6'] |
|||
new_fish['6'] = currentLanturnFish['7'] + new_fish_to_spawn |
|||
new_fish['7'] = currentLanturnFish['8'] |
|||
new_fish['8'] = new_fish_to_spawn |
|||
|
|||
return new_fish |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
line = lines[0].strip() |
|||
parts = line.split(',') |
|||
|
|||
fish = Counter(parts) |
|||
print(fish) |
|||
|
|||
days_to_predict = 256 |
|||
for x in range(days_to_predict): |
|||
fish = tick(fish) |
|||
print(sum(fish.values())) |
|||
@ -0,0 +1 @@ |
|||
1101,1,29,67,1102,0,1,65,1008,65,35,66,1005,66,28,1,67,65,20,4,0,1001,65,1,65,1106,0,8,99,35,67,101,99,105,32,110,39,101,115,116,32,112,97,115,32,117,110,101,32,105,110,116,99,111,100,101,32,112,114,111,103,114,97,109,10,767,559,240,1779,740,550,84,819,108,728,212,650,264,899,1231,90,127,46,219,1494,192,473,163,1456,1048,22,4,1121,9,37,180,531,1167,395,456,952,1807,199,606,293,1003,236,235,1294,102,4,724,672,458,511,431,162,48,900,229,4,570,316,111,520,720,343,1064,314,261,1102,397,1585,610,509,1374,157,128,353,440,435,864,1489,425,762,320,1369,233,903,1181,1203,598,9,938,659,214,2,141,468,1485,631,265,156,165,987,2,856,564,120,325,16,743,849,822,51,18,1153,1100,143,301,402,717,126,937,391,36,802,1399,512,461,250,679,646,303,556,574,948,362,395,402,253,1631,1,203,76,48,246,115,117,15,953,926,210,1257,96,47,147,1058,1129,1166,183,375,1404,697,237,191,760,431,38,1778,159,698,411,160,289,23,836,554,841,289,892,276,877,216,751,1273,388,392,289,78,324,1142,896,767,416,780,373,117,1,71,235,302,307,906,321,480,991,1586,1491,1617,653,499,1323,156,455,19,669,169,415,284,743,439,705,980,1350,210,118,797,81,67,894,183,10,439,950,1126,576,828,85,681,517,19,872,119,164,882,31,244,195,640,41,313,888,303,224,433,462,389,329,254,488,570,286,945,1377,32,1101,206,457,584,662,1176,9,1164,227,467,239,1094,131,420,871,942,52,1276,14,72,7,1099,702,53,118,263,645,181,60,105,780,1102,550,85,225,1159,250,1424,8,1060,458,79,299,744,76,1513,338,68,179,323,644,65,293,66,153,699,819,966,678,207,538,372,284,101,224,305,103,1276,577,316,350,647,314,1256,595,1332,133,83,654,1072,63,446,46,5,92,939,608,940,257,851,1715,742,96,1497,240,1154,30,69,803,13,47,380,97,349,742,581,768,94,454,25,330,899,584,1425,447,207,1621,329,429,22,361,3,24,534,361,695,61,680,517,43,129,1686,301,1090,211,680,362,855,700,392,354,871,154,485,654,203,1417,208,1228,243,317,899,106,307,62,157,186,291,475,616,137,113,1367,24,778,431,1563,36,651,131,259,165,765,226,28,1410,456,1601,11,21,323,214,208,1444,11,108,49,1182,89,564,1266,478,1324,538,1572,488,1546,434,1168,615,285,507,561,100,1092,30,866,946,840,322,625,106,101,157,209,531,63,133,103,715,666,1655,81,1439,1016,32,441,86,1597,1273,443,732,160,162,528,727,150,107,21,111,10,502,302,1315,643,84,318,1488,315,150,5,248,675,167,691,101,412,584,992,1317,18,1046,164,359,111,1105,96,16,301,463,680,443,433,477,420,1141,362,1840,12,57,1094,806,23,708,243,1060,894,403,941,958,240,903,497,1342,1068,35,399,381,19,499,339,0,226,108,292,1607,281,72,283,316,182,224,33,488,786,1456,25,104,201,549,827,890,1520,931,70,763,25,633,464,822,751,327,144,62,1205,78,1007,216,324,316,289,682,1359,198,204,199,29,580,10,338,45,150,217,290,734,985,1654,201,934,0,793,956,549,230,1337,183,115,229,31,122,90,1264,122,1292,278,78,256,919,365,444,455,1235,484,45,1646,21,895,218,179,1311,141,238,1330,40,593,518,95,466,233,125,777,150,315,606,265,935,13,89,961,394,341,88,485,57,725,665,616,889,577,100,154,686,842,772,581,1311,604,41,62,1439,313,320,225,1115,279,176,995,12,70,739,96,4,2,37,252,1164,1243,899,856,10,219,233,1430,443,1011,30,378,81,39,167,1060,9,601,663,89,718,1192,1579,511,85,180,236,1079,556,496,215,192,718,300,1282,475,984,535,1760,1137,439,759,221,125,1298,542,1119,446,204,90,16,84,63,176,26,123,1157,140,518,1115,514,701,1207,547,39,970,240,584,77,66,44,858,560,21,648,309,1096,618,220,28,75,1442,233,1,86,325,244,161,218,6,229,1104,275,754,60,186,882,232,133,1288,42,697,152,252,396,345,38,672,980,1514,468,102,563,871,313,358,97,28,1018,830,182,32,1335,525,490,419,1182,946,362,57,496,799,194,504,1615,440,566,481,283,1422,133,919,185,695,871,1422,1372,250,96,438,743,954,1363,349,814,1235,642,461,160,135,131,61,250,188,125,698,346,470,603,1391,460,578,404,3,14,1715,1271,856,1334,28,739,274,628,70,456,393,5,326,382,70,244,101,560,424,1521,25,1441,147,851,1207,747,84,703,172,101,87,357,421,91,939,595,581,149,626,797,1485,419,192,828,1031,1283,333,614,479,1344,520,1434,1422,877 |
|||
@ -0,0 +1,25 @@ |
|||
import os |
|||
import sys |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
line = lines[0].strip() |
|||
crabsString = line.split(',') |
|||
crabs = [int(numeric_string) for numeric_string in crabsString] |
|||
|
|||
maxDistance = max(crabs) |
|||
minDistance = min(crabs) |
|||
|
|||
smallestFuel = 9999999999999999999999 |
|||
for i in range(minDistance, maxDistance+1): |
|||
currentfuel = 0 |
|||
for crab in crabs: |
|||
currentfuel = currentfuel + abs(crab-i) |
|||
|
|||
smallestFuel = min(smallestFuel, currentfuel) |
|||
|
|||
print(smallestFuel) |
|||
@ -0,0 +1,27 @@ |
|||
import os |
|||
import sys |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
line = lines[0].strip() |
|||
crabsString = line.split(',') |
|||
crabs = [int(numeric_string) for numeric_string in crabsString] |
|||
|
|||
maxDistance = max(crabs) |
|||
minDistance = min(crabs) |
|||
|
|||
smallestFuel = 9999999999999999999999 |
|||
for i in range(minDistance, maxDistance+1): |
|||
currentfuel = 0 |
|||
for crab in crabs: |
|||
steps = abs(crab-i) |
|||
a_sum = steps*((steps+1)/2) |
|||
currentfuel = currentfuel + a_sum |
|||
|
|||
smallestFuel = min(smallestFuel, currentfuel) |
|||
|
|||
print(smallestFuel) |
|||
@ -0,0 +1,200 @@ |
|||
gbdfcae ebcg cfg gc facegb fecab acfge cbfgda fedag caebfd | ecbg bfcagd faegc gcf |
|||
eacgf efcab fgc fedagc gdeaf cged aebfgd adcgfbe gc bdgcaf | fgbacd cfega ecdg cg |
|||
dfgae gcadef efb eb dcabf bgde edfba bcfaeg egcdfab fbgade | bged eafdb eb gfdea |
|||
aefdb cafdgeb egdfac egdcba fcbd efd eadcb caefbd df aegbf | cfadeg abfedgc fde bfcd |
|||
dc deafg ecd dbaefc adcfeg cfged ecbfg acdg cafdegb gfeadb | dcga edc adfebcg ecgfb |
|||
befdc bcfge befad degfab cde aecbfd gcedaf eafcgdb dc bcad | bdeafc cde ebdcafg daebgcf |
|||
cd egdacfb fdc fecgb gabdf fbcdg fcgdeb gdcfea debc ecfbga | gfecb fbgecd bcgef dc |
|||
fagcdbe gec gbdea ce bgedc aecd cgbeaf cfbdg gebcda dbfgae | cfbaged cgbeaf ceg gadfbe |
|||
gcbaf gfdb bdafc df adf adcbefg dcfeag cebad adfgcb faecgb | afd agfedc dcbfa gdfabc |
|||
fbae cef fecdbg afbcg cefbga fe acdfgb gadce fbdacge fcage | fe abef gfbac cef |
|||
cfdebg bg beg cabfeg fbgd acged ecgbd fdcbe cfbeda cebgadf | fbedc gadce gdaec bcfed |
|||
gba ab fgbcd gedaf bcadge afbdgc cdgfbe agdfcbe bcfa bdfga | gab gdbfc ba fgdbcae |
|||
fabdgce bfdgac cbaed dcb bgade fbaec fcde edbfac gfabec cd | dc cefd dc cd |
|||
afc dbecafg fagce fbega fbgc edgca agecbf bafged eacdfb cf | cf bfdcaeg gfbc gfbc |
|||
gedcb ebda cgbdfa fcaeg gab bfgdce ba agbce bdgecfa dgebca | bdgfce cebagd cbdgfae dcfbeg |
|||
egbacf acdfe gfecb egdfcb dfgaceb dfb dgcb fdbce db bdeafg | fdb db db bdf |
|||
cfeg eabcf gdefcab bef geabc bfcad egbadf cfgbae egcdba fe | fgec gaecfdb cagbef ef |
|||
bafde dbgeac feacgbd cbaef bed bfgaed gafecd bgdf bd eafgd | db cfgdae caegdfb fabed |
|||
afg bacg cdbgf gcdfab fdcae gafdeb dbgfce ga dcafg cedabfg | gaf bdafgc agbc ga |
|||
edgca bafdcg acbdg cbdeag dce fgcea gdcfeb aebd ed gfdabce | ebgcad daeb edcga ced |
|||
agecf abfegc dbefcga ad dafc fegdb adg afgde bdcega ecagdf | fadeg dfac dga da |
|||
ceagdb gedac acfdbg cda bgecafd adgeb dcefg ca beac abgfde | aegbd baegd bdcagf abcdeg |
|||
egaf bagdce dcgabf ea eab cgbfa cdfebga fbcae dfcbe fgbace | gdfaceb gfea dbcfe eba |
|||
cfbega bge eg cgdebaf gedbc adeg bceadg bfadcg agbcd cdefb | ge ge cfedb fbgadec |
|||
afc ca cabe gbefcd aebcgdf acedf gbafdc eagfd edcfab dfbce | gbfdcea fca aecbfd ceba |
|||
af bcdag agbfde fdbca ebdfc adf dbefcga abedfc aefc dbgcfe | af acfe adf adcfbe |
|||
badfe agebd gfaced gbdcafe aecfd fab dbfc geacbf adbcfe bf | fb ebagfc beadf dface |
|||
bfeda gabefd agbedc ec fcadeb dfbaecg cea fdec afceb agfcb | fbcae cfde eac fedc |
|||
ebcf eafgcb egdfba dfcag bacge faceg afe gdceab ef dgcbaef | fcbe febc bcaeg cbfe |
|||
dafbc afdebg egfc ce eagbcd ceafgbd fgeba cbefa eac fcgeba | afegb cdagbe cbdaf gfaeb |
|||
ecd dface cdgafe gcabfd edbgcfa gdacf fecg cdbaeg ec efbad | edbaf gcafd dcgbaf dafgceb |
|||
gd fagbec bdfg gde cfgbe cefdbg gbdeacf agdcef bdceg bcdea | dg gcfeba dg ebdcg |
|||
bg bgdeac abdg cgb fcbade gdbceaf fbdgce dbeca gaebc aegfc | cgb befgdc fedgcb gbc |
|||
gac cgeda egcbafd gfdbce fadec ag degbca agecbf dagb gebcd | cdegb degcbaf cedaf edafc |
|||
ecfab bfacdg bdga gb cfgba bfg gefdacb cegdfb fagdc cafedg | bfg cefba gb aedbcgf |
|||
dgfce aeg cfbdgae acfgeb ebcafd ag gafed gaebfd bdga dbfea | gae cfbdae abedfg bgfdae |
|||
cgbad cbaf fbgeda dfgcab fdcebg dbfcg decag cdagbfe bga ab | dfcabg cbfa fcedgab adfcbeg |
|||
cegbadf edfgba cafeg dc agdebc dbgfe cdbefg dec dbcf edfcg | bdfc facdegb adfegb egbfd |
|||
bedf cefadg ced ed bcegd gefabc agcdbfe cdgab gcfbe fgcdbe | ed cde bdgec dbecfg |
|||
egfcab debfa ecd bfgec cdgb cd bdcef dgebcf ecdabgf egcadf | becfd cbgd gcdb fcbed |
|||
bc dbfge gbecf caefdg gefabc abgdcf bfc baec efcag cebgafd | baec fegbc agfec cgbef |
|||
bacegfd fbdgca egbcf fabce bdaefc dcaef dagefc ba dbae cab | daeb cbefa cab ab |
|||
fgab cgdfae fcgebd gb bcg dbaegcf cabed gadcb gcafd gbfadc | gbc adcgf dgecbf cgb |
|||
gdaeb df cgaebdf dfbe cbdagf eabdcg gfd aecgf aefdgb agedf | dfg gfcea febd ebdag |
|||
ecbaf cagfdb aecgf gac ebga defagcb baedfc gfcde ag gfbeca | cadbfg gaecbf agbfec fecba |
|||
edbgaf fbd egdbfca dagf gabde bdfge fd bgcfe efbcda eacdbg | fbd ebcdaf dbgaefc gefbda |
|||
acdbg aefcdg cdg cegb acebfd abgdf cg fbegadc gcbdae eabdc | gc edafbcg gadbc cg |
|||
fgcd bgdafe bacge dg facgde acfde agdec gdefbca deg aebcfd | gd eagdc ged ged |
|||
egfa efdcba dfbgc cbfea ga abcfg edgcab bga fecgdab aebfcg | bga faegcbd bfeadc badcge |
|||
bfeda ceagdb bf ebfacd edacb acefbdg begcdf bafc agfde feb | fb fb fbac bcegad |
|||
bfdcea dcbgaf cbega dbage cea ce cbafg gefc bgacfed bfecag | abgfc ec cegf acdefb |
|||
adgfce cdag cd fgecab cfgae ced fdbae gebdfc agbcefd ecafd | dfcae dc fdcae ebafcg |
|||
dbeag begfad bfdegac dcb cb gcfda ecdgfb ceab gcabd dcebag | cbd cb cegbda bgcdef |
|||
cdfaeb fgebad ea dcbgfa gcaebdf cegbd bdcae fabcd cfae eba | caef bafdce afec gfdbea |
|||
bcfega gcbea bdfgeca gabcd bd gdcabe dafcg ecdb dba ebfadg | fceadbg fbaceg db bd |
|||
gadcbe dgb debcaf fabgcd bcgfe bdgcf acfedbg gd cafdb gdaf | eafdcb bcfade badceg bdacfg |
|||
gafce cabde cdf aefbdgc efacgd fgeacb ceafd df efgd badfgc | edfg acbegf dfc gedf |
|||
afgce gbdecf bae adebcgf bgedca abecg abcd baefgd ba gbdec | ab dfagcbe gbeca ab |
|||
de dcgaf gcfbed gdebfca acegb cde bcgafe abed gdacbe gecda | ed afgcedb deagc gcdaf |
|||
gcdef ebfadc da dabefg daf fbaeg gaefcb dfeag gbdfcea bgad | gadfbe bafgce dgba afd |
|||
bdfeg gecf fc egdfcb gcbedaf bfc dfcbe cbdfga baced abedfg | fcge fgdecb dcgfabe fgdeb |
|||
bdf acbdfg bdaefg aefgbc abcde dagebfc fd dfcg cabdf cgfab | bfadc cabfg gfcdab fbaegc |
|||
af cdfbega edbfac dfbgc fac adef adecb becagd acdfb efcbga | bcagfde bdfcae gfdecab eacbd |
|||
egfcad bdgeac fdac fed cdage fd gcbfed baegf gfedcab gedfa | adceg fd afebg egdca |
|||
fegba ecbafgd cfegba cgdab efbgad ec fadcge ecg bcef cegba | bgadc ce fecgdba baceg |
|||
bdfaeg abgedc efadg bafd gfeba fcdebga adg aecgbf da ecfdg | ad ad dfba befcgad |
|||
efadcg dacfb cfgab bfde eafdc decfbag decbfa bd bcd acebgd | debf cafde gcdafe fcgebad |
|||
agd cgadef gcdebfa gd facge bdfgea eagbfc dcgaf cafdb ecdg | cbgfae ebfcga agcef bfdeag |
|||
dfbge abefgd aefbcg dcfegb ba fgbad gedafbc bdea fba dcafg | agfdb fab fba fcbgde |
|||
fcdab agbecd eacgfb gc fgeabd gdabc dgbea cbfdeag cag dceg | fcadb fbcad degba gca |
|||
eag cbefg dfeagbc cdfbga egcba dcegba dace agedbf ae gadbc | cegba age agbdc dbcafg |
|||
cdbag gfb dgceba cbfa gfdbac faebcgd deafg dgbaf fbegcd bf | eagdf febgcd fbdag gdfbce |
|||
cdbgf afcebg acfdbe ed ced bdefagc dcgbea fbeac cbdfe adef | cfbde de dec ecd |
|||
dfc fbcde dfcbga ecbgd egbdca fd eabfc edbfgc efdg cdfegab | df dgef fgbaedc df |
|||
fcg egcbd gacefb dfgbc abfcgde bfdga cfed cf gdebac gbecdf | bfdcg fgc fbcdg agdbf |
|||
fcabg acfbedg bfcgde ecbad agef ecfgba ecf fe dafbgc baecf | aegfbc cfe dbace fec |
|||
edbagc cefbda bfdeg af agcf gfebdca fgdcab dgcba baf fabdg | bcadef dfgcab abdcfe gedfb |
|||
acegf efbgcd dgbefac cgd bedga cbad agcedb dc egadc feagdb | badcgef cd dcgbfae cd |
|||
bfc cdafeb bcega gdcf afgdbe egbfd caebfdg gcefb cf debcgf | gcebf bgedf dfbgea fc |
|||
dgfaceb gcdf dabcg fd dfgba aefcbd bdacge gfabe afd dcagbf | daecgfb gbecda dacbfe gdcba |
|||
fbgedc bfcda cfg dafbge fecdbag cagfd aecg agfde cg adgcfe | ecdfagb gfceda gaebdf gbfdea |
|||
afbe gfa gfdcb af febcadg faegcb bcgea aedcbg eagfcd afgcb | bagcf gfdeca abfe af |
|||
caefg efd fd abedc fcgd egdcaf egafbd gfcbea dafec abgedcf | gaebcf fcedga def egcafbd |
|||
dcfab gefdcb bda da baefc baedcfg gfda dbceag cbfagd fbgdc | cdebga efdgbc fbcgead beafc |
|||
bgfed fdaegcb bedagc da bdacfg gda eacfgb cadf dafgb cabgf | dgceab da dfbeg bcegad |
|||
cedab fc adbfec faegcb adbgf cfa ecdf ebagcfd dcbfa ecgabd | becdaf cefd abdfc efcd |
|||
cdgbea aeg agdec dafgbc gbed aegbcf ge aecfbgd cagbd cafde | ceafd bagcd gacdb cgbad |
|||
dgfeb bedag cgdefa df gfdaeb cbdega gfdceba gbfec dafb gfd | fabecdg bdfa bdaf dfba |
|||
gdfe acdbf ed bdegcf cegbfa cebfd deb badegfc fbcge bgaced | ebd efgcabd bfcda dfeg |
|||
abfcedg gec fcgdbe gaebc gebfac efbdca gfea acbfe gbdca ge | agfe cge cdbgfe bcfdea |
|||
fgbaed dacegb dacef egafd aecbgf adfcebg bdfg ged agfbe gd | agdfceb gd dg fbgd |
|||
egdb acgbef edfac bd fgecb gbadfec bcafgd bcd bedcf gdecbf | bdc bedg gdbe efbgc |
|||
cagbef acgbf fgcabde cgd gbda dg dbfgec ecafd dgfca dagbcf | agbcfe dcgfa dbagcf cgdafeb |
|||
cb efbgc cgfae cgb gceafd beca fbcgae gefdb cbgadf dcfabeg | bgeacf bacedfg cbdgfa dfgbe |
|||
cgbedf facgdb agfdc cga cafed gfcbd gcdbeaf degacb fbag ag | gbaf acfed gafcd cgfda |
|||
egbdfca cadf bdafgc cbgfea cbgde bdcfg gfc cf fdbag gebdfa | eacdgfb fcda dfac adefcgb |
|||
fdgea abcd ac cfabge cdbfeg gdebac acg gcdebaf gadce bcedg | gac abefgc ac gcaed |
|||
eafdc eafbc agbe begcadf ba gcefba fgcbda gdbfce cba ecbgf | ba ab abeg adcgbf |
|||
afg ga bdafe eadfg dagc gefcab edbcgf ceagfd ecgdf aedcbfg | agdc daefb debcafg fdaeb |
|||
baf cbdgf afbecd gdcabfe dcfabg fadeg gbac gbadf ab cedgbf | fcdeba cbga afbdg bgca |
|||
ebdfgca ebfdag gb bgf fdeagc gdbe cdfgba egfab abcef agdfe | gb gfbdea gdeb eafbg |
|||
agbcdf fe gebad fea becf ecfbga cgabf aegfb fedgca acgbedf | ebgda ebdgacf fcbe aef |
|||
gdbef bgfadec gfeab eab gdcfbe ab bfadeg fdab dcaebg acgfe | fgadbe fbedgc dgefb aeb |
|||
adcbf fbdg bcf dcbag fecad cgafbd fb acdefgb bgefac dgcabe | dfcab cfb bf cdeaf |
|||
dfgbca cdebagf cfe fcbga aefdg geafc bdecgf ce bgefac aceb | bace aebc gfbac efc |
|||
adfegcb gcbaf fa adgcb acf efgacb fgcbed eadfbc agef fbgce | aefg acf gafe cfa |
|||
fdegbc fcbad ec ebgaf gecfdba feacb caefgb degfba ecb geac | ecb ecb cfadb ebafc |
|||
fegabc ebcgafd gfacde ge fcgeb ceg bagcf dcfbe ebga bdcfga | cefabdg fdceb abgcf gfeadc |
|||
fdabcg bgafc fcbeag edbfg gadfceb ad adb dfca dcbgae dfabg | bdegf faedbcg da caegfbd |
|||
cgfae gdbeca decaf fd dfbc fad dabegf daebc bedafgc efbcda | decfa fgcbdae fcbead dbegcaf |
|||
dbeaf cb fabecdg bcfda gabfdc cbfg agdfce abc edgcba cgadf | bcdefag bcgf dafbc badcgf |
|||
gbdcfa becfdg fdbcgea fgc cg fecdg efdgb ecadf gceb gadefb | gcbe fgcebda daecgbf aebcfgd |
|||
cdega dgcaeb cbgea egdcaf gfacedb begfda cebfg cbda bag ba | ab egdac beafdcg faegcdb |
|||
gab cgfab cfage fbaedc bcdg gb gacfbd defcagb gdebaf fadbc | bg fbacde gfabc dceagbf |
|||
ge ebg cgdfb cedba bedgc ecag deagcb bfceda gdcfeab egdbfa | bge beg bafged cadbeg |
|||
eabd ebacf ecd fdcbg dbafegc ed ceagdf fgceab ecfbda cdbef | dec dfcabe dec befca |
|||
afbgdec cedb dc agdbf cegbf bfcedg cdg bdgfc baecgf ecfdag | cd dgefbc fdgcb cd |
|||
gebdaf dgfae afe gafcbed agcfd febd edabg gbfeca bcdega fe | ebdag fedb egafd aegcbf |
|||
gebdcf abefdcg deg bgdfc fcde gbfea gedabc edbgf ed bgfcda | efdbg fedacbg gbfacd fbdeg |
|||
bcgd edagc gaebd bcdaeg fabedc bgefa fcadge agbfcde db adb | cgbdfae bdagcef badegc dab |
|||
df fdb bfadceg bgeadf afbdce efdg dgbae dafbg cafbg abdgec | gdfe afcgb ebcgafd fbgacde |
|||
gabce gdfaeb bcad cebdgfa fgcbae efgcd dga da cgdea cdeabg | ad agd gda gfedc |
|||
fcabge edbfg fcaebd ea dcbagef gace gafcdb bafcg eaf fgbea | dcfbage aceg afbdceg ebcafd |
|||
bafe egfcda be bfgaec gbe egcfbad fcaeg bdcaeg bgecf cfbdg | fabgced bfea gbcef gcfeb |
|||
badfeg fgecb af cgaebd acfdbge gaf afcged gfaeb dfab egbad | fa fga abfd gabde |
|||
afceg bcdfge fcaebg baegdcf cfg eabcdg bgfa efcad gcabe fg | abfg gf fbgecd acebgd |
|||
acbedgf fb efgdc bgf gbcfd bgfdac dagcb fdbeag ebcdga fcab | bf gdebaf fb bf |
|||
aecf cgbdefa bacged efbcga fdgcab febag af agf dgfeb ecabg | bcgdaf af cadfbge efca |
|||
egfda fgceab acd bfcadeg dc dcega bfdcea gcdb cdbega eacbg | gabecd cd befgcad gdcb |
|||
gecda dfegacb cgfae cdbfag fcbeag afg gf fbge dafecb caebf | dfaebc cfeab gf agdfbc |
|||
gdafe cdgaeb egfdba da bfdgec gbfed eagcf egdbafc fbad dag | agfde dga dcgbfe abcdfeg |
|||
acgdb gadfce cbefdga becad bcegdf bacgdf afbg ga dag dbcgf | abdgc gdeacf acdfbg ecdab |
|||
gdfa eadbc gcafe dgc dg fcagde bcgfea decgfb egcda fbecagd | cegda cgdea gd dg |
|||
ga egdbcfa aegcb cag egbcd gadceb gbcefd decafg badg cabfe | bagd cagfed gacdfeb cbegd |
|||
cb deafc bcgd agfceb dbfega ecb deacb aebgd cbafdge ebdacg | dcgb adceb edgba ceb |
|||
edgfab acgb becfdag bgf cgbdf cgfad dacbfg bg ecdbf afegdc | gfb bg gcfade gfbdeac |
|||
caebg cgaf acgdfbe begcaf cf fdgeb agedcb ebgfc cfe fbcdea | dbfeagc cfe fbeagdc cf |
|||
ageb bg adcbfge fcgea cbgaef cbdfa gfb fedacg bfgca fdcgeb | fbg afdcb ecgbdfa cgfdbe |
|||
dgbfe aeg ea dcea dbeagfc fbacgd ecbdag gadbc bcafge adgbe | aedc ae gbdef daec |
|||
dbafcg dbgaefc adfc egdab fdg df agefbc bdgcfe fbacg gdfba | bedgacf gcbaef cdfgab cafd |
|||
eg fdgcabe gcadbe aebdc gced bagfde gea gbeac afbcg ecdbaf | agfbc fgdabe fcdgaeb feabcd |
|||
fedb gfe defabgc caedg cgadbf feagd bdagfe fgbda efagbc ef | fe fgcbea ef dbfe |
|||
bc agcb dfceg bafgdc gfabd fbdcg bcd ecgfbda ebadgf fbaedc | cbd fabcgd cgbfd bc |
|||
ebfgc dbeg ed gefdc cde gfbecd fgdca caedfb gdbafec gefcab | fgdecb dgfce fbecg cabgfe |
|||
ab ebda bfagdc becgd aecfg bag daecgb ebcag gbacdfe cfgbde | abedgc eafgc ebacg ab |
|||
ecdbag dagbfe badef fcaed adc cd efbagdc cafge cfaebd dfbc | dcfb dca acd gcdabe |
|||
cedbgaf ecbfg dagfec dgbea bdca gfdaeb ecgbd dbecga cd edc | ecbdga cde edbag dc |
|||
egbfcd gbcafe ed defga dbgfa bcgdeaf cdea def eacdgf gacfe | bgfad ecda gbfad gcdefb |
|||
dafge cea fdace agdc dbgfea ebdfgca dcbfe acedfg abecfg ca | defac gcad ac ca |
|||
ecdba fbac eabcdf beadgfc acd efacgd ac agedbf bfdea ecgbd | aecbd agbefd bdgec dgebc |
|||
bfegda bdage gdf gfdae bdfgace fgeb afdec fgdacb gf deagcb | fbaegcd fegb aedgb dfg |
|||
cdaf fd bcdfge agebf dcgfae gfead baedcg gdcea egdbacf dgf | efgab df eagfd afgbe |
|||
egfca egcb ceafdb fbc fbcaeg dgbfa cdfeagb fgcba agdcef cb | cb gcdfae eabgfc fgbca |
|||
gdbca fdecba gdecfb feagbd ceb adfbgec bdgec ec efgdb cfge | ec ecbgd dacefb abfged |
|||
edbcag cabd ecfdgb aegfd eagfcbd ac cga feagcb ebdgc dgeca | acfbdeg dfgea cga dgeca |
|||
ebgacf adcf bcgedfa gdcabe abedf aef edabc fa befgd bfdaec | aefdb af cebad fae |
|||
dageb de gde dgfbce cgdba gabefd afbge cgdebfa aefd ceafbg | efgbda agbdecf bfaegcd edg |
|||
ce dec becf efdgb edfgcb ecbdag gdaefb beafgdc dagfc fecgd | ce fdbage gcdfeba gbcadef |
|||
ecgfa ebadcf ed gcdfab cdefa gfdaeb dbec dbfgace cdbfa dfe | dceb cdfab ed ceagf |
|||
cadg efgcdb gbcfad feabc agfcb afcdgbe dgbfa gcb fagbde gc | gdecbf adfgbc fbcgade gafbc |
|||
gdcefa gefdb bcfeg eabc fagdbc ecagf bcf afcebg cb bfgaedc | fcgdba agbecf fcgeba fgdceab |
|||
afgbc be cbeaf gfeb ebcdfag cfdbag cdfae cfegba cbeagd abe | gdecbaf cagfb bfgaec cabfdge |
|||
eb egdb dcagb abe gcdabe agbce dgabcf fedbca fdcebag gfeca | gdbe agdcb gfcae cgadbf |
|||
dbagc bcaedfg gade cadeb efgabc cabedg gca fgdbc ecafdb ag | dage cagdb dgcaeb cdgab |
|||
gbecd eacdg cgb egacdbf gfdbec efbg bfced bg bdfcea bafgdc | acbfde bg gb gb |
|||
fgbadc fbdag dbecg fbae dacgef ega ae afcbged ebgfad bgaed | ae bacfgd bfea agdbef |
|||
dacfeg gecfd ad gadbfe gadbfec gda acde fcedgb acbfg fdcag | gefcd cdegf agd ad |
|||
caegbd cfdeba edbac cfbegad fe fbea fdagc cef acdef bedgcf | ef cdafgeb fce edfca |
|||
dgcae cedbfag facbdg fdc eacdbf bfegda dfcae fdbae cf cfeb | cf febgcda dfc cdf |
|||
edfag dbeacg dbecafg agc gcefa gc bcfea cdfg fbdgae gefadc | dfacge fagbecd feacbdg bfaged |
|||
abefdg fgdec ecadf efcdab ac dbeaf acdb acf cdegfab gecbfa | fca fdbega decaf cgafdeb |
|||
bceafd fegcad edcagbf dbcage decba bafd df fcd bcfge cbfed | ebgfc eacbdf gadebc df |
|||
egba cgdafbe begfc gacdfb dceaf cefbdg gfa ag gcebaf aecfg | acbgfd gabe fbgeac agfec |
|||
cdgeb fdecag agdbefc gefbac cdaf ade fegdab cgead ad caefg | ecbgdaf dgceb cfgae dea |
|||
cafbde fbgac edcg agdfeb eg dacgef fgcea aefdc dceagfb eag | afgec fbcga ceafgd bgceadf |
|||
cefbg ceabd gd edbacgf aedfbc gaedcb cdbeg abfdcg gdc gead | cgd dgea gd cebad |
|||
fadbg dagecf fea fbecga adce ae bedfcg egacbdf fdgec fdage | dcae caed dbefcg adgfb |
|||
acged aec efgdcb ac fagc abdge abfdegc fdeacg cfaedb gedfc | egbcafd gaefcdb cae cagdfe |
|||
fcbdage bafgec cab fcbae ac abdegf dbfec fbgae eagc cbfadg | acb dafegb acb bfeagdc |
|||
af egfda gebdf gebdfa aefcdbg fbecda fgba daf cdeag dgbcfe | eagdc cefbgda daf daf |
|||
dgebcf gcf agcbd fbecd fbcdg ebacgf aebfcd fdeg fegdabc fg | dacgb dfge fcdbe gedf |
|||
bfacdg gafcb gefbd cd dgcfb dagc bdfagec bceadf fagceb bdc | begfd gbdfe afgcdbe fbeacgd |
|||
bagf afe bdcaeg fdcbe af dafbe cbedgaf gfebad gdaeb aefcdg | baedcgf fa af cgadbef |
|||
acdgf becgfa acd cagbf agcdbe fdba da bdcfag gfdec dcgafeb | bagfc da dca fdbacg |
|||
cdabfe adbfc ecbaf cdae cdbfge dabgfc bfgae bec ce gadcbef | faecbd beadcfg dcae cgfedab |
|||
bceag agd aced gdbafce bcfgae agdeb ad fabdcg fdbge egcbad | gaceb agd bdagec da |
|||
cag dfgbeac ecdbgf ag gfabc ebag fabgec deafgc adcfb fcegb | dgaecf aebg bgea dcbfa |
|||
afdb degbc agedcf da aed beacfg dgfecba efcab bdface cbdea | fbeca aecbd gdecaf ade |
|||
cafebg afedcb gfeabcd fgcb cfa afdeg fc ecgab dacebg cfeag | bcgf bgcae gdfea bgcf |
|||
feg gfcaed cfabdge gf degafb fdegc edfcab edgbc agcf cfade | gf gf gacf egf |
|||
ceadf ecdgf eacbd cebagd dcabfge eaf fdceab fbad fgebca af | cefadb cefad bfad abedc |
|||
gefabd cabdfeg dgceab dagef bdfacg egfdc edgab af feba fda | geadcb dagfceb fda af |
|||
dfcea adgce dfebc gecfdba fadgbe dcefga cfga aebcdg efa fa | fa fae af gaedbf |
|||
agbfd acbgedf faecb cegbad dgabfe gbc fcdg cfagb gc afdbgc | cg cg dfgbae cdfg |
|||
efg bfacg feab efcagd fe bcagedf edgbc ebgcf afbegc bcfgda | dgecfa ef fgcba efba |
|||
aebfdc bcfage dgbacf gface gbaecfd dfgce geab acfbg ea eac | cabfg ea cfagb eagb |
|||
gba gdcea cdbfg acgdb gbecadf bfgecd dgcfab abfc ba fdeagb | ab febagdc dfgbac fdagcb |
|||
dfcb gcebd dfgaec efdgc eagcb dfaebg afedcbg gbd gbcfde bd | gadebfc db febdga bgd |
|||
eabd adcbg ceafg ecb be eacdbg acegb gbfcde adgcbf ecfdgba | cgfebad cbe ebacg dfgceb |
|||
cefbgd cgdfa bagfced dabe fgceab abfeg gdbaef gbfad db gdb | aefdgb bd abdfegc fgabed |
|||
@ -0,0 +1,44 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
ones = 0 |
|||
fours = 0 |
|||
sevens = 0 |
|||
eights = 0 |
|||
|
|||
test = False |
|||
|
|||
for line in lines: |
|||
input_segments = "" |
|||
output_segments = "" |
|||
|
|||
if test == True: |
|||
if '|' in line: |
|||
input_segments = line.strip() |
|||
else: |
|||
output_segments = line.strip() |
|||
else: |
|||
parts = line.split('|') |
|||
input_segments = parts[0].strip() |
|||
output_segments = parts[1].strip() |
|||
|
|||
if output_segments == "": |
|||
continue |
|||
|
|||
output_parts = output_segments.split() |
|||
for output in output_parts: |
|||
num_signals = len(output) |
|||
if num_signals == 2: |
|||
ones = ones + 1 |
|||
elif num_signals == 3: |
|||
sevens = sevens + 1 |
|||
elif num_signals == 4: |
|||
fours = fours + 1 |
|||
elif num_signals == 7: |
|||
eights = eights + 1 |
|||
print(ones+fours+sevens+eights) |
|||
@ -0,0 +1,123 @@ |
|||
import os |
|||
|
|||
dir = os.path.dirname(os.path.abspath(__file__)) |
|||
|
|||
with open(os.path.join(dir, './input.txt'), 'r') as input_file: |
|||
|
|||
lines = input_file.readlines() |
|||
|
|||
total = 0 |
|||
|
|||
test = False |
|||
|
|||
for line in lines: |
|||
input_segments = "" |
|||
output_segments = "" |
|||
|
|||
if test == True: |
|||
if '|' in line: |
|||
input_segments = line.strip() |
|||
else: |
|||
output_segments = line.strip() |
|||
else: |
|||
parts = line.split('|') |
|||
input_segments = parts[0].strip() |
|||
output_segments = parts[1].strip() |
|||
|
|||
if output_segments == "": |
|||
continue |
|||
|
|||
output_parts = output_segments.split() |
|||
input_parts = input_segments.split() |
|||
one = "" |
|||
two = "" |
|||
three = "" |
|||
four = "" |
|||
five = "" |
|||
six = "" |
|||
seven = "" |
|||
eights = "" |
|||
nine = "" |
|||
zero = "" |
|||
for input in input_parts: |
|||
num_signals = len(input) |
|||
if num_signals == 2: |
|||
one = input |
|||
elif num_signals == 3: |
|||
seven = input |
|||
elif num_signals == 4: |
|||
four = input |
|||
elif num_signals == 7: |
|||
eight = input |
|||
|
|||
input_parts.remove(one) |
|||
input_parts.remove(seven) |
|||
input_parts.remove(four) |
|||
input_parts.remove(eight) |
|||
|
|||
segment_one = set(seven) - set(one) |
|||
|
|||
for input in input_parts: |
|||
num_signals = len(input) |
|||
if num_signals == 6: |
|||
if one[0] in set(input) and one[1] in set(input): |
|||
continue |
|||
six = input |
|||
|
|||
input_parts.remove(six) |
|||
|
|||
segment_three = set(eight) - set(six) |
|||
segment_six = set(one) - segment_three |
|||
|
|||
for input in input_parts: |
|||
num_signals = len(input) |
|||
if num_signals == 5: |
|||
if len(segment_six.intersection(set(input))) == 0: |
|||
two = input |
|||
|
|||
input_parts.remove(two) |
|||
|
|||
segment_two = set(six) - set(two) - segment_six |
|||
segment_four = set(four) - set(one) - segment_two |
|||
|
|||
for input in input_parts: |
|||
num_signals = len(input) |
|||
if num_signals == 6: |
|||
if len(segment_four.intersection(set(input))) == 0: |
|||
zero = input |
|||
else: |
|||
nine = input |
|||
elif num_signals == 5: |
|||
if len(segment_two.intersection(set(input))) == 0: |
|||
three = input |
|||
else: |
|||
five = input |
|||
|
|||
display_string = "" |
|||
for output in output_parts: |
|||
candidate = set(output) |
|||
if set(one) == candidate: |
|||
display_string = display_string + "1" |
|||
elif set(two) == candidate: |
|||
display_string = display_string + "2" |
|||
elif set(three) == candidate: |
|||
display_string = display_string + "3" |
|||
elif set(four) == candidate: |
|||
display_string = display_string + "4" |
|||
elif set(five) == candidate: |
|||
display_string = display_string + "5" |
|||
elif set(six) == candidate: |
|||
display_string = display_string + "6" |
|||
elif set(seven) == candidate: |
|||
display_string = display_string + "7" |
|||
elif set(eight) == candidate: |
|||
display_string = display_string + "8" |
|||
elif set(nine) == candidate: |
|||
display_string = display_string + "9" |
|||
elif set(zero) == candidate: |
|||
display_string = display_string + "0" |
|||
|
|||
total = total + int(display_string) |
|||
|
|||
print(total) |
|||
|
|||
Loading…
Reference in new issue