Luna Lailatova
2 years ago
6 changed files with 5111 additions and 13 deletions
@ -0,0 +1,20 @@ |
|||||||
|
# building input |
||||||
|
with open('in.txt','r') as f: |
||||||
|
inp = f.read().splitlines(keepends=False) |
||||||
|
|
||||||
|
blueprints = [] |
||||||
|
|
||||||
|
for line in inp: |
||||||
|
tempA, tempB = line.split(' ore. Each clay robot costs ') |
||||||
|
oreBot = int(tempA[-1]) |
||||||
|
clayBot, tempC = tempB.split(' ore. Each obsidian robot costs ') |
||||||
|
clayBot = int(clayBot) |
||||||
|
tempC, tempD = tempC.split(' clay. Each geode robot costs ') |
||||||
|
obsidianBot = tuple(map(int, tempC.split(' ore and '))) |
||||||
|
tempA, tempB = tempD.split(' ore and ') |
||||||
|
tempB, _ = tempB.split(' obsidian') |
||||||
|
geodeBot = (int(tempA), int(tempB)) |
||||||
|
blueprints.append((oreBot, clayBot, obsidianBot, geodeBot)) |
||||||
|
|
||||||
|
for blueprint in blueprints: |
||||||
|
print(blueprint) |
@ -0,0 +1,52 @@ |
|||||||
|
with open('input20.txt','r') as f: |
||||||
|
inp = f.read().splitlines(keepends=False) |
||||||
|
|
||||||
|
sequence = [] |
||||||
|
|
||||||
|
for i in range(len(inp)): |
||||||
|
if int(inp[i]) == 0: |
||||||
|
zero = (i, int(inp[i])) |
||||||
|
sequence.append((i, int(inp[i]))) |
||||||
|
numbers = sequence.copy() |
||||||
|
|
||||||
|
for number in sequence: |
||||||
|
if sequence.count(number) > 1: |
||||||
|
print('!') |
||||||
|
|
||||||
|
for number in numbers: |
||||||
|
#print(number[0]) |
||||||
|
index = sequence.index(number) |
||||||
|
_number = number[1] |
||||||
|
newIndex = index + _number |
||||||
|
while not (len(sequence) * -1) <= newIndex < len(sequence): |
||||||
|
if newIndex < (len(sequence) * -1): |
||||||
|
newIndex += len(sequence) |
||||||
|
if newIndex >= len(sequence): |
||||||
|
newIndex -= len(sequence) - 1 |
||||||
|
if newIndex == 0: |
||||||
|
newIndex = len(sequence) - 1 |
||||||
|
elif newIndex < 0: |
||||||
|
newIndex = len(sequence) -1 + newIndex |
||||||
|
if _number >= len(sequence): |
||||||
|
newIndex += 1 |
||||||
|
if _number <= (len(sequence)* -1): |
||||||
|
newIndex -= 1 |
||||||
|
if newIndex > index: |
||||||
|
newIndex += 1 |
||||||
|
sequence.insert(newIndex, number) |
||||||
|
sequence.pop(index) |
||||||
|
else: |
||||||
|
sequence.pop(index) |
||||||
|
sequence.insert(newIndex, number) |
||||||
|
#print(sequence) |
||||||
|
|
||||||
|
|
||||||
|
number = sequence.index(zero) + 1000 |
||||||
|
_sum = 0 |
||||||
|
for i in range(3): |
||||||
|
number %= len(sequence) |
||||||
|
#print(sequence[number]) |
||||||
|
_sum += sequence[number][1] |
||||||
|
number += 1000 |
||||||
|
|
||||||
|
print(_sum) |
@ -1,13 +1,2 @@ |
|||||||
2,2,2 |
Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian. |
||||||
1,2,2 |
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian. |
||||||
3,2,2 |
|
||||||
2,1,2 |
|
||||||
2,3,2 |
|
||||||
2,2,1 |
|
||||||
2,2,3 |
|
||||||
2,2,4 |
|
||||||
2,2,6 |
|
||||||
1,2,5 |
|
||||||
3,2,5 |
|
||||||
2,1,5 |
|
||||||
2,3,5 |
|
@ -0,0 +1,30 @@ |
|||||||
|
Blueprint 1: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 2 ore and 12 obsidian. |
||||||
|
Blueprint 2: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 2 ore and 9 obsidian. |
||||||
|
Blueprint 3: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 3 ore and 10 obsidian. |
||||||
|
Blueprint 4: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 4 ore and 15 obsidian. |
||||||
|
Blueprint 5: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 12 clay. Each geode robot costs 3 ore and 15 obsidian. |
||||||
|
Blueprint 6: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 3 ore and 19 obsidian. |
||||||
|
Blueprint 7: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 7 clay. Each geode robot costs 4 ore and 17 obsidian. |
||||||
|
Blueprint 8: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 14 clay. Each geode robot costs 3 ore and 16 obsidian. |
||||||
|
Blueprint 9: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 2 ore and 9 obsidian. |
||||||
|
Blueprint 10: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 7 obsidian. |
||||||
|
Blueprint 11: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 4 ore and 9 obsidian. |
||||||
|
Blueprint 12: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 16 clay. Each geode robot costs 3 ore and 14 obsidian. |
||||||
|
Blueprint 13: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 18 clay. Each geode robot costs 2 ore and 19 obsidian. |
||||||
|
Blueprint 14: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 13 clay. Each geode robot costs 3 ore and 12 obsidian. |
||||||
|
Blueprint 15: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 16 clay. Each geode robot costs 3 ore and 9 obsidian. |
||||||
|
Blueprint 16: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 4 ore and 8 obsidian. |
||||||
|
Blueprint 17: Each ore robot costs 2 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 17 clay. Each geode robot costs 2 ore and 10 obsidian. |
||||||
|
Blueprint 18: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 16 clay. Each geode robot costs 2 ore and 11 obsidian. |
||||||
|
Blueprint 19: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 12 clay. Each geode robot costs 3 ore and 8 obsidian. |
||||||
|
Blueprint 20: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 12 clay. Each geode robot costs 3 ore and 17 obsidian. |
||||||
|
Blueprint 21: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 2 ore and 9 obsidian. |
||||||
|
Blueprint 22: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 4 ore and 20 obsidian. |
||||||
|
Blueprint 23: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 3 ore and 10 obsidian. |
||||||
|
Blueprint 24: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 9 clay. Each geode robot costs 3 ore and 7 obsidian. |
||||||
|
Blueprint 25: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 3 ore and 19 obsidian. |
||||||
|
Blueprint 26: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 16 clay. Each geode robot costs 3 ore and 20 obsidian. |
||||||
|
Blueprint 27: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 19 clay. Each geode robot costs 4 ore and 11 obsidian. |
||||||
|
Blueprint 28: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 4 ore and 7 obsidian. |
||||||
|
Blueprint 29: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 2 ore and 12 obsidian. |
||||||
|
Blueprint 30: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 2 ore and 15 obsidian. |
Loading…
Reference in new issue