Bad practice (verging on wrong answer) in Battleship Hide! (13/7) unit


I don't like the "prompted" answer for Battleship Hide! unit- it works for this particular assignment, but will lead to insidious, hard-to-track bugs if generalized. Since this course seems to be geared to beginners, I believe you're doing them a disservice.

You are asked to generate a random row and column index for a given board. The instructions prompt you to use


to generate both a random row and column number. In this particular case, we have a 5x5 board, so using


will return correct results for both a randomly chosen row or a randomly chosen column.

The problem is that in the general case, the number of rows will not equal the number of columns!


is the number of rows in the board, and


is the number of columns in the first row (which we will have to hope is the same as in any other row!)

I think the "prompted" answer should be:



for the number of rows in the board, and


for the number of columns- perhaps with a discussion about the distinction, or even changing the board size so it's not square to force the discussion.

Up to this point, however, I think this is a great resource for those learning to code or learning a new language. Keep it up, please!

EDIT: I guess I spoke too soon- the next step (and Seek!) does use the correct expression


for the number of columns. However, it's kind of just slipped in when one progresses to the next level, and I think it would be better to either call attention to it- either before (so the student generates the correct code) or after (so the student understands why


is the correct expression for the number of columns.