Timeline for Debugging code for won function in game of fifteen
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 5, 2017 at 2:41 | comment | added | rasdocus | that would be more elegant,i agree, thanks | |
Mar 4, 2017 at 2:46 | comment | added | Cliff B |
Yeah, I should have looked closer. I completely skipped over j starting at 1 and assumed it started at 0. Your change definitely will work, but it has about 2 or 3 extra calculations in each loop. Wouldn't it make more sense to have j go from 0 to d-1, the same as i, and to change the formula to k = k+d; ?
|
|
Mar 4, 2017 at 2:42 | vote | accept | rasdocus | ||
Mar 4, 2017 at 2:42 | comment | added | rasdocus | I changed it to board[i][j-1] and the problem was solved, thanks for your help | |
Mar 4, 2017 at 2:41 | comment | added | rasdocus | I got it!, even though I was incrementing J from 1 and not 0, it was messing up my board[i][j] as it was checking board[0][1] on the very first cell and not board[0][0]. | |
Mar 4, 2017 at 2:21 | comment | added | rasdocus | I think the formula is correct and I checked it on paper; My code starts j from 1 and goes up to d while my i starts from 0 to d-1. | |
Mar 3, 2017 at 12:33 | history | answered | Cliff B | CC BY-SA 3.0 |