You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: everybody_codes/event2025/quest_11.py
+38-53Lines changed: 38 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
"""Everyone Codes Day N."""
2
2
3
3
importmath
4
-
importtime
5
4
fromlibimporthelpers
6
5
fromlibimportparsers
7
6
@@ -22,18 +21,25 @@ def experiment2(ducks):
22
21
In this example, two ducks from col 1 can flow into the basin on cols 3-4.
23
22
24
23
1. Find a peak: any column taller than the next column.
25
-
2. Find the basin: the first column shorter than the next one. Flow into here. Extend this basin if there are repeated low columns.
24
+
2. Find the basin: the first column shorter than the next one. Flow into here.
25
+
Extend this basin if there are repeated low columns.
26
26
3. Determine how high the basin can be filled.
27
-
3a. If the peak is adjacent to the basin: `(source - dest) / (width + 1) * width` (rounded up/down/maybe).
28
-
3b. If the peak is not adjacent to the basin: `min( [source - source_neighbor], [basin_right - basin], [basin_left, basin] )`.
29
-
4. Flood fill the basin, tracking movements. Source through basin edge have movement of flow amount. Basin tiles get moves equal to `sum(fill for that column and all basin columns to its right)`.
30
-
5. Basin fill is a tad messy unless `flow_amount % basin_width == 0`. I used `basin_fills, extra = divmod(flow_amount, basin_width)` where the right `extra` spots of the basin get `basin_fills + 1` and the left part of the basin gets `basin_fills`.
0 commit comments