first 13 stars
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
elves = []
|
||||
count = 0
|
||||
with open("input.txt", "r") as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip("\n")
|
||||
# Some python magic to split out the strings and convert them to integers
|
||||
pair = [x.split("-") for x in line.split(",")]
|
||||
pair = [[int(y) for y in x] for x in pair]
|
||||
elves.append(pair)
|
||||
# Elves is now a list of list of lists.
|
||||
for elf in elves:
|
||||
if ((elf[0][0] <= elf[1][0] and elf[0][1] >= elf[1][1]) or
|
||||
(elf[1][0] <= elf[0][0] and elf[1][1] >= elf[0][1])):
|
||||
print(elf)
|
||||
count += 1
|
||||
print(count)
|
||||
Reference in New Issue
Block a user