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

Pset3 Tideman, I dont understand why the locked_pairs doesn’t work :(

the last few days I worked very hard on the Pset3. I worked out pretty much all of the functions in the tideman problem. But I just can’t get the locked_pairs function done. I try to fix it but with ...
user avatar
0 votes
0 answers
12 views

Why does this change in my Tideman sort_pairs function cause it to work?

I was surprised to see that in my sort_pairs function for Week 3's problem Tideman, changing the boundaries of my two for-loops from pair_count to pair_count - 1 causes check50 to say that the pairs ...
user avatar
0 votes
0 answers
14 views

Failing to increment pair count correctly add_pairs Tideman CS50

When testing with a print statement the pair count seems to be correct even when there are ties between 4 voters or when there are no ties. But for some reason I'm still failing. Could someone please ...
user avatar
0 votes
1 answer
20 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 :(...
user avatar
0 votes
0 answers
15 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 ...
user avatar
0 votes
1 answer
36 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 ...
user avatar
0 votes
1 answer
18 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 ...
user avatar
0 votes
0 answers
164 views

CS50 2022 Pset3 (Tideman) print winner works but cannot pass check50

I wrote the code according to the specifications. I had tried some examples I can imagine and was able to print out the winner correctly. But check50 said there was still something wrong with the ...
user avatar
0 votes
2 answers
71 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 ...
user avatar
0 votes
1 answer
88 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 ...
user avatar
0 votes
1 answer
39 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 ...
user avatar
  • 23
0 votes
0 answers
16 views

Pset3 Tideman :( lock_pairs locks all pairs when no cycles

I can't understand why it wouldn't given my code and examples i have thought of for (int i = 0; i < pair_count; i++) { locked[pairs[i].winner][pairs[i].loser] = true; locked[...
user avatar
0 votes
1 answer
37 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 ...
user avatar
0 votes
1 answer
45 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 ...
user avatar
0 votes
1 answer
44 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 ...
user avatar
  • 5
0 votes
0 answers
25 views

CS50 PSET3 Tideman Help!

I'm having a little trouble with the add_pairs function because the pairs array refuses to store numbers. I used printf to corroborate the values that were being recorded, and the i and j ints don't ...
user avatar
  • 1
0 votes
2 answers
32 views

Pset3 Runoff CS50x

I have been trying to debugg the program for a while but am not able to figure out what the error in line 9 is as this was the code provided by the courses and I didn't make any changes. Any help ...
user avatar
  • 7
0 votes
0 answers
25 views

sort_pairs fails check50 tideman using selection sort

My sort_pairs function fails the check50 **:( sort_pairs sorts pairs of candidates by margin of victory ** test however it passes the usage case given on the CS50 website. I am using selection sort to ...
user avatar
0 votes
0 answers
17 views

PSET3 Tideman: Why does the order of arguments in this function matter?

I'm working on debugging the Tideman pset and came across a weird issue in my lock_pairs function. My code is below: void lock_pairs(void) { // Loop through pairs for (int i = 0; i < ...
user avatar
0 votes
1 answer
74 views

pset3 runoff: find_min function help

please help. Errors: :( find_min returns minimum when all candidates are tied find_min did not identify correct minimum :( find_min ignores eliminated candidates find_min did not identify correct ...
user avatar
0 votes
1 answer
26 views

pset3, vote(); direct comparison failing but strcmp() working?

Why is if (strcmp(candidates[i], name) == 0) working, but: if (name == candidates[i]) not working? I have also tried with casting string on both sides, but doesn't work. I have checked via printf, ...
user avatar
0 votes
0 answers
42 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 < ...
user avatar
0 votes
0 answers
26 views

CS50 AI Crossword self.crossword.variables is not giving me all the variables in the problem

I finished my code for the this assignment however when I run it I get an error saying 'NoneType' object has no attribute 'i'. After observing the stack I saw that backtrack was calling itself ...
user avatar
0 votes
1 answer
31 views

I changed typedef struct in Plurality in problem set 3, is there any problem?

"You should not modify anything else in plurality.c other than the implementations of the vote and print_winner functions (and the inclusion of additional header files, if you’d like)." I ...
user avatar
0 votes
0 answers
122 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&...
user avatar
0 votes
1 answer
29 views

Pset3 add value to preferences array

my code for (int i = 0; i < candidate_count; i++) { if (strcmp(candidates[i].name, name) == 0) { preferences[voter][rank] = i; return true; } } I'm able to printout ...
user avatar
0 votes
0 answers
58 views

Pset3 - tidmean - need help to understand logic behind solution

The screenshot above is a solution which I found on youtube (link: https://www.youtube.com/watch?v=mw0ukwi_ZLI&t=480s&ab_channel=AlgorithmicCoding). However, He doesn't explain why we do not ...
user avatar
1 vote
2 answers
64 views

(!vote) in runoff [pset3]

I am having real difficulty understanding how calling the vote function for valid votes in runoff is supposed to work. The relevant part of the distribution code is as follows: // Record vote, unless ...
user avatar
0 votes
0 answers
19 views

Tabulate fails with candidate elimination

I 've tried many things and they didn't solve the problem. Thanks in advance.
user avatar
0 votes
0 answers
12 views

sort pair function does not work. tideman pset3

The following code seems to work while checking in debug50 but check50 flags it as wrong . void sort_pairs(void) { for (int i = 0; i < pair_count; i++) { for (int j = ...
user avatar
  • 72
0 votes
0 answers
23 views

Could anyone point out why my lock_pairs function is not locking the final cyclical pair correctly?

My lock_pairs function works correctly locking all pairs when no cycle is created and skips the middle part when a cycle is created. However, when a final cycle is created, cs50 says it's not working ...
user avatar
  • 1
0 votes
1 answer
31 views

Vote indexing problem

my code works well in indexing all votes in the preferences except for the first one, I tried debugging and it worked well for all indexes including the first one..!
user avatar
0 votes
0 answers
10 views

Preferences error

I can't fully understand this code syntax or how it will look like if we are going to print it for example.
user avatar
0 votes
0 answers
36 views

CS50 PSET3 test code does not compile

The output says that the code does not compile, but the error is in the test code not in mine`s
user avatar
0 votes
1 answer
38 views

Plurality problem

I ran check50 on my code and it worked fine on everything except in dealing with invalid votes, so I tested it by debugging and fount out that a segmentation error occurs while debugging, and then ...
user avatar
0 votes
1 answer
21 views

Plurality Clarification

Here, can I edit return false because it seems to be in the wrong place for me (to return false at any time and/or case it was called in), or I should edit only the TODO code section?
user avatar
0 votes
1 answer
24 views

Plurality starter code clarification

Previously, we 've been indicating an array by typing its datatype at first, and then the rest of the syntax how does candidate here is typed instead of the datatype ?
user avatar
0 votes
1 answer
61 views

Having trouble with is_tie in runoff. How do I use a count in an if statement as a variable in another if statement?

I need to be able to count "eliminated" from the number returning true from one if statement and use it in the if statement that follows it. How do I get the code to store the new "...
user avatar
  • 14
0 votes
1 answer
16 views

Printf works fine if arr[0] is the largest after sorting, but not if another element is moved to that position. Why?

I am trying to sort a typedef struct array and print out those elements that have the largest number. I can get the answer I want, but if the element that is largest is NOT what was originally in the ...
user avatar
  • 14
0 votes
1 answer
143 views

Pset3 - runoff - print_winner and find_min error

After I checked my code using check50 cs50/problems/2021/x/runoff, I received the following error messages for my bool print_winner(void) function and int find_min(void) function as follows :( ...
user avatar
0 votes
0 answers
52 views

CHECK50 for Plurality shows bug which manual testing can't find

Could anyone perhaps help me figure out what's wrong with the code below? When I check it manually, it works every time, in every scenario I can think of, but when I run check50 on it, I get ":( ...
user avatar
0 votes
1 answer
53 views

Problem Set 3 (Runoff) print_winner function doesn't print and quits

I am working on problem set 3 runoff and I am having trouble with getting my print_winner function to work correctly. When I run the program it basically does nothing and quits the program. It gets ...
user avatar
1 vote
1 answer
130 views

PSET3 Tideman - What to do with the lock_pairs function?

Can someone please help me with the lock_pairs section of the problem? The lock_pairs function is killing me. I get that you have to compare the pairs to each other and then return false or true in ...
user avatar
  • 139
0 votes
1 answer
57 views

why am i getting an " use of undeclared identifier 'j' or 'i' " on the vote and tabulate functions?

shouldn't the compiler consider the 'i' and the 'j' from the for loop in the 'main' function to be the voter and rank ints passed to the functions #include <cs50.h> #include <stdio.h&...
user avatar
0 votes
1 answer
76 views

cs50 plurality invalid vote

I'm working on plurality on pset3, and so far I haven't edited any code, but whenever I try enter a vote it comes back as 'invalid vote'. Is this normal? And if so what should I do to solve this bit.
user avatar
  • 107
0 votes
1 answer
88 views

Runoff: Issue with check50 on find_min function

I've tried two different variations of my implementation of the find_min functions and both times two of the requirements on check50 are achieved and only one shows an error. Sucesses: :) ...
user avatar
0 votes
1 answer
72 views

Passing arrays into function in tideman

I've created a solution to week 3's tideman problem which is entirely logically correct. Unfortunately, I had to dodge the standard solution by commenting out parts of a function and altering its ...
user avatar
1 vote
1 answer
342 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 ...
user avatar
1 vote
2 answers
192 views

Can't determine the problem with my tideman program - check50 fails at lock_pairs function, says I didn't correctly lock all non-cyclical pairs

My program for the tideman problem in pset3 passes all check50 checks except for :( lock_pairs skips final pair if it creates cycle lock_pairs did not correctly lock all non-cyclical pairs Here ...
user avatar
0 votes
0 answers
108 views

My tabulate function won't work for multiple eliminated candidates

I dont know what to do. My tabulate function won't work for multiple eliminated candidates and multiple rounds of preferences. The rest is fine, as check50 states: :) tabulate counts votes when all ...
user avatar

1
2 3 4 5
27