Questions tagged [pset3]

The problem set for Week 3 asks students to write code for a classic puzzle game in the C programming language.

Filter by
Sorted by
Tagged with
1
vote
1answer
846 views

How to test helpers.c

I'm just wondering the best way to test out sort and search in helpers.c. Since the file won't compile/run on its own, how can I test the code that I'm writing?
0
votes
1answer
108 views

Dereferencing 2d pointer to print board

I've used pointers to help create my game of fifteen grid, and now I want to print out the board using 'draw'. The function works to the point that the board prints, but instead of array elements I ...
0
votes
1answer
525 views

helpers.c is not sorting my array and I'm running low on ideas on how to fix it

My first question on this board and I really need some help in order to figure out what could be wrong with my code. I decided to go with a a selection sort but as soon as I run ./generate 2 2 in ...
0
votes
3answers
681 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
2answers
119 views

GDB stops at GetInt()

I tried using GDB for my Game of Fifteen but I can't get to the part of functions move and won because GDB stops when command line asks for tile to move. This has something to do with GetInt. GDB ...
0
votes
1answer
93 views

Why isn't pset3 marked? [duplicate]

It's not really a question about coding. I was just wondering why my pset3, which I submitted two months ago, hasn't been marked yet. Sorry about using this forum, but I'm taking the course through ...
0
votes
2answers
72 views

How to define something in a loop only once and have it remain after function ends and is called again?

for pset3 my move function is the following: int j = 0; for(int i = 0; j < d; i++) { if(i == d) { i = 0; j++; } if(board[i][j] == tile) { printf("%i, %i", i, j); ...
1
vote
4answers
132 views

Pset3: why are the j and i values not swapping?

Here is my code: for(int i = 1; i < n - 1; i++) { printf("%i\n %i\n", i, j); int j = i + 1; if(values[j] < values[i]) { int tmp = j; j = i; i = ...
2
votes
2answers
513 views

Find.c does not find the value that I put in haystack

For pset3, I have to download pset3.zi and unzip it. I followed all the steps in the instruction. However, when I get to the program find.c, there's a problem. The program seems like not working ...
1
vote
2answers
98 views

Do we have to implement game of fifteen in pset3 using graphics?

Does fifteen.c had to be implemented in graphics, by including graphics.h and creating the tiles as graphical objects?
0
votes
2answers
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 ...
3
votes
3answers
416 views

Blank tile without using a variable

Regarding the blank tile in Game of Fifteen, can I avoid using a variable for the blank? In other words, can I just print an underscore when I reach zero in my array?
0
votes
2answers
2k views

pset3: sort — having trouble connecting all the dots

I'm not sure what to work on. The pset3 instructions say: Go ahead and implement sort so that the function actually sorts... Odds are you’ll want to implement bubble sort, selection sort, or ...
0
votes
2answers
189 views

How to Stop Making my move() Function Keep Printing “Tile to move”?

Please explain me why fifteen's move() function is successfully compiles and, runs but keeps printing "Tile to move:" without printing anything else like invalid input and so on. GDB gives me the ...
1
vote
2answers
1k views

Pset3 Fifteen Move function

I dont even know how to begin the move function, can somebody give me some ideas please? Probably by searching the tiles position, but how can i do that?
0
votes
1answer
510 views

How to Print the Blank Tile in the Game of Fifteen

In Game of fifteen we are asked to print a blank space at the end of the game, they fistly tell us to put the last number as any Int, then they ask us to print something that is not the int we chose, ...
2
votes
3answers
3k views

helpers.c Doesn't Compile

I'm trying to compile helpers.c (pset 3), but it doesn't compile successfully. It gives me the following error: jharvard@appliance (~/Dropbox/pset3/find): make helpers clang -ggdb3 -O0 -std=c99 -Wall ...
2
votes
1answer
2k views

why do we pass arguments to the main function?

I did not understand that ,why do we pass arguments to the main function? for example in pset3 generate.c main {int argc,string argv[]}. please explain?

1
22 23 24 25
26