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
54 views

Pset 3 Plurality Help (still not working)

When I compile my code it works, but when I try to run it, it says segmentation fault. I believe the segmentation fault is on the line that says printf("Winner is %s with %i votes\n", winner,...
0
votes
1answer
110 views

Receiving an expected expression error on pset3 (curly braces match)

Tad bit confused as to why I'm receiving an expected expression error. I've looked at other questions for help on this, but the solution seems to be the curly braces. I've actually done this, and I'm ...
0
votes
2answers
373 views

pset 3 - finding the needle problems!

I need some guidance. I had a problem with infinite loops (which I think I've corrected) and some problems on my sort algo as a user here pointed out (I think I've corrected the sort problem too). Now,...
0
votes
1answer
102 views

game of fiteen shows errors in check50

guys my game of fifteen is showing errors in check50 please help here's my pastebin link http://pastebin.com/TgA030A5 check50 2015.fall.pset3.fifteen fifteen.c :) fifteen.c exists :) fifteen.c ...
0
votes
1answer
794 views

pset3 helpers.c linear search confusion

bool search(int value, int values[], int n) // TODO: implement a searching algorithm if (n >= 0) { for (int i = 0; i < n; i++) { if (values[i] == value) ...
0
votes
1answer
560 views

Pset3 Music frequency returns all 440

My frequency function returns all 440. Been researching and trying possible solutions (turn ints to floats, round, power, etc) but still does it. What am I doing wrong? Thank you! int frequency(...
0
votes
1answer
137 views

Ball won't bounce off sides

I've written some code to make the ball bounce off the edges and move diagonally. But the ball just disappears off the edge of the window! I've read elsewhere that I have to initialise the velocity ...
0
votes
1answer
33 views

PSET 3: Color is messed up

I can't figure out how to fix the colors of large.bmp when I run it. It resizes correctly but the pixels are all messed up and don't look like the original. Someone help me? Please and thank you! // ...
0
votes
1answer
216 views

My music program: frequency returning zeros

// Calculates frequency (in Hz) of a note int frequency(string note) { int n,r,a; double oct, z; float x = 0.0; float y = 0.0; char t; t=0; a = 0;r = 0; n = strlen (note)...
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
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
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
2answers
35 views

PSET3 Plurality trouble. All of the checks on check50 work except 1!

I am having trouble figuring out what is wrong with my code. The only failure in check50 is (:( print_winner identifies Charlie as winner of election Cause print_winner function did not print winner ...
0
votes
0answers
25 views

Lock pairs and Recursivity

I've been trying to solve this pset since more than a month and don't want to give up... so this is the first time I'm coming to ask for help. Basically I separated in two parts the lock_pairs ...
0
votes
1answer
443 views

Sort Race - check_flag function?

the problem set i'm having issues with can be found here: http://docs.cs50.net/2016/x/ap/problems/race/race.html i'm struggling to implement the check_flag function which is a simple check that ...
0
votes
1answer
127 views

Segmentation fault on pset3 (find : more comfortable)

My program got a problem when I used this command './generate 1000 50 | ./find 127' which generating random number to run it. It shows "Segmentation fault", but it works fine when I type the input ...
0
votes
0answers
87 views

Can't get pset3/tideman's lock-pairs function to work

Before going to Python I thought I'd go back to some previous homework that I hadn't been able to solve - pset3/tideman. I've spent ages on this but I just can't seem to figure out the lock function. ...
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
1answer
229 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
3answers
135 views

pset3 plurality check50 invalid vote

So I have a few questions on Plurality check50 errors for this Pset: My Code is as follows: #include <cs50.h> #include <stdio.h> #include <string.h> #include <math.h> // Max ...
0
votes
1answer
1k views

Pset3: Tideman - sort_pairs error!

I have difficulty to understand what should the output of the function sort_pairs() should be!, What I understand is I should take the unsorted pairs[] and sort it. For example, this is pairs[] ...
0
votes
1answer
166 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 ...
0
votes
1answer
38 views

incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *

bool vote(int voter, int rank, string name) { // TODO for(voter=0;voter<=voter_count;voter++) { for(rank=0;!strcmp(name, candidates[rank].name == 0);rank++) { preferences[voter][...
0
votes
1answer
95 views

pset3 Tideman: checking for cycles

I made it so that if a losing candidate in any pair wins in another, a function checks whether there's the losing candidate in that pair wins in any other, and so forth. this here is the unlocks the ...
0
votes
0answers
496 views

PSET3 -Tideman - lock_pairs

I'm doing tideman and I can't understand where is the problem: my code seems to be working but the test says that it does not. I will share a bit of my code: int count = 1 void lock_pairs(void) { ...
0
votes
0answers
43 views

PSET 3 CS50x: Need help with print_winner

here's my print_winner code. Could someone help me see what's wrong? Thanks so much. void print_winner(void) { //dummy number. just so loser != 0 for later on. int loser = 90000; for (int ...
0
votes
0answers
50 views

Pset 3 runoff : I am getting{ :( runoff compiles code failed to compile}

I wrote my code but when I came to test it it gives me code failed to compile. I don't know why? :| here is my code #include <cs50.h> #include <stdio.h> #include <string.h> // Max ...
0
votes
1answer
91 views

CS50 Recover.c | No idea what and where i'm going wrong | Can't debug or compile in CS50 IDE

I'm trying to debug in CS50 IDE but I'm continuously receiving this error; debug50: recover: No such file. and if I try to compile it says this "make: *** No rule to make target 'recover'. Stop." ...
1
vote
1answer
32 views

pset 3 runoff help again

I still dont know what to put in for loop :( I still dont know what to put in the for loop for(int k = 0; k < voter_count; k++) { for (int j = 0; j < candidate_count; j++) { ...
1
vote
3answers
38 views

PSET3 Runoff Help Please

for(m = 0; m < voter_count; m++) { for(t = 1; t < 4; t++) { string name = get_string("Rank %i: ", t); } printf("\n"); } } bool vote(int voter, int rank, string name) { ...
0
votes
2answers
155 views

PSET3 Plurality Problem

void print_winner(void) { // TODO int c = 1; int numwin = 1; candidate mv[MAX]; mv[0].votes = -1; for(int i = 0; i < candidate_count; i++) { if(candidates[i].votes >...
0
votes
1answer
87 views

Plurality Pset 3 I need Help

Whats wrong i keep getting segfault for(int o = 0; o < n - 1; o++) { if(candidates[o].votes > high0) { high0 = candidates[o].votes; name1 = candidates[o].name; } ...
1
vote
1answer
70 views

runoff tabulate error :( tabulate counts votes when multiple candidates are eliminated

void tabulate(void) { for (int i = 0; i < voter_count; i++) //as long as the number of total voters has not been met; this increases which voter we are on { int j = 0; ...
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
69 views

pset3 resize (less) compiles but doesn't write into new file for factor != 1

I've been stuck with the pset3 for a long time now and can't figure out why my code isn't working; it compiles fine but doesn't produce an image except for the factor 1. Could someone point me in the ...
0
votes
1answer
331 views

Please help about tideman lock_pair function!

// Lock pairs into the candidate graph in order, without creating cycles void lock_pairs(void) { for (int i = 0; i < pair_count; i++) { locked[pairs[i].winner][pairs[i].loser] = ...
0
votes
2answers
76 views

PSET3 Binary search not yielding results

I can't seem to figure this out. here's my code bool Binarysearch(int key, int array[], int n){ int end = n-1; int start = 0; while(start<=end){ int midpoint = (((end+start)/2)); if (...
1
vote
1answer
185 views

Logical flaw in Problem Set 3 - Tideman?

Whilst writing my code for Tideman in Problem Set 3, I had many problems with the lock pair function, as I am very new to coding. Some research I did online also showed that this question is ...
0
votes
1answer
405 views

pset3: code failed to compile

Now I am doing tideman and I already test and all are working well and get the expected result.but when I check with Check50,I got this msg :( tideman compiles code failed to compile I just ...
0
votes
1answer
151 views

Pset 3 runoff Randomly Increasing Votecount

I'm close to solving pset 3 runoff but I've run into this interesting problem in my tabulate function. Whenever I run the program with the debugger, my vote counts keep increasing by very large ...
1
vote
5answers
94 views

Trouble with tabulate and printwinner

I'm having a hard time with the runoff problem in pset3, especially with the tabulate function. Based on the instructions it looks like I need to update the preferences array but I'm not sure how. I'm ...
0
votes
0answers
36 views

pset 3: i dont understand why runoff is not being ececuted?

#include <cs50.h> #include <stdio.h> #include <string.h> // Max voters and candidates #define MAX_VOTERS 100 #define MAX_CANDIDATES 9 // preferences[i][j] is jth preference for voter ...
0
votes
1answer
47 views

Trouble with find_min

I'm trying to implement a bubble sort in the find_min function in pset3 runoff. But It looks like it is not returning the correct min. I think it is because candidates[0].votes may not be the lowest ...
0
votes
1answer
34 views

resize.c write to array

I think i made a breakthrough in this one with the rewrite method but i need to know how to write the triple to the array i tried a couple of things but didn't work out here's my code : int main(int ...
0
votes
0answers
38 views

Pset3 Plurality Help Again

This time I'm able to compile and run my code properly, but it tells me that there is a segmentation fault. Can someone help me figure out how to fix it? My code is below, thanks. #include <stdio.h&...
0
votes
1answer
112 views

Pset 3 Plurality Help

I was trying to compile my code for plurality but it says: plurality.c:82:1: error: control may reach end of non-void function [-Werror,-Wreturn-type] } ^ 1 error generated. <builtin>: recipe ...
0
votes
1answer
51 views

Pset 3 Min function need some help

So my min code works, except it ignores the eliminate function. Can someone please show me where my logic is wrong? Thanks. int find_min(void) { int min = voter_count; int h = 0; for (int i = 0; i ...
0
votes
1answer
26 views

PSET3 strcmp error

I hate to ask again because this should be incredibly simple, but I'm literally running strcmp(name, candidates[j].name) and it is telling me candidates[j].name is an int in the error and not a char ...
0
votes
1answer
229 views

pset3 (runoff) check50 is giving an error for print_winner

I can't find what's wrong with my code but check50 keeps telling me :( print_winner prints name when someone has a majority print_winner did not print winner of election :( print_winner returns ...
0
votes
2answers
91 views

Why am I running into a segmentation error in PSET 3 plurality?

I've been working on plurality for hours now and I'm stuck with a "segmentaion error." So my approach to this problem was to sort the candidate objects in terms of votes and print the first object (...

1
3 4
5
6 7
26