Questions tagged [won]
The won tag has no usage guidance.
50
questions
0
votes
1
answer
24
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 ...
0
votes
1
answer
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()...
0
votes
1
answer
48
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!
0
votes
1
answer
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] <...
0
votes
2
answers
109
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[...
0
votes
1
answer
56
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 ...
0
votes
1
answer
62
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 ...
0
votes
1
answer
40
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 (...
0
votes
1
answer
30
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;
...
0
votes
2
answers
50
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; ...
0
votes
1
answer
92
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 ...
0
votes
1
answer
43
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 ...
0
votes
1
answer
41
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 ...
0
votes
2
answers
115
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. ...
0
votes
1
answer
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(...
0
votes
1
answer
106
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....
0
votes
1
answer
67
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[...
0
votes
2
answers
151
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 ...
0
votes
1
answer
73
views
pset3 fifteen logical error in won function, please help
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 ...
0
votes
1
answer
90
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.
0
votes
1
answer
494
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 ...
0
votes
1
answer
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 ...
0
votes
1
answer
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 ...
0
votes
1
answer
78
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 ...
1
vote
2
answers
602
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 ...
0
votes
1
answer
120
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 ...
0
votes
1
answer
92
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 ...
0
votes
1
answer
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++)
{
...
0
votes
1
answer
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*...
1
vote
1
answer
673
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
:...
0
votes
1
answer
41
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 ...
0
votes
2
answers
355
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 (...
0
votes
1
answer
76
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,
* ...
2
votes
1
answer
147
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 ...
0
votes
0
answers
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 ...
0
votes
1
answer
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 :/
0
votes
1
answer
280
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 ...
0
votes
1
answer
362
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 (...
0
votes
1
answer
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 &...
0
votes
1
answer
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 ,...
0
votes
1
answer
584
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 ...
0
votes
1
answer
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] == ...
0
votes
1
answer
419
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++)
{
...
0
votes
0
answers
85
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:
...
0
votes
1
answer
116
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 ...
0
votes
1
answer
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)
{
...
-1
votes
1
answer
306
views
pset3 won - segmentation fault?
I've tried a solution for function won but I always get segmentation fault (core dump). First for loop is row
It doesn't work... always this segmentation fault.... what am I doing wrong? please help!
1
vote
1
answer
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++...
0
votes
3
answers
684
views
Error in my logic? Pset3 Won
Could someone explain me why my superb idea isn't working? Okay, perhaps it isn't that superb but it was my original own idea.
In pset3 fifteen game when seeing if the game is won, I first created a ...
0
votes
2
answers
852
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 ...