Questions tagged [pset3]

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

302 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
0
votes
0answers
86 views

My linear search can't find any values. Why?

Here's the code for my pset 3, which fails to find the '127' in the stack. Any hints will be massively appreciated: bool search(int value, int values[], int n) { for(int i = 0; i < n; i++) ...
0
votes
0answers
139 views

Paddle lags while ball is moving (Pset3 breakout)

Hey guys sorry in advance if I format this wrong it's my first time posting here. The problem i'm having with my code is the paddle lags maybe about 10 seconds behind the actual input while the ball ...
0
votes
0answers
27 views

Fatal error spl/gwindow.h with version 29

When I try to begin breakout with pset 3, I run into Fatal error spl/gwindow.h although I have 2014 version 29 of the appliance. Really stuck here, any help would be great
0
votes
0answers
90 views

pset3 segmentation fault decodeColor Colors must have 6 or 8 hexadecimal digits

I am developing my Breakout, and have just added the check for collision with bricks. This line, to check for brick/ball collision: if (strcmp(getType(object), "GRect") == 0) {//commented code;} ......
0
votes
1answer
167 views

Breakout Bricks coding caused segmentation-fault error! HELP!

After coding my Bricks for BREAKOUT, I get Segmentation error and my Paddle, Ball, and Scoreboard no longer appear! The bricks look great, but everything else disappeared and I get the fault error. ...
0
votes
1answer
201 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
3answers
342 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
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
0answers
45 views

pset3 gwindow header include error in window.c file

pset 3 gwindow header file error.my appliance vesion is 19-2 and when i am include gwindow.h it show an error for which i have attached screenshot below. pls help me ASAP.
0
votes
0answers
55 views

Pset3 : Ball doesn't begin motion from center of window

I initially instantiated the ball in the center of the window using the initBall function. However after I implemented the code to move the ball randomly across the window, it doesn't begin its motion ...
0
votes
0answers
55 views

Linker error with breakout.c

I have attached the linker error and a listing of the files in the directory that contains breakout.c. I think I have the right setup, but it won't compile. the clang command is clang -ggdb3 -O0 -...
0
votes
0answers
91 views

Why paddle is not visible at bottom middle of window?

I have instantiated the function initPaddle(). The function returns a paddle and I can see it in the window at various location coordinates that I provide. But, when I provide location coordinates ...
0
votes
1answer
148 views

Pset3: First row of bricks are not removed (rest all are removed)

The first row of the bricks are not removed. The ball goes above the first row of bricks and bounces the top wall comes down. But still the top row bricks don't disapper. Is there something amiss with ...
0
votes
1answer
495 views

Pset3, detect collision, paddle not ‘colliding'

I used the code given in the set GObject object = detectCollision(window, ball); if(object !=NULL) { if(object== paddle) { y_velocity=-y_velocity } } else if (strcmp(getType(object), "...
0
votes
0answers
52 views

check50 giving that the answer is correct of pset3 but in gradebook i am not getting full marks

I checked my answer of pset3 with check50 and its says fine but in gradebook i am not getting full marks.
0
votes
0answers
162 views

encountered error : ack while trying to write code to move paddle

What is error : ack? I am at that part of breakout where one has to make the paddle move in accordance to the mouse movement. I have successfully compiled the code, but when i run it.... the paddle ...
0
votes
1answer
256 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
269 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
2answers
176 views

How can I compile to Windows from the appliance?

I am currently using the appliance through VMWare, and while doing the breakout program I find myself with 2 problems. One the game runs quite laggy, both versions (staff and mine), and it is quite ...
0
votes
1answer
78 views

binarysearch no errors from compiler, but only spews out gibberish , anyone got an idea?

To make it more readable i thought this time i will just post the link to my helpers.file. The bubblesort worked and the linary search before too. Maybe i did something wrong in the implementation of ...
0
votes
1answer
534 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
0answers
235 views

pset3 find: Bus error (core dumped)

I finished the binary search algorithm and I get an error Bus error (core dumped) when I try to test it using the generate tool which is given. However, it works fine when I input the haystacks myself....
0
votes
1answer
806 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" bool search ...
0
votes
0answers
83 views

Detecting if ball is moving up or down

How can I detect if the ball in the breakout.c problem (pset3) is moving up or down? In other words how do I detect changes in Y parameter of velocity? Are there any functions for this purpose in the ...
0
votes
0answers
160 views

Error in breakout's ball bouncing off the edges

I am doing the pset3 breakout. while implementing the ball bounces off the edges, I did it successfully it is bouncing off whenever it touches the edges but it is giving me error ack after closing the ...
0
votes
2answers
256 views

How do i pass an array into a function?

I have tried passing arrays into functions but I keep getting an error about pointers. So is it possible to pass an array I initialised in my main function to another function I created without using ...
0
votes
0answers
66 views

Couldn't exec spl.jar

This is the problem i cant execute the spl.jar file i already tried installing java jdk but it yet didn't work.
0
votes
0answers
56 views

Can I remove the staff's comments from fifteen before submitting?

I've implemented init, draw, move, and won for Game of Fifteen. What part of the notes at the beginning of the file can I take out without messing up my code?
0
votes
0answers
74 views

Illegal Move when using 4x4 txt

I'm not sure what's going on, but when I try to run the 4x4.txt file on my Game of Fifteen, I get illegal move errors starting when it tries to move 6, but if I replicate the moves by hand, I don't ...
0
votes
0answers
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: ...
0
votes
0answers
135 views

I can't get search to work when value == value[n]

I'm trying to implement a recursive binary search in helpers.c. When checking my code with check50, everything works except: :( finds 42 in {40,41,42} :( finds 42 in {39,40,41,42} So obviously ...
0
votes
2answers
422 views

pset3, move function

Here's my move function. The problem here is i know im not following the instructions. Because i don't understand why do i need to track and how to track the blank tile. My function works as expected. ...
0
votes
1answer
190 views

Trouble with binary search

Using gdb, I found the problem is when the left_values is not there because if I try print left_values right after declaring it, it tells me No symbol "left_values" in current context. after ...
0
votes
1answer
98 views

Values for tile locations are 0 in gdb

I'm not getting whats going wrong with my move and draw functions. When I trace the program through gdb I'm getting the 0 values for tile locations.
0
votes
0answers
1k views

What does clang's “undefined reference” error mean?

What do the following compilation errors mean and how can I fix them? jharvard@appliance (~/Dropbox/pset3/find): make helpers clang -ggdb3 -O0 -std=c99 -Wall -Werror helpers.c -lcs50 -lm -o ...
0
votes
0answers
162 views

Move won't swap tiles

Both init and draw run perfectly fine, but no matter what I try with move, any number I give the program returns "Illegal move" My code was (i thought) running through each row and column until it ...
0
votes
1answer
217 views

Why won't my nested for-loops compile?

I'm trying to use nested for loops in the "init" part of Game of Fifteen and can't figure out why my code won't compile. Here's the code: for (i = 0; i < d; i++) { for (j = 0; j < d; j++) ...
0
votes
2answers
362 views

Binary search algorithm only works for smaller arrays

I can't figure out what I'm doing wrong. My algorithm works for smaller arrays, but once the number of values increases, the program stops and I have to hit Ctrl + C. I thought maybe it was an issue ...
0
votes
0answers
77 views

Header files in helpers pset3

What is the rationale for the header files in helpers.c? For example there is cs50.h but not stdio.h even though the functions are all stdio except for bool which is in neither CS50 nor helpers. And ...
0
votes
0answers
123 views

segmentation fault in pset 3

i have written init and draw function in init i have made 2 nested loops and given value to each element starting from position (0,0) = d*d-1 till the last element and i have printed the given ...
0
votes
1answer
732 views

Binary search question

I'm currently struggling with the binary search in pset 3 and I think I already found out how to implement it. I just really can't understand why, after return res;, the program does not leave the ...
0
votes
0answers
114 views

what's wrong with my linear search?

I don't get this. I did a whole lot of debugging with gdb, and somehow move returns false automatically just after this simple search for the tile. int p=0,q=0; for(i=0;i<d ;i++) { for(j=0;j<...
0
votes
0answers
302 views

Swap function in helpers.c file

I have successfully completed the linear search and sort functions in the helpers.c file for problem set 3. I included the swapping steps within the sort function directly and everything worked ...
0
votes
1answer
276 views

(pset3: fifteen) my code work on 4x4.txt but not on 3x3.txt?

I am getting correct output for 4x4.txt but not for 3x3.txt. I can't understand what went wrong. I have downloaded both the file as I am not using appliance. Can anyone check weather my 3x3.txt file ...
0
votes
2answers
71 views

Help with pset3 runoff

is this correct for vote function..struggled to figure out how to access candidate index so not sure if this is correct..any help/advice would be greatly appreciated bool vote(int voter, int rank, ...
0
votes
1answer
230 views

Recover cs50 Please help!

Can somebody please help with this question? ... and also I tried to debug and apparently it doesn't run my while loop and i don't understand why. while (fread(buffer, 512, 1, fraw) == 1) so ...
0
votes
1answer
39 views

Pset3 Resize - image has more bytes than expected

I have a problem with this pset3-resize-less. Everything works fine but when I run check50, only first three things are correct: :) resize.c and bmp.h exist. :) resize.c compiles. :) doesn't resize ...
0
votes
1answer
43 views

Is my bubble sort alogrithm elegant?

Snippet: //c is swap counter , while j is for optimisation for( int c= -1, j = 0 ; c != 0 ; ) //loop till c==0 { c = 0; for(int i = 0 ; i < (6-j) ; i++) //7 ...
-1
votes
1answer
74 views

CS50 Pset3 Tideman

please let me know what’s wrong with my work. Thank you!
-1
votes
1answer
670 views

In pet3 , find.c

Can't understand where I went wrong.. FIND.C #include <cs50.h> #include <stdio.h> #include <stdlib.h> #include "helpers.h" // maximum amount of hay const int MAX = 65536; int ...

1
3 4 5
6
7