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
0
votes
1answer
58 views

pset3 check receives standard error from init()

The game compiles and runs, passing all the other tests in check50 when entered manually, but on the step for testing init, check50 fails. Here's the check50 output: https://sandbox.cs50.net/checks/...
0
votes
1answer
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] <...
1
vote
4answers
458 views

Pset3 fifteen.c - Move function allows invalid moves

To implement the move() function I divided it into three functions, one to find the tile inputted by the user, one to check if the move is legal, and one to actually move the tiles. At first it looked ...
1
vote
1answer
43 views

How do i declare an integer in main and have it recognised in a sub function?

I need line 72 declaration to apply to the formula stated on line 207. I have formatted it this way because previously my move() function was re-declaring the variable zeroi, which did not allow it ...
0
votes
1answer
45 views

GetWidth error CS 50 breakout

How do I fix this problem? breakout.c:109:26: error: expected expression if (getX(ball) + getWidth() >= getWidth(window)) ^ /usr/include/spl/generic.h:44:49: note: ...
0
votes
1answer
56 views

PSET 3 Linear Search Error

Keep getting the error of "control may reach end of non-void function" This is for the linear search, can someone please give me some help/tips into getting this error to go away? This is my code: ...
0
votes
1answer
48 views

How to solve the deflated by (x%) while using zip -r pset3.zip pset3?

My solution is correct while checking but when I try to zip it it says deflated by certain percent. I don't know if it is a problem in my machine. I tried to upload the same zipeed version, but there ...
0
votes
1answer
47 views

Help fixing bubble sort

I've been working on implementing a bubble sort, and I can get it to swap one time through the list, but I can't get it to run more than once, and I'm not sure how to implement it. I also know that ...
0
votes
2answers
90 views

Pset3 Game of Fifteen - Zeroes

