Initial commit
This commit is contained in:
commit
b1394d905a
18 changed files with 6496 additions and 0 deletions
22
day5/1.py
Normal file
22
day5/1.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
with open(r'day5/input.txt', 'r') as input:
|
||||
lines = input.read().split('\n')[:-1]
|
||||
|
||||
blank = lines.index('')
|
||||
|
||||
ranges = []
|
||||
|
||||
for i in range(blank):
|
||||
ranges.append(list(map(lambda x: int(x), lines[i].split('-'))))
|
||||
|
||||
print(ranges)
|
||||
|
||||
sum = 0
|
||||
|
||||
for i in range(blank+1,len(lines)):
|
||||
id = int(lines[i])
|
||||
for range in ranges:
|
||||
if range[0] <= id and range[1] >= id:
|
||||
sum+=1
|
||||
break
|
||||
|
||||
print(sum)
|
||||
Loading…
Add table
Add a link
Reference in a new issue