timo bombino

This commit is contained in:
awerbrouck 2021-12-01 13:10:21 +01:00
parent 9f7eae8d51
commit 77ee7859a2
10 changed files with 2076 additions and 1 deletions

Binary file not shown.

2000
2021/SWAMP/2021/py/id1.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,10 @@
from w1 import d1
def main():
print(d1.part1())
print(d1.part2())
if __name__ == '__main__':
main()

View file

@ -0,0 +1,41 @@
def read(inputData):
with open(inputData, "r") as infile:
data = infile.readlines()
return data
def strArrToIntArray(inputData):
return [int(value.replace("\n","").replace(" ","")) for value in inputData]
def readAsIntArray(inputData):
return strArrToIntArray(read(inputData))
def keepEven(inputData):
return [d for d in inputData if d % 2 == 0]
def keepUneven(inputData):
return [d for d in inputData if d % 2 == 1]
def keepIfContaint(inputData, toContain):
return [d for d in inputData if toContain in d]
def removeIfContains(inputData, toContain):
return [d for d in inputData if not toContain in d]
def keepIfDevisor(inputData, toDiv):
return [d for d in inputData if toDiv % d == 0]
def keepIfDivisibleBy(inputData, toDiv):
return [d for d in inputData if d % toDiv == 0]
def get_primelist(lower, upper):
result = []
for cp in range ( lower, upper + 1 ):
for i in range ( lower, cp ):
if ( cp % i == 0 ):
break
else:
result.append(cp)
return result

View file

Binary file not shown.

View file

@ -0,0 +1,24 @@
import util
def count_increments(depths, slice_length):
increments = 0
slice_start = 0
slice_end = slice_start + slice_length
prev = depths[slice_start:slice_end]
for i in range(len(depths)):
idx = i+1
slice = depths[idx:idx+slice_length]
if (sum(slice) > sum(prev) and len(slice) == slice_length):
increments += 1
prev = slice
return increments
def part1():
depths = util.readAsIntArray("id1.txt")
return count_increments(depths, 1)
def part2():
depths = util.readAsIntArray("id1.txt")
return count_increments(depths,3)

1
2021/SWAMP/README.md Normal file
View file

@ -0,0 +1 @@
# AoC

1
SWAMP

@ -1 +0,0 @@
Subproject commit 16cd1dd8eb8a7c7e39a5ad8780e8c6a9af7c00c0