Questions tagged [fifteen]

The tag has no usage guidance.

0
votes
1answer
14 views

CS50 AP Game of Fifteen

I'm currently getting an error for "make sure game is winnable" but my program works with ./fifteen 3 < ~cs50/unit3/3x3.txt Here is my error log: :) fifteen.c exists. :) fifteen.c compiles. :) ...
1
vote
1answer
19 views

pset 3 fifteen - check50 failure last 3x3, 4x4

I was going to check my solution to pset3 fifteen with check50 while I received two failure errors on the console (on the last 3x3 and 4x4 checks). :) fifteen.c exists. :) fifteen.c compiles. :) ...
0
votes
1answer
36 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
1answer
44 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
1answer
30 views

game of fifteen problem with initialisation of my 2D array

I have been working on this program more than a week and even started once again from the beginning. I created init() function and draw() function in a separate file (they both are in main function ...
0
votes
1answer
49 views

pset3 problem fifteen

Pset3 seems to be my worst enemy at the moment. Finally done with 'find', thanks to this forum, but now I am stuck at 'fifteen'. I have the feeling that I am close to finishing 'fifteen' though, so I ...
0
votes
1answer
44 views

“Game of Fifteen” debug50 works but not actual execution

My init function works in step by step debug mode but it does not when I actually execute the file, why is this? void init(void) { for (int k = 0; k < d; k++) { for (int l = 0; l < d; l++)...
0
votes
2answers
96 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
1answer
47 views

Segmentation fault in pset3 Game of Fifteen

I'm a little lost. I've been trying to debug this segmentation fault for a few days now and still can't figure out what to do. I narrowed the problem down to a particular line of code thanks to a ...
0
votes
1answer
44 views

PSET3: Every move is ilegal, no matter what

I'm currently working on the move function that's in the game of fifteen and every single move is illegal even though my logic seems correct (at least to me), but it keeps outputting illegal move and ...
0
votes
1answer
47 views

CS50 Fifteen Code working perfectly, but not approved by check50

I have tested the code myself, through 3x3.txt, 4x4.txt and everything seems to be working perfectly and stopping the game when it is won. But I can't seem to get it approved by cs50 check. I have ...
0
votes
1answer
21 views

Pset3 Fifteen, generating array with extra zeros?

Thanks in advance for any tips. Why is my code generating lots of extra 000s when I generate the array? The code below outputs something like {{8,7,6,0,0,0,0,0,0},{5,4,3,0,0,0,0,0,} etc. This seems to ...
0
votes
1answer
34 views

check50 failed on pset3 game of fifteen

When I run the command check50.... it reports several correct and some incorrect outputs. One of the examples: :( 3x3 board: move blank up twice did not find "8-7-0|5-4-6|2-1..." Log running ./...
0
votes
1answer
32 views

Correcting invalid moves fifteen.c

I've been trying to correct the invalid moves, because in the check50, it doesn't stop for incorrect moves. I'm not really sure how to fix this, thanks! #define _XOPEN_SOURCE 500 #include ...
0
votes
2answers
112 views

pset3/fifteen/check50 fails on last output of some of the checks

The last output of some of the tests fail. The first failure was: 3x3 move blank up twice. My log.txt is identical to the log.txt of the staff solution and I do not have the word "file" in any of my ...
0
votes
1answer
153 views

Pset3 Fifteen Won function

Could anyone help to have a look at my code? I ran check50 and it works for 3x3 but 4x4. However, when I checked manually with 4x4, it works. Here is my code (won): bool won(void) { int win_board = ...
0
votes
1answer
16 views

The output is only _

So in this program, the only output I am getting is _. Help would be appreciated. My init: void init(void) { // Initializing the game int square; square = (d*d) - 1; for (int i = 0 ;...
0
votes
1answer
38 views

Help with the move function pset3 game of fifteen

I've been stuck on the move function for a really long time and I can just not figure out how to do it. I've tried to get help from other people and I really just don't understand any of it. Please ...
0
votes
1answer
47 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
1answer
30 views

Help finishing the move function pset3

I've been stuck on this problem for a really long time. I think I'm almost done with the move function, but I need someone to explain what I need to do. Please help me. My code is: bool move(int ...
0
votes
1answer
36 views

Pset 3 move function not working

I tried to make the move function recently, and it doesn't put the tile where it is supposed to go. It moves the blank over, and only once. Please help me fix this. My code is ` bool move(int ...
0
votes
1answer
41 views

Pset3/fifteen works but doesn't pass check50

I've almost finished "fifteen". It works: outputs correct board from 3x3 to 9x9 with 'init' void init(void) { int k = (d * d) - 1; for (int j = 0; j < d; j++) { for (int i = 0; i < d; i++) ...
0
votes
1answer
38 views

PSET3- Game of fifteen, function move();

So, my move function is ALMOST working, but sometimes when swaping numbers both tile AND blank space shows up as a blank space...can you guys check my code? Thanks! Ps..Blank is a global variable, ...
0
votes
1answer
26 views

Why can an integer data type be declared with board[DIM_MAX][DIM_MAX]

Just a quick conceptual question here: in pset3 fifteen, line 27 of the given code shows: int board[DIM_MAX][DIM_MAX] I just want to check my understanding here- board has not yet been declared as a ...
0
votes
1answer
40 views

Swapping 1 and 2 on even number boards in fifteen.c

For fifteen, I have finished most of init and draw, but it doesn't print right for even number boards. Can someone run this code and let me know how to fix it? My full code is /** * fifteen.c *...
0
votes
1answer
44 views

Init function in pset 3

I've been working on fifteen, and I started with the init function, and I want to make sure I have it right. Other than the part where you swap 1 and 2, does this look right? void init(void) { ...
0
votes
1answer
42 views

Swapping 1 and 2 in fifteen.c

I made the init function in a different tab so I can check it, and it won't switch 1 and 2. My code is /** * fifteen.c * * Implements Game of Fifteen (generalized to d x d). * * Usage: fifteen d ...
0
votes
1answer
52 views

Init for fifteen.c

For fifteen, I tried to make init in another tab so I could check to see if I have it right. Also, I'm not sure if I swap 1 and 2 in the init function or in the move function. My code so far is: /** ...
0
votes
1answer
94 views

pset3 fifteen check50 error [duplicate]

Can someone help me understand what's going on with my code? check50 keeps telling me "can't check until a frown turns upside down" even though the code compiles correctly. I don't know what this ...
1
vote
1answer
41 views

ps3 Move, check50, illegal move are moving? help please

Please, I spent so many hours on this and I can't find the mistake I am doing. From the start, there are some numbers still move when they are illegal move. See description from check50: :( 3x3 ...
0
votes
1answer
32 views

Fifteen- Pset3: Weird error that is not my fault - help

Well my Fifteen doesn't compile because get_int but I included cs50 library. What I am missing? Check the screen shot please. Thank you!
0
votes
2answers
45 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
1answer
64 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
1answer
35 views

The tile doesnt swap or move when i use this code!

I have been stuck on this for two days now. Would really appreciate some fast help! every time i run this it and put in Tile to move:3 all the numbers on the board change can u give me ideas on how to ...
0
votes
1answer
36 views

Pset3 - Fifteen - Move() Accepts Legal Moves, but does not swap?

I have been able to successfully draw the board with the correct configuration, but when I try to implement move(), I cannot get the values of tile to swap with the blank space. As it currently stands,...
0
votes
1answer
163 views

PSET 3: Game of fifteen. Everything in the board is equal to zero

CS50 community! I have a problem with my PSET 3. I've done only init() and draw() functions and can't understand what's wrong, so I can't go on. It prints blankspaces all over the board, so everything ...
0
votes
2answers
109 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
1answer
24 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
1answer
41 views

Proceeding in fifteen move function with five if and else-if segments?

I am at the move function within fifteen. I plan to do four if, else-if functions for each of four possible moves. The first bool move(int tile) { for (int i=0; i < d; i++ ) { for (int j=0; j&...
0
votes
0answers
35 views

Strange print out for fifteen?

To print out the grid, I used this code: void init(void) { int k = d*d - 1; for (int i=0; i < d; i++ ) { for (int j=0; j<d; j++, k--) { board[i][j] = k; } } board[d][d]= ...
0
votes
1answer
1k views

How to fix “variable-sized object may not be initialized” error?

I am trying to code the init part of the fifteen function. I thought to do: void init(void) { int i = 0; int j = 0; int k = d*d -1; for (i; i < d; i++ ) { for (j; j<d; j++, k--) { ...
0
votes
1answer
37 views

Correct implementation of init function in fifteen

I would like to check the validity of the various functions in fifteen on a step-by-step basis. For example, I hope that I managed to code the init part of the function correctly: void init(void) { ...
0
votes
1answer
37 views

fifteen.c(what is wrong in my code)

bool won(void) { int count = 0; for(int row=0;row < d;row++) { for(int column=0;column < d;column++) { count++; if(board [row][column] == count %(d *...
0
votes
1answer
46 views

Can't seem to figure out what's wrong with my code pset3 game of fifteen

Any and all help appreciated. Please and thank you. :) Here's my code: https://gist.github.com/noilddude/48e7d0f30ee5bb80d7e0f5d2490899b2 Here's what happens when I run check50:
1
vote
2answers
53 views

game of fifteen check50

by checking with check50. I got following error :( 3x3 board, move blank up (tile 3), then try tile 2 \ expected "0" character 5 of line 10, not "2":) 3x3.txt wins the 3x3 board Link: https://...
0
votes
1answer
52 views

Pset3 Fifteen: “move” moves only once

My "move" function lets me make one move. After that, anything I do is illegal. This is my code: bool move(int tile) { int a = d - 1; int b = d - 1; for (int i = 0; i < d; i++) { for (int j ...
1
vote
1answer
52 views

function of fprintf fopen

In the pset3 Game of fifteen What is the role of fprintf, fopen and other functions starting with f And what is the function of FILE *file = fopen("log.txt", "w"); fprintf(file, "%i", board[i][j])...
0
votes
1answer
111 views

Pset3/fifteen.c : What does the usleep() function do?

Please can anybody explain me what is the usleep() function that has been used in many places in the fifteen.c source code? What about the different tyoes of arguments that have been passed to the ...
0
votes
1answer
89 views

pset 3 fifteen log.txt file not matching board

My code for fifteen.c works and solves the test inputs of the 3x3.txt file and the 4x4.txt file. However the check50 fails for the following. :) fifteen.c exists :) fifteen.c compiles :( init ...
0
votes
2answers
146 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 ...