Questions tagged [won]

The tag has no usage guidance.

50 questions
Filter by
Sorted by
Tagged with
146 views

How do I get to work gdb to check my Won function in game of fifteen

there is a staff implementation of predefined set of moves for a 3 x 3 board which can be executed by ./fifteen 3 < ~cs50/pset3/3x3.txt I was working on my Won function, can some one tell me how ...
588 views

pset3 fifteen won

I've been attempting many different ways to make this work and I either come up with everything stopping once the game looks like it's been won and an "illegal move" and "retry" message, or I end up ...
670 views

expected an exit code of 0, not a prompt for input WON

I'm still stuggling with the game of fifteen, and I could make it works. However, when I run check50 it displays :( 3x3.txt wins the 3x3 board \ expected an exit code of 0, not a prompt for input :...
274 views

won() Doesn't Work Properly

My won() function works properly when the board dimensions are 3 x 3. However, it doesn't work properly when the board dimensions are 4 x 4. What could possibly be wrong? for (int i = 0; i < d; i++...
851 views

Pset3 won-function works only with 3x3 board. Where am I wrong?

Pset3 won-function successfully passed this test ./fifteen 3 < ~cs50/pset3/3x3.txt only for a 3 × 3 board. For a 4x4 board the program's output is: 1 2 3 4 5 6 7 _ 9 10 12 ...
105 views

Won()- Pset 3- Game of Fifteen

