Questions tagged [pset3]

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

286 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
143 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: ...
1
vote
1answer
19 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 ...
1
vote
0answers
139 views

Pset3 Tideman: lock_pairs skips middle pair if it creates a cycle

I'm having issues figuring out how to solve this problem without using recursion (I'm not sure how to solve things recursively). Its a program that determines the winner of a Tideman election and I'm ...
1
vote
5answers
97 views

check50 errors - runoff

I've been trying to resolve these myself for too long - I'm officially stuck These are the check50 errors I get: :( tabulate counts votes when multiple candidates are eliminated :( find_min ignores ...
1
vote
0answers
47 views

PSET3 - if(!vote(i, j, name)) {return 4}

I have a question regarding the reasoning behind If at any point, the ballot is deemed to be invalid, the program exits. from pset3. Why is this functionality included in runoff but not in plurality? ...
1
vote
0answers
93 views

Pset 3 Plurality - Error: linker command failed with exit code 1 (use -v to see invocation)

I have come across an unusual situation and I was not able to find a solution on this elsewhere. So for some reason, I was having issue compiling my plurality assignment and it kept on giving me the ...
1
vote
0answers
667 views

pset3 (runoff) keep getting print_winner error when using check50

I keep getting these errors when running check50 on my runoff program: print_winner prints name when someone has a majority print_winner did not print winner of election print_winner returns ...
1
vote
2answers
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....
1
vote
0answers
23 views

What's wrong with saving the scanline array elements in my code for resize (less), Pset3 problem?

I've solved the problem by recopy method successfully and thanks to many helpful answers to others' questions. Now I'm trying to solve be rewrite method and I think I have a problem with storing ...
1
vote
1answer
40 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 ...
1
vote
1answer
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 ...
1
vote
2answers
50 views

My code is swapping “1”, “2” even if i have written code only for swapping “if even.”

This is my init function, please check and suggest: void init(void) { int size= d*d; for (int i=0;i<d;i++) { for (int j=0;j<d;j++) { board[i][j]=size-1; ...
1
vote
0answers
113 views

Fifteen.c -> expected file to be of length X “cheap solution”?

I've been having some trouble with the fifteen game code. Even though it works as expected, when I do check50, I get a bunch of errors related to the expected size of the log file. After looking at ...
1
vote
0answers
123 views

Pset3 find grade 0

My Pset3 has been graded and I received a 0.6 score. I got a full 1.0 for fifteen, but 0 for find. I think I have submitted the files correctly - I can see all the files in the files folder, and ...
1
vote
1answer
159 views

Paddle is lagging and how to use drand48?

Well when I coded for the creation of paddle and the movement of the paddle in initpaddle(), it was moving fine but now after step 6 of the problem set. With the ball too moving the paddle is lagging, ...
1
vote
1answer
227 views

expected output not standard error

In pset3's find. I have implemented Binary search. Everything works fine when I test it. But when I test it with check50, the last test fails saying: \ expected output, not standard error of "/opt/...
1
vote
1answer
526 views

How to use swap?

I am currently in pset3, implementing sort. I chose to do selection sort and at the end of it I need to swap the numbers, but when I try to compile, I get this message: implicit declaration of ...
1
vote
1answer
152 views

Breakout (with no changes) won't compile

I always get the following messsage when I try to compile breakout in PSET3. jharvard@appliance (~/Dropbox/CS50/pset3/pset3/breakout): make breakout clang -ggdb3 -O0 -std=c99 -Wall -Werror -Wno-...
1
vote
1answer
113 views

Why does setLabel() freeze the program randomly?

I have a decent implementation of the Breakout program that normally runs perfectly all the way through. I have noticed, however, that occasionally the program will freeze. After a joint effort of ...
1
vote
0answers
153 views

week4 some compiling error

jharvard@appliance (~/Dropbox/pset3): make ./bounce clang -ggdb3 -O0 -std=c99 -Wall -Werror bounce.c -lcs50 -l`enter preformatted text here`m -o bounce /usr/bin/ld: /usr/lib/debug/usr/lib/i386-...
1
vote
2answers
539 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.
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 ...
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
2answers
68 views

what does “Unexpected error: decodeError: Illegal color value” mean?

I just finished the code for breakout.c and I received no errors when I typed in "make breakout". However when I typed in ./breakout I received a whole lot of errors saying that there was an ...
0
votes
0answers
6 views

PSET 3 TIDEMAN Locked pairs Function

I am relatively new to the community so please forgive me should my question not be coherent enough. Ok so basically check 50 tells me that everything in my code is okay except for the locked pairs ...
0
votes
0answers
10 views

lock_pairs skips final pair if it creates cycle lock_pairs did not correctly lock all non-cyclical pairs

can anyone please help I got only one error which is:- lock_pairs skips final pair if it creates cycle lock_pairs did not correctly lock all non-cyclical pairs and this is my code bool hash_cycle(int ...
0
votes
0answers
14 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
0answers
18 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
3answers
22 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
49 views

My print_winner from pset3/tideman is doing everything right and still check50 says it's wrong

void print_winner(void) { bool looser; for (int i = 0; i < pair_count; i++) { looser = false; for (int j = 0; j < pair_count; j++) //checks if each winner ever lost ...
0
votes
1answer
37 views

Pset3 runoff tabulation error

[![enter image description here][1]][1] I keep getting a tabulation error with check50 that I cannot replicate 11 voters, 4 candidates, 3 or 4 rounds of voting works fine with I run it, and debug50 ...
0
votes
1answer
36 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
0answers
30 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
0answers
25 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
2answers
28 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
2answers
41 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 ...
0
votes
2answers
94 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
0answers
36 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
200 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
1answer
49 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
0answers
75 views

pset3 tideman; can't pass check50 “lock_pairs skips final pair if it creates cycle”

I'm kind of confused about what the last pairs should be if it creates cycle. Like, if a->b, b->c, and the last pair is c->a, should I just skip it or turn it around, make it a->c? I tried both idea, ...
0
votes
1answer
16 views

what does different return value signifies in this problem of runoff?

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

Back again with runoff problems, tabulate() passes no check50 tests

(I can't get formatting to work properly here so it might look a bit weird) void tabulate(void) { int j = 0; for(int i = 0; i < candidate_count; i++) { for( ; j < voter_count;) { ...
0
votes
2answers
65 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 (...
0
votes
0answers
37 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
52 views

pset3 tideman ranks array

In the tideman distribution code and the logic itself, the ranks[] array in the vote function is never actually sent outside the vote function. The array that's going to be passed into the ...
0
votes
1answer
97 views

PSET3 Runoff - tabulate() function for multiple eliminated candidates

I'm working on the tabulate() function, and to an extent the is_tie() function The tabulate() function passes all the tests of check50 but the last one: :( tabulate counts votes when multiple ...
0
votes
0answers
64 views

:( print_winner identifies Alice as winner of election. print_winner function did not print winner of election

What kind of test I should do to know What is the problem in my code because it's the only issue I have every other condition is working good.
0
votes
0answers
34 views

PSET3: More problems(weird loops and other unexpected results)

So I am still working on Runoff and I am having some weird results. It will return an obvious victory but any ties end up in weird loops and such. This has been apparent by adding printf functions ...
0
votes
1answer
40 views

Runoff pset 3, arrrays and indexing

I don't understand what's going on with the solutions to the voter preference and tabulate functions. I had set up a similar function to the answer with the exception that I had [voter][i] = rank; ...

1
2 3 4 5 6