This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
${c2}_-o#&&*''''?d:>b\\_ | |
_o/"`''${c4}~~${c2}'',,~dMF9MMMMMHo_ | |
.o&#'${c4}~~~~~~~~${c2}`"MbHMMMMMMMMMMMHo. | |
.o""~'${c4}~~~~~~~~~${c2}vodM*$&&HMMMMMMMMMM?. | |
,'${c4}~~~~~~~~~~~~~~${c2}$M&ood,${c4}~${c2}'`(&##MMMMMMH\\ | |
/${c4}~~~~~~~~~~~~~~~${c2},MMMMMMM#b?#bobMMMMHMMML | |
&${c4}~~~~~~~~~~~~~~${c2}?MMMMMMMMMMMMMMMMM7MMM$R*Hk | |
?$.${c4}~~~~~~~~~~~~${c2}:MMMMMMMMMMMMMMMMMMM/HMMM|`*L | |
|${c4}~~~~~~~~~~~~~~~${c2}|MMMMMMMMMMMMMMMMMMMMbMH'${c4}~~~${c2}T, | |
$H#:${c4}~~~~~~~~~~~~${c2}`*MMMMMMMMMMMMMMMMMMMMb#}'${c4}~~${c2}`? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
test = False | |
file = 'data/task11test.txt' if test else 'data/task11.txt' | |
with open(file) as f: | |
octipi = numpy.array([[int(x) for x in list(y)] for y in f.read().splitlines()]) | |
def incrementNeighbors(y,x): | |
ymax = len(octipi)-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
test = False | |
file = 'data/task11test.txt' if test else 'data/task11.txt' | |
with open(file) as f: | |
octipi = numpy.array([[int(x) for x in list(y)] for y in f.read().splitlines()]) | |
def incrementNeighbors(y,x): | |
ymax = len(octipi)-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test = False | |
file = 'data/task10test.txt' if test else 'data/task10.txt' | |
with open(file) as f: | |
lines = f.read().splitlines() | |
opencharacters = ['[', '{','\'','<'] | |
def bufferReverse(buffer): | |
score = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test = False | |
file = 'data/task10test.txt' if test else 'data/task10.txt' | |
with open(file) as f: | |
lines = f.read().splitlines() | |
opencharacters = ['[', '{','\'','<'] | |
score = 0 | |
for line in lines: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
from functools import reduce | |
import uuid | |
test = False | |
file = 'data/task9test.txt' if test else 'data/task9.txt' | |
class Basin: | |
nodes: list | |
basinName: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
test = False | |
file = 'data/task9test.txt' if test else 'data/task9.txt' | |
with open(file) as f: | |
depthmap = numpy.array([[int(x) for x in list(y)] for y in f.read().splitlines()]) | |
print(depthmap) | |
risk = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
test = False | |
file = 'data/task8test.txt' if test else 'data/task8.txt' | |
data = [] | |
with open(file) as f: | |
lines = f.read().splitlines() | |
for line in lines: | |
tmp1 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test = False | |
file = 'data/task8test.txt' if test else 'data/task8.txt' | |
data = [] | |
with open(file) as f: | |
lines = f.read().splitlines() | |
for line in lines: | |
data.extend(line.split(' | ')[1].split(' ')) | |
count = sum(list(map(lambda x: 1 if len(x) == 2 or len(x) == 3 or len(x) == 4 or len (x)==7 else 0, data))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test = False | |
file = 'data/task7test.txt' if test else 'data/task7.txt' | |
with open(file) as f: | |
crabmarines = [int(x) for x in next(f).split(',')] | |
bestPosition = 9999999999 | |
for position in range(min(crabmarines),max(crabmarines)+1): | |
curPosition = sum(list(map(lambda x: abs(position-x)*((abs(position-x)+1)/2), crabmarines))) | |
if curPosition < bestPosition: |
NewerOlder