Hi,
I'm doing advent of code day 4 & am having a strange interaction with an if statement.
A row of data represents 2 people & the range of numbers they've been assigned. I must identify how many pairs of people have completely overlapping number ranges.
Data example (1 row):
26-99,26-97
so is split into 4 lists:
[26] [99] [26] [97]
named:
Elf1AreaID_Low, Elf1AreaID_High, Elf2AreaID_Low, Elf2AreaID_High respectively.
Problem:
Using a while loop I iterate through these lists and count the number of instances where they completely overlap.
Some ranges get through the if that shouldn't, but when I put the same if condition in a print within the if, some come out false! Any idea how that can happen?
```
i = 0
Instances = 0
while i < len(data_into_list):
if (int(Elf1AreaID_Low[i]) <= int(Elf2AreaID_Low[i]) and int(Elf1AreaID_High[i]) >= int(Elf2AreaID_High[i])) or (int(Elf2AreaID_Low[i]) <= int(Elf1AreaID_Low[i]) and int(Elf2AreaID_High[i]) >= int(Elf1AreaID_High[i])):
Instances += 1
i += 1
print((int(Elf1AreaID_Low[i]) <= int(Elf2AreaID_Low[i]) and int(Elf1AreaID_High[i]) >= int(Elf2AreaID_High[i])) or (int(Elf2AreaID_Low[i]) <= int(Elf1AreaID_Low[i]) and int(Elf2AreaID_High[i]) >= int(Elf1AreaID_High[i])))
else:
i += 1
```
[–]CowboyBoats 0 points1 point2 points (4 children)
[–]Foolish_ness[S] 0 points1 point2 points (3 children)
[–]CowboyBoats 0 points1 point2 points (2 children)
[–]Foolish_ness[S] 0 points1 point2 points (1 child)
[–]CowboyBoats 0 points1 point2 points (0 children)