I'm having trouble seeing where my logic is going wrong with my won() function for Game of Fifteen (Pset 3). For example looking at my for loop, let's say d=4, i = 2, j = 1. Then board[i][j] = board[...
114 views

Pset3 Game of Fifteen Won Function

The won function for fifteen is driving me crazy! Here's my implementation. I've run it through debug50 and it appears to work as expected. However, check50 only passes on a 4x4 board, but not a 3x3. ...
98 views

game of fifteen won function (still!!) not working

I have been working on my won function for days now, and have read all the relevant posts on this site but still cant work out where I'm going wrong. The code does not return true when passed the 3x3....
22 views

fifteen won function timing out

So I have looked and seen very similar (non-working) solutions, but my code is very slightly different from what I've seen here, and the answers that I've seen haven't really helped me. I'm a complete ...
40 views

Won() function not working and gives error

This error is shown while compiling(error is pointed to the last closing bracket of won function)- error: control may reach end of non-void function [-Werror,-Wreturn-type]. here is my code for won()...
90 views

Fifteen - help please, I can't find the problem in my code for move and won

I'm still at the first move to understand what is going wrong. If my first tile to move is the number work, it does work, so 3 and - swap, but the game show me ftw! ??? and when I move for the first ...
42 views

won function does not seem to return true (even though it should)

So this has been a little frustrating. Even though the rest of the problem went well I cannot figure out where I went wrong. Here's the idea; set a counter called value that increments by every time ...
38 views

pset 3 won() function always return false

I'm stuck on the logic in pset3 won() function. Apparently, the function just doesn't return true no matter what. Here is my code. bool won(void) { int n = 1; //iterate over the board for ...
25 views

won does not return exit code of 0

I am working through the Game of Fifteen and have almost completed it, but the program does not return an exit code of 0, which I'm almost certain is due to my won function. Here's my code: bool won(...
62 views

won returns illegal move when board reaches winning configuration

This is the code for the won() function. bool won(void) { int counter=1; for(int i=0;i<d;i++) { for(int j=0;j<d;j++) { if (board[d-1][d-1]!=0 || (board[...
489 views

pset3 fifteen won kind of give up

After two weeks struggle, I still can not come up with a solution to the won function. I divided the whole board into 3 areas: 1) rows except the last row (i.e. 0<=id+1 until (d-1)(d-2). Value at ...
114 views

Pset3 Fifteen won function reorders correctly but finished with illegal move, what's wrong?

I'm completely stuck. I don't understand what I'm doing wrong! My won functions correctly checks the game and allows for reordering of the entire board when checking with 3x3.txt but when it gets to ...
90 views

pset3 check50 can't pass won for expected prompt input not exit code 0

Help!! I can't get pass check50 for won with the message 'expected prompt input not exit code'. I thought we supposed to expect exit code 0 (here is another discussion on this matter: expected an ...
36 views

fifteen, won function does not seem to return if game one

My plan was simple. first check if the zero is in the right place. Then see if the element is correct using a formula and adding a counter so i only do it until i reach the field where the zero should ...
1k views

Why is my pset3 fifteen won function not working?

It's still hard for me to see what I am doing wrong.. I am initializing a counter to 1. Then inside 2 for loops (to iterate over the board), I place the next code: if (board[i][j] == ...
414 views

pset3 game of fifteen, won function

Can someone please tell me is this code for the won function works ? And if not , why? int counter=0; for(int line=1; line<=d;line++) { for(int column=1;column<=d;column++) { ...
114 views

Why my won routine does not return true even if the game is completed?

I've been struggling with the final stage of fifteen programming. So far up to move, my coding is working OK. In my 'won' routine, I'm checking all of the tiles are in the ascending order. The blank ...
1k views

pset3 fifteen won function isn't working?

I've been trying to write the won function for days, but it has never worked correctly. I can't find any flaws in my logic, so can somone help me figure out what I'm doing wrong? ebool won(void) { ...
47 views

allmost done, pset3 fifteen 4x4 doesnt work

I can not fix the won function. Itso almost complete but the 4x4 is not winnable... please help!
63 views

Error: Make sure game is winnable (fifteen) won

bool won(void) { for(int i= 0; i<d; i++) { for(int j = 0; j <d; j++) { if((i==(d - 1)) && (j==(d -1)) && board[i][j]== 0) { if(board[i][j] <...
51 views

pset3 game of fifteen won() function does not work

Just in case, I'll put the code of the other functions, but they, like, are successfully tested. void init(void) { int value = d*d - 1, c; for(int i = 0; i < d; i++) { for(int ...
55 views

pset3 game of fifteen won()

The won() function, which I thought was pretty straightforward, initially gave me some trouble. I had it trying to evaluate the if statement seen below in a loop that iterated over each position of ...
36 views

Pset 3 Game of Fifteen Won Function

I've used check50 to confirm that everything is working except for my won function. I've tried many different variations of the below code, and I'm not sure why it's not working. bool won(void) { if (...
26 views

Pset3_Fifteen_Won()

bool won(void) { // TODO for(int r=0;r<d;r++) { for(int c=0;c<d;c++) { if(c==r==(d-1)) { if(board[r][c] != 0) { return true; ...
49 views

Pset3, Game of Fifteen, won, game keeps winning!

for the final part of fifteen, my game wins automatically upon start up and I'm not sure why, please help, thanks. my code is as follows: bool won(void) { //for each row for (int i = 0; i < d; ...
150 views

Problems with won function on pset3

Everything is ok with the code, except of check50 which reports this one mistake, I assume problem is in my won function because everything else works. Can someone explain to me where mistake actually ...
73 views

Check50 gives me this error: :( 3x3.txt wins the 3x3 board \ expected an exit code of 0, not a prompt for input :( 4x4.txt wins the 4x4 board \ expected an exit code of 0, not a prompt for input I'm ...
84 views

Fifteen won returning ftw

Can anyone tell me why the code doesn't work as I had expected ? It keeps returning ftw even if it's not.
64 views

PSET3 WON…is it flawless?

So after weeks of struggle, i'm happy to say i finally completed this pset last night. the WON function took me a while as i couldn't figure out how to account for the final tile as blank, but somehow ...
122 views

PSET 3 WON logic

Stuck on WON where the check is failing on the winning prompts. I can't really use GDB and debug WON without actually trying to beat the game, but i don't think my logic is wrong in this code. Have a ...
71 views

Am I on the right track for won?

Can someone please tell me if my "won" logic will work? Will loop through each tile making sure first tile is 1, second tile is 2, etc. If a tile is not the expected number, return false(not sure if ...
70 views

won function pset3

here's my code. bool won(void) { int counter = 1; if (board[d -1][d -1] == '_') { for(int i = 0; i <d; i++) { for(int j = 0; j < d; j++) { ...
49 views

pset3 won function - Where does the “return true;” statement go?

bool won(void) { int counter = 1; for (int i = 0; i < d; i++) { for (int j = 0; j< d; j++) { while (board[i][j] != board[d-1][d-1] && counter != d*...
278 views

Won function of pset3 game of fifteen making error

My code is not able to compile clang is stating error in won function. My code is as follows: /** * fifteen.c * * Computer Science 50 * Problem Set 3 * * Implements Game of Fifteen (...
71 views

My won function is not working. I am getting the following checks. https://sandbox.cs50.net/checks/6ca6c632ceb0408aaac04be0ed215bfe

/** * fifteen.c * * Computer Science 50 * Problem Set 3 * * Implements Game of Fifteen (generalized to d x d). * * Usage: fifteen d * * whereby the board's dimensions are to be d x d, * ...
122 views

Move function not working in Game of Fifteen

I cant seem to find the bug why my move function is not working for me, any help would be much appreciated bool won(void) { int counter = 0; // loop for rows to start from one position left ...
30 views

Pset 3 doesn't check winning

http://pastebin.com/F8EiMheJ Really long block of code, sorry. The won() function starts from row 456 while it is called on row 99. Not really sure where the problem is :/
278 views

PSET3 Fifteen Won Function not returning True

In the 'Won' function I tried to do two things: check if the array is in order and to cater to the blank space (underscore in my case) I used the counter method to check if each cell corresponds to ...
361 views

Can’t get pset3 fifteen fails 3x3 and 4x4 txt wins the board

My thanks in advance to anyone who can fix my logic. I’m a beginner in every sense. I’ve read every post tagged w/”won.” I can’t get gdb to debug “won" and have manually mapped out i and j values (...
150 views

pset3 won code looks like it should work but doesnt…

So I finally got the code working when it looks like this: int k, l, m = 0; for (k = 0; k < d; k++) { for (l = 0; l < d; l++) { if (board[k][l] == m + 1 &...
1k views

in pset3,fifteen.c

When the won function is working. check50 gives the following result: And after intentionally making the won function wrong ,the result through check50 is: Now,it's obvious that to win the game ,...
583 views

pset3 Fifteen: Function won won't win

After running the check50, errors below appear: :( 3x3.txt wins the 3x3 board \ expected an exit code of 0, not a prompt for input :( 4x4.txt wins the 4x4 board \ expected an exit code of 0, not a ...
80 views

Why won't my won function return true?

I'm having an issue my won function to return true. When I use the 3x3.txt file I get an Illegal Move message when won should return true. Not really sure what I'm missing here. Here is my code: ...