Questions tagged [pset3]

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

304 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
1answer
147 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
70 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
195 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
123 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
51 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
665 views

Tideman lock_pairs recursion problem

I'm currently working on Pset3 Tideman and am stuck on the recursion part of lock_pairs function. I tried implementing an additional function to check for a cycle, and obviously, it's not working. ...
1
vote
0answers
113 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
1answer
832 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
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 ...
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
161 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
228 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
560 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
540 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
69 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
3 views

Please help me by reviewing my logic for Tabulate in Runoff Pset3

Let's say 3 candidates were their initially and A and B got 2 votes each while C got 1 hence C should be eliminated then in the next round we need to see the second preference votes right? As the ...
0
votes
0answers
2 views

pset 3 Runoff Where is my code wrong?

I have written the functions but I am not sure which one is wrong as I am not getting any output Here is my code: // Record preference if vote is valid bool vote(int voter, int rank, string name) { ...
0
votes
0answers
8 views

Tabulate function in Runoff

Here is my code void tabulate(void) { for (int i = 0; i < candidate_count; i++) if (strcmp(candidates[preferences[i][0]].name, candidates[i].name) == 0) { ...
0
votes
1answer
7 views

Vote Function in Runoff

Here's my code bool vote(int voter, int rank, string name) { int j = 0; for (int i = 0; i < voter_count; i++) if (strcmp(name, candidates[i].name) == 0) { preferences[i][...
0
votes
0answers
16 views

PSET3 Tideman Sorting Check50 Error

What's the difference between these two codes? Why does the first return me no error from check50 while the second one does? void sort_pairs(void) { int max; for (int i = 0; i < pair_count; ...
0
votes
0answers
10 views

Is my vote function correct in Runoff?

I have started runoff and just completed step 1 that is to write the vote function can someone tell me if it's correct? It seems to give the correct output but I don't think I used int rank in the ...
0
votes
0answers
5 views

pset 3 runoff - problem with tabulate

I am a (very) beginner coder, so pls be gentle!! I have numerous mistakes in my code, but am unsure how to fix them. The code is working for some things, and I have scored 73 % on the problem set, but ...
0
votes
0answers
8 views

cs50 pset3 print winner function

Im strugling with print_winner function in Tideman election program. In my opinion function workes fine. It prints the candidate which has all false values in column under his name (number) in locked ...
0
votes
1answer
28 views

Tideman sort_pairs seems correct but check50 tells me it isn't

Here is the code for my pair sorting algorithm. void sort_pairs(void) { int sorted_pairs_added = 0; for (int i = voter_count; i > 0; i += -1) { for (int j = 0; j < pair_count;...
0
votes
0answers
17 views

help with pset3 tideman lock_pairs function

This function is a recursive function, that lock_pairs is using to understand if a pair will create a cycle: bool create_cycle(int win_idx, int orig_idx) { if (win_idx == orig_idx) // if it's not ...
0
votes
1answer
28 views

CS50 Runoff Tabulate

So I have been working on the tabulate function and Check50 says that the function is correct and it does properly work when no candidate is eliminated and when one is eliminated, but not when ...
0
votes
0answers
22 views

cs50 pset3 tideman lock pairs and print winner function are not working rest all are working

in lock pair (lock_pairs skips final pair if it creates cycle is working) rest all lock_pair and print winner is not working. #include <cs50.h> #include <stdio.h> #include <string.h> ...
0
votes
0answers
23 views

PSET3 Tideman: Help with lock_pairs function

how's it going? I'm now working on Tideman but I'm now having a hard time why my code does not satisfy all the condition, only the first one: :) lock_pairs locks all pairs when no cycles These two ...
0
votes
0answers
30 views

I'm STUCK for a good while in pset3 Tideman last 3 functions :(

I'm mostly concerned about the sort_pairs() function atm, but i'm willing to receive answers regarding the whole code. I can't really see what's wrong with the way i coded it in general, but mostly ...
0
votes
0answers
11 views

My program does **NOT** skip the last pair if it creates cycle. #PSET3 #Tideman

my program has apparently one bug. check50 says my program does NOT skip the last pair if it creates cycle. However, I ran my function through debug and it did skip the last pair and did not write ...
0
votes
0answers
24 views

tideman sort pairs not working

dont know why my function isn't working, i suspect the while loop triggers even when it shouldn't. void sort_pairs(void) { // TODO supair supairs[pair_count]; supair unSorted[pair_count]; ...
0
votes
0answers
28 views

Plurality works with my examples, but not with check50

I have finished my plurality program and its fine with the examples I give it, but it fails to print any of the winners of the Check50 examples. Any idea of how can I reproduce that elections, to see ...
0
votes
0answers
33 views

CS50 tideman Lockpairs function (Doesn't skip the last pair?)

So in order to solve lockpairs function, I made a custom function that can detect a cycle (it would return true if it has a cycle, false if it doesn't). My custom functions logic is: Check each pair ...
0
votes
0answers
34 views

Could someone explain why this function for pset3/tideman isn't correct

So as seems to be the case with many people, I'm struggling a bit with tideman. My code scores full marks up until the point where the pairs become "locked." The code for my lock_pairs ...
0
votes
0answers
17 views

Tideman: linking pairs to candidates

and thanks for helping. I am confused with Tideman, and would love some enlightenment: I successfully sorted pairs, and can't figure out, in order to fill the bool locked, how to link the candidates ...
0
votes
0answers
44 views

lock_pairs skips final pair if it creates cycle

I have been working on the tideman problem from Problem Set 3. After multiple attempts, I have been able to pass all the required checks except one: "lock_pairs skips final pair if it creates ...
0
votes
1answer
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 :( ...
0
votes
0answers
34 views

Problem Set 3 - Tideman Lock Pairs

I am trying to solve the tideman problem for pset3. I have managed to get all parts of my code working apart from the the two parts which relate to checking whether cycles are created. :( lock_pairs ...
0
votes
0answers
27 views

Error in recursive cycle check function for pset3 tideman

I've implemented a recursive function to check for cycles and return a boolean based on if a cycle is found or not. Check50 only returns one error, and that is for "lock_pairs skips final pair if ...
0
votes
0answers
30 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 ...

1
2 3 4 5
7