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
0 answers
11 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
-1 votes
1 answer
48 views

recursive atoi | CS50

Greeting everyone! I've written the code of pset3 recursive atoi, but I'm facing an issue with the formula that converts the integer to its place value. To be specific it's in this line (number = ...
XxGOLDENELIXIRxX's user avatar
0 votes
0 answers
19 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
1 answer
28 views

i need help with pset3 runoff. spend 12 hrs on tabulate. please guide me on the right direction

void tabulate(void) { for (int i = 0; i < voter_count; i++) { for (int j = 0; j < candidate_count; j++) { for (int k = 0; k < candidate_count; k++) { if (preferences[i][j] == k && ...
Trex Vanga's user avatar
0 votes
0 answers
13 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
9 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
13 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
1 answer
9 views

Is this a compiler issue maybe?

Ok, so It doesn't look like I have missed any brackets here. But then why is it giving me this error on line 71... I'll put in the code too in case someone would like to review it: #include <cs50....
Soham Roy's user avatar
0 votes
0 answers
11 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
13 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
24 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
1 answer
15 views

Hey. I was trying the Mario block programs(pset1), but for some reason I am facing an error during compilation itself

So, I followed all the correct steps for the zip file and everything worked fine, but I'm facing the following issue... Anyways, as you can see, I do have a file named mario.c in my current directory....
Soham Roy's user avatar
0 votes
0 answers
57 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
  • 25
0 votes
0 answers
7 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
11 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
21 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,159
0 votes
0 answers
19 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
16 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
1 answer
47 views

Pset3 plurality print winner doesn't work

What's wrong with my code? The program works when I try it manually but when I check it for check50 it returns ":(" for all "print_winner" function. I spent a lot of time on this ...
e-zawadzka's user avatar
1 vote
1 answer
152 views

CS50 Pset3 - Tideman - I passed all the checks except for "lock_pairs skips final pair if it creates cycle". What am I doing wrong!

I am unable to pass the above-mentioned check. I can't see the issue. I would greatly appreciate if someone can share some insights. Code is below: // Lock pairs into the candidate graph in order, ...
Lacept's user avatar
  • 11
0 votes
1 answer
286 views

Outdated - Problem set 3

months = [ "January", "February", "March", "April", "May", "June", "July", "August", ...
Ritam Debnath's user avatar
0 votes
0 answers
48 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
39 views

Pset3 runoff: why does the is_tie function work one way but the inverse does not?

I completed the problem set runoff and finally got it after initially way overthinking. I often find myself just needing to invert/revert logic on these problem sets which is frustrating because I ...
user avatar
0 votes
1 answer
9 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
23 views

pset3: Plurality - check50 errors despite code working

My code appears to work, successfully printing the candidate/candidates with the most votes. However, I fail all of check50’s ‘print_winner’ function tests. I have looked around for a while online, ...
TheWanderingAmateur's user avatar
0 votes
1 answer
42 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
0 answers
43 views

pset 3 tideman - vote function

Can someone help explain to me the purpose of the vote function in tideman, in layman's terms? As they have it set up, ranks[] only takes type int. They keep saying that ranks[i] is the user's [i]th ...
Joseph J Filoramo's user avatar
0 votes
2 answers
59 views

Errors in check50 with plurality.c?

I've finished my plurality code (I even managed to make a version that detects lowercase) but here I paste my simplest version of it (plurality.c). The issue is that I get 10 out of 14 correct in ...
Mariano MF's user avatar
0 votes
0 answers
10 views

How to select a different result in the same integer

Hey I don't really know how to ask my question, I will try to summarize. In candidates[i].votes I want to add a if to printf a specific things if I get two candidates the same results. In the base ...
bd12's user avatar
  • 1
0 votes
1 answer
129 views

split function in python seems to perform a strip as well?

I am following CS50P and I developed the outdated problem (last exercise in pset3) My code works ok, and I got 100% - all checks passed. However, I then checked for other solutions online to help me ...
thomas's user avatar
  • 3
0 votes
0 answers
11 views

How can I implement a while loop in Tideman

Because I thought that I cannot create a new function (and therefore recursive not possible). Now I'm trying to implement it by using a while loop but it's not working as expected, can someone help me ...
PerplexingCode's user avatar
0 votes
1 answer
47 views

Pset3 Fuel :can't split successfully when fraction containing 100

I am doing the Problem set 3 :Fuel Gauge. With every other fraction input the program works fine, but when I inputed 10/10, the program will can't detect /, and so that the program can't split the ...
Onion_in_Germany's user avatar
0 votes
0 answers
25 views

PSET3 - Tideman - lock_pairs help needed

Pasting my code for the function lock_pairs below. I know it's not the best way to do it but nevertheless I was sure the logic behind it is sound because when I did my own testing it modified locked[][...
user19775552's user avatar
0 votes
1 answer
77 views

whats wrong with my printwinner punction

i tested this function and it works but check50 seems to have a problem. :( print_winner returns true when someone has a majority print_winner did not print winner and then return true :( ...
yosef's user avatar
  • 5
0 votes
1 answer
117 views

Tabulate function doesn't works properly (CS50x Runoff)

guys. I'm currently doing runoff (pset3) of CS50x, but I'm in trouble with the tabulate function. Here's the code: #include <cs50.h> #include <stdio.h> #include <string.h> // Max ...
Champs Legion's user avatar
0 votes
1 answer
123 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
53 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
95 views

having problems with check50 in plurality

I seem to have a working program but whenever i run Check50 it gives me all green except for two of the lines which for some reason don't seem to think it works. #include <cs50.h> #include <...
Schmilp's user avatar
0 votes
1 answer
46 views

Pset 3 Plurality "use of undeclared identifier"

I'm not sure I understand why here: // Update vote totals given a new vote bool vote(string name) { for (int j = 0; j < candidate_count; j++) { if (strcmp(name, candidates[j].name) =...
jiayou's user avatar
  • 17
0 votes
1 answer
22 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
1 answer
71 views

Another Runoff issue with check50 on print_winner function

OK. I throw the towel. For the last 4 hours I have been getting the following errors in check50: :( print_winner prints name when someone has a majority print_winner did not print winner of election :(...
pampero43's user avatar
0 votes
0 answers
24 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
183 views

CS50 problem set 3, vote function problem

Good evening. I have a problem with problem set 3 (plurality) https://cs50.harvard.edu/x/2022/psets/3/plurality/ "vote" function always return "false". I tried different ways, but ...
Bagazega's user avatar
0 votes
1 answer
26 views

Pset3, Plurality - seems to be skipping the first the return true for each first vote cast for a candidate

This is the first question I have asked but I can not seem to find the answer anywhere. let say I put in 2 candidates alice and bob with 5 for the number of votes. Every time I first write a vote say ...
Eric Morrison's user avatar
0 votes
2 answers
243 views

PSET3 Runoff Vote Function

I'm having trouble understanding how to write this vote function. I understand what I wrote is incorrect because I am assigning a struct to an array of ints but I can't understand how I'm supposed to ...
Cristian's user avatar
0 votes
1 answer
517 views

Tideman - "lock_pairs skips final pair if it creates cycle" - Almost there!

Getting good results in test cases. Hoping someone can point out where I'm going wrong! I'm also open to general code comments. // Lock pairs into the candidate graph in order, without creating cycles ...
monkdogz's user avatar
0 votes
1 answer
246 views

PSET 3 runoff is_tie function

New to this platform, forgive me if there are some norm or etiquette I may be missing. Please feel free to provide feedback on anything that is incorrect. This is for the is-tie function alone. I ...
x code's user avatar
  • 23
0 votes
1 answer
82 views

pset3 runoff tabulate function not knowing where to start

Is it required to eliminate candidates within the tabulate function? How should we recognize when a candidate is eliminated and how do we go about increasing vote count catering for eliminated ...
turbulenttangles's user avatar
0 votes
1 answer
85 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
1 answer
51 views

PSET3 - Plurality. Check50 is showing three error messages. Unable to find any mistakes in my code. Please help

Attached are my two functions. The code did not print winner for two inputs and also did not print all names in case of tie. // Update vote totals given a new vote bool vote(string name) { // TODO ...
Sumith's user avatar
  • 5

1
2 3 4 5
27