Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Game of Fifteen, one of the assignments in Problem Set 3
3
votes
Accepted
PSET 3: Game of fifteen. Everything in the board is equal to zero
You only need to delete this and the code will work:
int board[d][d];
The reason is that the global variable board is declared above and can be used by any function
int board[DIM_MAX][DIM_MAX] …
2
votes
Accepted
Long numbers appearing when trying to retrieve element of 2D array - Game of Fifteen, pset3
Delete this: int board[d][d];
The reason is that board has already been declared globally int board[DIM_MAX][DIM_MAX] and filled with values by init(). Int board[d][d] declares new, local variable an …
1
vote
Accepted
won function does not seem to return true (even though it should)
Why do you loop till j < d - 1 not j < d? For board 3*3, you miss board[0][2] so should return false for board[1][0].
However, I do not understand why you are stack in an infinite loop. You should re …
1
vote
Accepted
check50 error on PSET3 Game of Fifteen
output "ftw" doesn't mean by itself that all is fine.
The first line of check50 error says that something is wrong with "5" tile. And indeed, it is.
The positions in the beginning are: "5" is at [1] …
1
vote
Accepted
PSET3 'Illegal Move" coming up for legal moves as well! Almost done!
The initial position of blank tile is board[d-1][d-1], not board[d][d].
Other issues:
When checking tiles around the blank one, you go outside of the board borders, if the blank tile touches the bo …
1
vote
Accepted
PSET3 Game Of Fifteen tiles not swapping! (no illegal function but no change in board)
Well, now you correctly check if the move tile and the blank tile are next to each other. It's not the shortest and not the most stylish way to do it, but OK. Then, in theory, you need to swap these t …