Solved Stage 2 — why reverse the loops? MAMateoGOP 24 Oct, 11:27 Stage 1 goes row by row, stage 2 column by column. Why?
LILiamByte24 Oct, 17:51 Solutionreplies: 1To decide if a column is clear you need to look at every row in that column before deciding. So the outer loop is the column, the inner loop goes through rows, and a blocked flag records whether any row had debris there.
AMAmeliaRuns25 Oct, 10:34replies: 1Reset blocked = False at the start of each column, not before the outer loop. That's the usual bug.
Comments 5
Join the discussion CommentAlready have an account? Log in
To decide if a column is clear you need to look at every row in that column before deciding. So the outer loop is the column, the inner loop goes through rows, and a
blockedflag records whether any row had debris there.So the outer loop is "the thing I'm deciding about". Nice rule.
Reset
blocked = Falseat the start of each column, not before the outer loop. That's the usual bug....which I had. Every column after the first was blocked 😅
Great 2D exercise. Grids appear in so many problems.