day4 part1 complete.
This commit is contained in:
15
day4/part1.py
Normal file
15
day4/part1.py
Normal file
@@ -0,0 +1,15 @@
|
||||
input = open("./input.txt", "r")
|
||||
|
||||
total = 0
|
||||
|
||||
for line in input:
|
||||
trimmedLine = line.replace("\n", "")
|
||||
elves = trimmedLine.split(",")
|
||||
elf1 = elves[0].split("-")
|
||||
elf2 = elves[1].split("-")
|
||||
if (int(elf1[0]) <= int(elf2[0]) and int(elf1[1]) >= int(elf2[1])):
|
||||
total += 1
|
||||
elif (int(elf2[0]) <= int(elf1[0]) and int(elf2[1]) >= int(elf1[1])):
|
||||
total += 1
|
||||
|
||||
print(total)
|
||||
Reference in New Issue
Block a user