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
1 vote
1 answer
389 views

pset3, tideman, cs50 2021

I worked with pset3 and I think there are nothing wrong with my code, but check 50 says it has 2 problems on my code. 1.:( lock_pairs skips final pair if it creates cycle 2.:( lock_pairs skips middle ...
Keiyeung Law's user avatar
1 vote
1 answer
271 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 ...
Ian Samir Yep Manzano's user avatar
1 vote
0 answers
403 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 ...
timmy a's user avatar
  • 11
1 vote
4 answers
212 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 ...
Alex Shevchenko's user avatar
1 vote
0 answers
72 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? ...
Nate's user avatar
  • 13
1 vote
0 answers
1k 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. ...
roman465's user avatar
  • 113
1 vote
2 answers
47 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....
Afonso's user avatar
  • 11
1 vote
0 answers
27 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 ...
S. Sabry's user avatar
1 vote
1 answer
47 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 ...
Bijan Khadembashi's user avatar
1 vote
1 answer
36 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 ...
qwerty's user avatar
  • 64
1 vote
2 answers
53 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; ...
Ahmed Raza's user avatar
1 vote
1 answer
3k views

pset3: selection sort and binary search

I've been trying to implement those two function whole day and something seems to not be working because the printf function I wrote in find.c outputs 9,8,7,6,5,6,7,8,9 when I input the numbers from 9 ...
Petar Petrov's user avatar
1 vote
0 answers
115 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 ...
Alejandro Aristizábal's user avatar
1 vote
0 answers
126 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 ...
user avatar
1 vote
1 answer
180 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, ...
Furrukh Jamal's user avatar
1 vote
1 answer
233 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/...
Mustaghees's user avatar
1 vote
1 answer
1k 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 ...
Talita Maria Briganti Barbosa's user avatar
1 vote
1 answer
161 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-...
LDF's user avatar
  • 47
1 vote
1 answer
119 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 ...
MKrlt's user avatar
  • 13
1 vote
0 answers
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-...
RLBYC's user avatar
  • 13
1 vote
2 answers
560 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.
Ibrahim Alawwad's user avatar
1 vote
1 answer
348 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 annoying and I ...
Toto De Brant's user avatar
1 vote
4 answers
466 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 ...
Jason Keane's user avatar
1 vote
2 answers
86 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 ...
Bryan99's user avatar
  • 41
0 votes
2 answers
26 views

The code allways prompt to enter a new date when entering the date. How to correct my code in order to have the right answer?

import re months = [ "January", "February", "March", "April", "May", "June", "July", "August&...
Horace's user avatar
  • 1
0 votes
1 answer
143 views

CS50 Meteorites Cleaning

Quick Question for yall, so I set .nullvalue to "NULL" before writing my table updates. Second question, how do I rearrange columns in my final meteorites table that was it passes the CS50 ...
adubzzzz's user avatar
0 votes
0 answers
21 views

Pset3 tideman error at lock_pairs

void lock_pairs(void) { int cycle = 0; int winner; for(int i = 0; i < pair_count;i++) { locked[pairs[i].winner][pairs[i].loser] = true; if (pairs[i].loser == pairs[i+...
Ahmed Yehya's user avatar
0 votes
0 answers
32 views

Tideman PSET03 - lock_pairs ERROR

I'm currently doing the Tideman PSET03 and I've completed almost everything except ``. Could you tell me why this is happening? It'd appreciated. Check50: https://submit.cs50.io/check50/...
AlvaroAndLukeTheCoder's user avatar
0 votes
0 answers
20 views

How to use .txt file with debug50 - pset3 tideman

Does anyone know if there is a way to store a bunch of data, e.g. number of voters and votes for the Tideman problem, as a .txt file, and then run that with debug50, so that I don't have to manually ...
Joseph J Filoramo's user avatar
0 votes
0 answers
15 views

Tideman - First Error of lock_pairs function is not working

I'm currently doing the lock_pairs function of tideman. I have completed most of the requirements of check50 in the lock_pairs function except :( lock_pairs locks all pairs when no cycles. I don't ...
AlvaroAndLukeTheCoder's user avatar
0 votes
0 answers
24 views

Tideman PSET03 - Add_Pairs errors!

I'm currently doing the tideman pset and i have some errors on the add_pairs function and the lock_pais function but I'm more focused now on the add_pairs function. I don't know why these errors are ...
AlvaroAndLukeTheCoder's user avatar
0 votes
0 answers
26 views

Tideman PSET03 - Please Help Me!

I've been doing Tideman and I've completed every function required. But when I run Check50, it gives me some errors: add_pairs function did not produce 2 pairs , lock_pairs did not lock all pairs, ...
AlvaroAndLukeTheCoder's user avatar
0 votes
0 answers
20 views

Problem of pset3 plurality

This code can run, but the outcome isn't right.I checked many times, but I still can't figure it out.I wish someone can help me. Here is the function "print_winner" of my code:(I guess the ...
Lea's user avatar
  • 1
0 votes
0 answers
33 views

Tideman - sample votes

I am very close to solving the lock_pairs function in tideman. Everything passed, except that check50 is saying that :( lock_pairs locks all pairs when no cycles isn't working correctly. But it does ...
Joseph J Filoramo's user avatar
0 votes
0 answers
100 views

I don't understand the answer to the pset3 atoi practice problem

#include <cs50.h> #include <ctype.h> #include <math.h> #include <stdio.h> #include <string.h> int convert(string input); int number = 0; int main(void) { string ...
Harr's user avatar
  • 35
0 votes
0 answers
9 views

Sorting an array based on ints within a strut

I'm looking for a way to implement merge sort to sort the pairs[] array in the tideman problem. The problem being the array is made up of the strut pair, not ints. However, I have added an element to ...
Gavin Colonese's user avatar
0 votes
0 answers
12 views

What is the difference between these 2 'check_cycle' functions?

This is in regard to the 'lock_pairs()' function that calls on a recursive function 'check_cycle(w, l)' function to check if a cycle will be created before locking a pair of winner (w) and loser (l). ...
str58290_03's user avatar
0 votes
0 answers
24 views

vs code non running well pset3 plurality, execution does weird things

Does anyone else think that vscode is garbage? I am able to run a program correctly in another environment but in vs code it never runs correctly
MARS's user avatar
  • 5,169
0 votes
0 answers
25 views

I don't know why my code doesn't work correctly, can you help me? PSet03 - Runoff

I,ve been completed all the functions that i'd need to complete in the Pset Runoff but I don't know why when I do the check50 it gave some errors and My code doesn't print out the winner as well. Here ...
AlvaroAndLukeTheCoder's user avatar
0 votes
0 answers
18 views

Pset3 Tideman add_pair error

the check command says my add_pairs funtions doesnt count or produces the corrects pair but when I run it works fine: debug50 testing with three candidates a, b, c; preferences are in the same order ...
wnccys's user avatar
  • 1
0 votes
0 answers
58 views

pset 3 tideman - vote function - rank int

I am having trouble figuring out how to set up the rank integer in the vote function of pset3. I could do this to ask the user to rank the candidate, but I assume that wouldn't work with the sample ...
Joseph J Filoramo's user avatar
0 votes
1 answer
13 views

calling the first element in struct

I have defined an array of pairs of elements using struct and I'm trying to call (and sort) it using one of the elements (I'm not sure if element is the right term for it) for example, I have typedef ...
blueberry's user avatar
0 votes
1 answer
49 views

Lock pairs function not locking for final pair, but works for middle pairs

I wrote the following code: void lock_pairs(void) { for (int i = 0; i < pair_count; i ++) { bool createsLoop = false; for (int j = 0; j < pair_count; j ++) { ...
Sarmen Ter-oganesyan's user avatar
0 votes
1 answer
191 views

Help with Pset3 Runoff check50

After a while i got runoff working but when i ran it through check50 there seem to be some errors but i just can't figure out what they are :) runoff.c exists :) runoff compiles :) vote returns true ...
Schmilp's user avatar
0 votes
0 answers
60 views

Help with print_winner in Pset3 Runoff

I'm almost finished with Runoff and have solved all of the other functions except for print_winner. I can't help but think I'm missing something simple here. Can anyone see where I am going wrong? // ...
getsendy's user avatar
0 votes
1 answer
24 views

PSet3 Plurality - Segmentation Fault when exiting main

My code seems to function properly until I try to exit main. At this point it reports a segmentation fault. This only occurs when there is a tie. Here is my code: #include <stdio.h> #include <...
Thomas Gallaher's user avatar
0 votes
0 answers
25 views

Any idea why I keep getting is_tie errors for this pset3 using check50?

I'm trying to figure out why I keep getting these two errors. I've created a new array called placeHolder to gather remaining candidates I have also created int newCandidateCount[1] to globally store ...
Akersar's user avatar
0 votes
1 answer
92 views

Stuck on 'runoff'in pset3

I have been working on the runoff assignment from week 3. I am having issues with two of my functions: tabulate() and print_winner(). I have implemented them in the following ways: Here my ...
mz1user's user avatar
0 votes
0 answers
146 views

How to sort an array of strengt by victory using bubble sort (pset3: Tideman)

I wrote this code... void bubbleSort(void) { // loop to access each array element for (int step = 0; step < pair_count - 1; ++step) { // loop to compare array elements for (int i = 0; i < ...
Nemanja Vuksanovic's user avatar
0 votes
0 answers
266 views

Help on Plurality Pset3

I'm trying to solve assignment "Plurality" of Problem set 3. However, check50 didn't prove to be quite useful for me this time. I'm having only one error message saying "print_winner&...
Zoltán Uhlár's user avatar

1
2 3 4 5
7