void init(void) { int count = d*d-1; for(int i=0; i < d; i++) { for(int j = 0;j< d;j++) { board[i][j] = count; count--; } } //if even number swap 1 and 2 if(d%2==1) ...
0
votes
1answer
539 views

pset3 implementing bubblesort, how should i test what is most likely garbage?

i am a total beginner and i tried to implement bubble sort as follows: void swap(int* a, int* b) { int temp = *a; *a = *b; *b = temp; } void sort(int values[], int n) { do int counter=0; ...
0
votes
1answer
430 views

pset3 Tideman: function to print out preferences array is not working

I have written a function, print2d(), to print out a 2D array. I am using it to print out the preferences array after calling record_preferences() in main according to the provided template. The ...
0
votes
1answer
48 views

pset3 Linear search output problem

the code isn't working for ./generate 1000 50 | ./find 127 and also for other inputs too. Please help.
2
votes
1answer
660 views

argc value count confusion

I'm having some confusion on Pset3. In the program "generate.c" there is an "if" condition for validating the argument counts. Here is the portion I'm having confusion : if (argc != 2 && argc ...
0
votes
1answer
68 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
397 views

CS50 pset3 music - EOF segmentation fault

I've compiled notes and synthesize using cmd make without any errors. running notes works just fine but when I run synthesize, it gives a segmentation error when I pass EOF command (ctr+D). I've gone ...
0
votes
3answers
343 views

I can't check sort in Helpers.c

After reading the other questions, I still don't get how to check it. I tried to use gdb on ./find, but while I ran it, I could only see what was expected. Then, while typing n, it said "in fileops.c"...
0
votes
2answers
50 views

Pset3 - move function - Keep getting an “Initialize the variable” message

bool move(int tile) { int xaxis = d - 1; int yaxis = d - 1; int tile_i; int tile_j; search_the_board(tile); if (tile_i == xaxis + 1 || tile_i == xaxis - 1) if (tile_j == ...
0
votes
1answer
69 views

Calculate n (semitones) for frequency in pset3

I'm having a bit of a hard time trying to calculate the value of n(the number of semitones from A4). I'm currently using the following formula: if (octave > A4_OCTAVE) { n = (octave - ...
0
votes
1answer
67 views

Pset3 Move Function “Illegal Move”

my code is notifying me with "Illegal Move" every time I test it. I was wondering if someone can help figure out what is wrong with my code? bool move(int tile) { // TODO int i, j; int swap; //rows ...
0
votes
1answer
77 views

Writing the .wav file fails with command-line notes

I have verified that my frequency(note) function returns the correct frequency as an int. However, when I attempt to write out using the "command-line note entry" testing scenario described (and yes ...
0
votes
0answers
18 views

Okay, legit think that check50 on Tideman is broken

Actually not, still I cannot grasp what is wrong with the lock_pairs function in my code. This is my lock_pairs function: // Loop to pass each pair for (int i = 0; i < pair_count; i++) { ...
1
vote
1answer
144 views

pset3 runoff help -> 3 :( showing on check50

I'm getting the following fails when I check pset3 runoff (all the rest are coming up as correct) :( tabulate counts votes when multiple candidates are eliminated tabulate function did not produce ...
0
votes
1answer
89 views

Breakout - wall collisions work…sometimes

I'm trying to get the ball to collide with all of the walls of the window. My current code works for the first 3 seconds of gameplay but then the ball will jiggle through a wall. I'll show you the ...
0
votes
1answer
84 views

CS50 Pset3 “Fifteen” Works but doesn't pass Check50

My code for pset3 "fifteen" works perfectly when I play it—board sizes fit, goes in descending order, blank space prints as a 0 etc. etc. but for some reason, it won't pass any check50 checks past "...
0
votes
1answer
97 views

game of fiteen doubts in code and in check50

have a look at my game of fifteen code at: http://pastebin.com/gpZnkTPp it is showing errors in check50 , but i don't know what's wrong with my code check50 2015.fall.pset3.fifteen fifteen.c :) ...
0
votes
1answer
391 views

killed by server

) helpers.c exists :( helpers.c compiles \ killed by server :| finds 42 in {42,43,44} \ can't check until a frown turns upside down :| finds 42 in {41,42,43} \ can't check until a frown turns ...
0
votes
1answer
77 views

in pset3 error while performing check50

when i use check50....it is showing error in helper.c but i didn't find any error in source codes of programs or helper.c i wrote programs for generate.c and find.c but they didnt gave any errors i ...
0
votes
2answers
150 views

what is the significance of break; in tabulate function?

I know break statements are pretty basic, but it's got me here: This is my function: for (int i = 0; i < voter_count; i++) { for (int j = 0; j < candidate_count; j++) { if (...
0
votes
1answer
334 views

PSet 3, binary search implementation

I'm struggling with implementation of binary search in PSet 3, and my code can't quite get past check50. Here's my code: bool search(int value, int values[], int n) { // TODO: implement a ...
0
votes
2answers
384 views

Check50, Game of Fifteen. Timed out while waiting for “Illegal move”

I've finished working on my pset3 game of fifteen. After consulting Check50, it keeps telling me that: timed out while waiting for "Illegal move." Can someone explain this to me? Don't know what to do....
0
votes
2answers
71 views

PSet 3 Plurality keeps getting 'segmentation fault'

This keeps coming up with "segmentation fault" when I run it although everything I want it do is working. It seems to be coming from the last if statement because there's no fault when I delete that ...
2
votes
1answer
150 views

check50 error: CERT_HAS_EXPIRED

I'm using check50 to check my linear search algorithm in pset3, and it doesn't seem to be uploading or checking at all. Instead I get the message: Uploading.. CERT_HAS_EXPIRED and the second time: ...
0
votes
1answer
206 views

Have I got the right idea? Pset3/Fifteen/Move

This is my code for identifying the blank tile: bool move(int tile) { int temp; int didSwap; int blankTile = 0; // search for blank tile for(int row = 0; row < d; row++) ...
1
vote
2answers
547 views

Best solution to move the ball in Breakout?

What's the best solution for providing proper parameters (x,y) for move() function? "Move() function" we use it to move the ball in the Breakout game.
0
votes
1answer
270 views

pset3 command line error make/clang

clang testing.c -lcs50 -o testing /tmp/testing-6c5209.o: In function `main': testing.c:(.text+0x3f): undefined reference to `sort' clang: error: linker command failed with exit code 1 (use -v to see ...
0
votes
1answer
204 views

Sort is not working on Pset3

After many hours can't figure out why the sorting and searching is not working... When running tests it I always get "Didn't find needle in haystack" whether the value is in or not in the array... ...
0
votes
1answer
169 views

Game of fifteen: everything works perfect until winning move breaks game

I've gotten pretty much everything working in fifteen. The tiles move correctly, the redraw works with a board of any size, et cetera. So I pasted in the ./fifteen 3 < ~cs50/pset3/3x3.txt the pset ...
1
vote
1answer
334 views

CS50 pset 3 breakout segmentation fault when lives --;

I get a segmentation fault after x times i "die" (it varies) and if i decrement the lives each time the ball hits the bottom i get a segmentation fault after 1 time. It's very anoying and i can't find ...
0
votes
1answer
807 views

linear search compilation error

I've updated search function in helpers.c with code below. I had to remove reference to helpers.h since that was causing even more errors. #include <cs50.h> // #include "helpers.h&...
0
votes
1answer
257 views

pset3: How to check for paddle edges?

When implementing breakout, i am having a hard time trying to figure out how to check if the ball hits the horizontal edges of the paddle. So far everything else works fine, but when the ball touches ...
0
votes
1answer
98 views

pset3 binary search , problems with check50

i have tried a lot but cannot find the meaning of the last two errors of check50 please help
0
votes
3answers
46 views

Even though I get correct output check50 shows error in pset3 plurality problem

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int ...
0
votes
1answer
81 views

If / else if / crazy behavior

How Is it possible that the code below do prints the printf ("Found it!") statement, but don't return true as the statement that follows? Instead, it's returning false as the last statement outside ...
0
votes
1answer
119 views

Pset 3 helpers.c check 50 errors

#include <cs50.h> #include <stdio.h> #include "helpers.h" //TODO binearysearch, om te controlere van de waarde. bool search(int value, int values[], int n) { int left = 0; int ...
0
votes
1answer
241 views

Music: Error loading audio file

I have finished Pset 3 with no issues compiling or any issues with check50. However, when I try to play the .wav file that I have generated using ./synthesize jeopardy.wav < songs/jeopardy.txt, the ...
0
votes
1answer
165 views

pset3 I did print winner from pluarity, but check50 says I didn't. What's wrong?

I ran plurality according to spec and was able to print out all winners correctly. check50 says I didn't. What could be the problem? Is there any way to see what check50 used as inputs for plurality? ...
0
votes
1answer
217 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
262 views

pset3 music frequency question

I am working on pset3 music frequency. I struggled with finding a pattern of frequencies for different notes, so instead, i created two arrays one with all possible note (C,D,E,F,G,A,B) and another ...
0
votes
1answer
71 views

Pset 3: Breakout initBricks implementation

I don't understand why my implementation of initBricks isn't working. I noticed that most people have been using nested loops for the ROWS and COLS and I don't particularly mind using doing that too, ...
0
votes
1answer
239 views

Pset 3 - Binary Search - clang: error: linker command failed with exit code 1

When I compile, with "make find", the following code: I get: So, if I'm interpreting this correctly, there's an undefined reference to search on line 58 of find.c, which is -- if (search(needle, ...

1
2 3 4 5
26