# Questions tagged [pset3]

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

1,268 questions
Filter by
Sorted by
Tagged with
46 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) { ...
41 views

### Pset 3 -> Counting Sort - need tips to find my error

What is wrong in my code? Why am I getting a segmentation fault? void sort(int values[], int n) { int aux_list[65536] = {0}; //map the count of values in the values list as the index of the aux list ...
33 views

### pset3: linear search (strange behaviour)

My code is going through check50 okay, but when I try to check it manually it doesn't seem to be able to find the needle in the haystack. I can't figure out why that is happening that's why I'm hoping ...
28 views

### Error with fifteen?

I am taking the Harvard ap cs5o class, and I just started the pset3's fifteen. I followed the directions to get the skeleton code from here: Problem scope After reading and following along I tried ...
33 views

### pset3/fifteen/issue with board

I have an issue making my board in fifteen, i think im doing well but it shows something i can't explain. Can anyone help me? why my board numbers shudenly do this weird thing: My code: void init(...
35 views

### why is binary search return false for everything

Here I have implemented the binary search in 2 ways, the iterative way, and the recursive way, but I get the same error for both ways, I also have implemented a insertion sort which works. but I am ...
38 views

I really don't know what I am doing wrong. I think I've mad a mistake in frequency. Check50 says: :( note C3 has frequency 131 expected "131", not "220" :( note Bb5 has frequency 932 ...
62 views

### cs50 pset3 runoff tabulate - why you say candidates[i].votes = 0 ; here?

why use that ?? for (int i = 0; i < candidate_count; i++) { candidates[i].votes = 0; } } return 0;
41 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 ...
30 views

When I try to upload pset3.zip, as the pset states I should do, on uploading, the source code thats shows includes everything except the code which i wrote myself, even tho it was saved and compiled ...
52 views

### My runoff problem doesn't pass check50

when I run check50 this is the message I get and I don't know what to fix :( tabulate counts votes when all candidates remain in election tabulate function did not produce correct vote totals :( ...
33 views

### Defining array[i] as a macro

I'm getting the following error: helpers.c:25:12: error: called object type 'int *' is not a function or function pointer if (MIN < MAX) ^~~ helpers.c:20:24: note: ...
25 views

Hi can someone help me out the code "./generate 1000 50 | ./find 127" doesn't find the haystack. And I even removed the "./find 127" and went through the generated numbers but still didn't see the ...
104 views

### Help finding segmentation fault

In my code, I get a segmentation fault some, but not all of the times that I run it. Sometimes, it sorts the code and finds the needle, sometimes it doesn't sort correctly and ends with a segmentation ...
30 views

### How to swap elements in “struct” data type?

I am working on "tideman" from pset3 and stuck on sorting the data that i have in "struct" data type. Don't really know if it was supposed to be figured out on our own, but they ...
34 views

### Resize less fails when trying to resize small.bmp when n is not multiple of 4 or is 1(probably padding issue)

int oldHeight = bi.biHeight; int oldWidth = bi.biWidth; bi.biWidth *= n; bi.biHeight *= n; int padding = (4 - (bi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; bi.biSizeImage = ((sizeof(RGBTRIPLE) * bi....
21 views

### Attempting to call getType on an object with unexpected type

error: Attempting to call getType on an object with unexpected type after calling the function updateScoreboard(window, label, points); in code for pset3.
28 views

### Can't figure out what's wrong with my linear search code

// add grave accents before and after code // to show it nicely in your question. bool search(int value, int values[], int n) { if(n<0) { return false; } // TODO: implement ...
32 views

### pset3 'fifteen' - init function only works for small grids

My init() code works beautifully for grids of 3, 4, or 5, but chokes with larger grid of 6, 7, 8, and 9. It looks almost like an integer overflow or floating point imprecision problem, but I can't see ...
48 views

### CS50 recover - images are some kind of blank

//My program creates images of different sizes but without content (just black and white pixels). Someone can help me? #include <cs50.h> #include <stdio.h> #include <stdlib.h> #...
29 views

### Fifteen.c/PSTE3 MOVE FUNCTION NOT SHOWING EXPECTED OUTPUT

Though my program fifteen.c/pset3 compiles with the int,draw,move function but the tiles are not moving at all. Here's my code as well the output.Kindly check and any suggestions will be appreciated. ...
29 views

### Everything's working in manual testing, but cs50 says 4x4 not working (pset3 fifteen)

Source code for init: void init(void) { int k=(d*d)-1; for(int row=0; row<d; row++){ for(int col=0; col<d; col++){ board[row][col]=k; if((d%2==0)&&(k==3)){ ...
51 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 ...
51 views

### PSET 3 still stuck

I'm still so very stuck on this one. Below I have a cobbled together "solution" that at least increases the size of the image. I have no clue what I'm doing when it comes to copying the value of ...
28 views

### In find, I print the array before sorting it, The last number it prints out is always consistent but unrelated to the problem

It continuously prints 2147483647 as the last number of the haystack, even when I use a different seed or no seed at all. Does anyone know why?
49 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; ...
38 views

### Sort Function not changing haystack

The array gets sorted inside the sort function but the haystack doesn't change. How do I pass haystack by reference without changing the function prototype? void sort(int values[], int n) { int ...
130 views

### How does one print out all existing integers in an int array?

The code below generates the following error: format specifies type 'int' but the argument has type 'int *' [-Werror,-Wformat] printf("%i", array); include include int main(void) { int ...
41 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 ...
28 views

### Binary search recursing issue

I've been working on a binary search of pset3 find, and I'm having an issue when I call the function again recursively. I believe that I know what the issue is, I'm just not sure how to fix it. When I ...
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] <...
63 views

### linker comman failed with exit code of 1 in find.c

I was about to submit pset3 and pset4 which I have completed, but in the process of keeping my house in order by checking every code before submission, I discovered that helpers.c has developed issues....
413 views

### Plurality is being failed by check50 when it works in my terminal (PSET3)

Plurality Check50: https://submit.cs50.io/check50/dfe0d69252268f63eddb40057eada6979586a661 However, code works when I run it in my terminal: https://imgur.com/a/xEp0EnH Code: void print_winner(void)...
133 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: /** ...
41 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 ...
57 views

### pset3(count sort):can't sort using count sort,it doesn't sort at all or not returning the sorted array??plz help

/** * helpers.c * * Helper functions for Problem Set 3. */ #include <cs50.h> #include "helpers.h" #define bound 200 /** * Returns true if value is in array of n values, else false. */ ...
27 views

### PSet3 Resize (Less) = Random Colors when not 1:1

I saw others posted about the same phenomena I am experiencing, but none of their solutions were what I needed. n = 1 works perfectly. This is large.bmp with an n = 2. I realize the first line of my ...
48 views

### Check 50 for find

I have gotten most of my code to work for the search and sort, but I still have a few issues. One is i my for loop, I have it set to less than 100, though I need to make it less than log n, but I ...
66 views

### Comparison Between Words

In this, I keep getting the error of comparison between pointer and integer?? My Code: (The List Of Errors Is At The Bottom) /** * scramble.c * * CS50 AP * Scramble * * Implements Scramble in ...
43 views

### pset3 - game of fifteen, problem with 0

I am only getting problems while I am choosing a zero as an extra tile. Every other value works fine, it passes the piped games as well:) Unfortunately can not understand where is the flaw:( I am ...
42 views

### Is this a correct way of implementing bubble sort?

I made a bubble sort code, but I want to make sure that my code is correct. My code is void sort(int values[], int n) { if (n == 1) { return 0; } int swapcount = 0; ...
44 views

### pset3 find code works, despite 'sort' failing

I'm very confused! I have spent many (MANY) hours working through this pset. I've gotten to the point where my code passes all check50 requirements for 'find', but it's failing the 'sort' ...
34 views

### pset 3 - killed by server problem

I understand my problem is with infinite loops but I would like some guidance on solving it. I am not sure if I should use a for - as I tried doing on comments - or if there is a better/more efficient ...
26 views

### In CS50 pset3 resize (less), the bfSize and biSizeImage are different than the correct values. Why?

outbf = bf; outbi = bi; outbi.biWidth = n*bi.biWidth; outbi.biHeight =n* bi.biHeight; // determine padding for scanlines int padding = (4 - (outbi.biWidth * sizeof(RGBTRIPLE)) % 4) % 4; int ...
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 ...
293 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 ...
57 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/...
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.
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"...