Browse Source

Fix edge case

master
Chris Smith 5 years ago
parent
commit
d415992930
1 changed files with 3 additions and 4 deletions
  1. 3
    4
      day17.nim

+ 3
- 4
day17.nim View File

91
 # still water, and we return true so that the row above us flows out.
91
 # still water, and we return true so that the row above us flows out.
92
 #
92
 #
93
 # Sides that aren't enclosed are flowed down. In complex shapes these
93
 # Sides that aren't enclosed are flowed down. In complex shapes these
94
-# may fill up areas below them. Where both sides fill up, or one side
95
-# is enclosed and the other fills up, we recursively call ourselves
96
-# to deal with the new situation.
94
+# may fill up areas below them. Where either side fills up, we
95
+# recursively call ourselves to deal with the new situation.
97
 #
96
 #
98
 # Finally, in other cases the cells inbetween the extents become
97
 # Finally, in other cases the cells inbetween the extents become
99
 # flowing water and we return false.
98
 # flowing water and we return false.
116
     if not right.enclosed:
115
     if not right.enclosed:
117
         rightFilled = grid.flowDown((right.last, point.y + 1))
116
         rightFilled = grid.flowDown((right.last, point.y + 1))
118
     
117
     
119
-    if (left.enclosed or leftFilled) and (right.enclosed or rightFilled):
118
+    if leftFilled or rightFilled:
120
         # We've filled in some holes and now our extents are no longer
119
         # We've filled in some holes and now our extents are no longer
121
         # valid. Recursively call ourselves to figure out what's what.
120
         # valid. Recursively call ourselves to figure out what's what.
122
         return flowOut(grid, point)
121
         return flowOut(grid, point)