-
Notifications
You must be signed in to change notification settings - Fork 0
jmoons/hitting_rock_bottom
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Setup reading of input file 1) Get units of water, store in constant 2) each row will be represented in a array representation of that row's map data split into individual characters 3) each row becomes an element of an array - array[0] = top of map, array[last] = bottom of map 4) Need to determine best data structure for depths of each column Iterate through the units of water 1) Start at the last row of the array, and add water to lowest, left-most point. If row is full (before rock or wall), move up one row. 2) When water is added, increment that columns depth record. Forget the bottom-up approach, it is not how water flows according to the spec. 1) Try with a instance variable that tracks the position of where the water currently is 2) for each unit of water a) go to that position and see if water can flow down i) if yes, flow down, move to next unit of water ii) if no, see if water can flow to the right 1) if yes, flow to the right, move to next unit of water 2) if no, go to previous row, find last water mark and see if it can flow to right We just need to know the last row of water flow 1) Scan to last ~ 2) Determine if water can flow down a) If yes, flow down, update row of last flow, move to next unit of water b) If no, determine if water can flow to the right i) If yes, flow to the right, update row of last flow, move to next unit of water ii) If no, go to previous row, scan to last ~, repeat from 'b' Check on each failed flow to the right, check to see if we are in the top-left corner and filled, then just bail.
About
puzzle_node_11_hitting_rock_bottom
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published