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
1answer
8 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 ...
0
votes
1answer
10 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 ...
0
votes
0answers
7 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[...
0
votes
1answer
11 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 ...
0
votes
1answer
24 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 ...
0
votes
1answer
32 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 ...
0
votes
0answers
18 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 ...
0
votes
2answers
27 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 ...
0
votes
0answers
15 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 ...
0
votes
0answers
16 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 < ...
0
votes
1answer
20 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 ...
0
votes
1answer
18 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, ...
0
votes
0answers
29 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 < ...
0
votes
0answers
16 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 ...
0
votes
1answer
28 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 ...
0
votes
0answers
67 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&...
0
votes
1answer
25 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 ...
0
votes
0answers
39 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 ...
0
votes
1answer
52 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 ...
0
votes
0answers
16 views

Tabulate fails with candidate elimination

I 've tried many things and they didn't solve the problem. Thanks in advance.
0
votes
0answers
11 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 = ...
0
votes
0answers
21 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 ...
0
votes
1answer
29 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..!
0
votes
0answers
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.
0
votes
0answers
33 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
0
votes
1answer
28 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 ...
0
votes
1answer
19 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?
0
votes
1answer
21 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 ?
0
votes
1answer
38 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 "...
0
votes
1answer
15 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 ...
0
votes
1answer
82 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 :( ...
0
votes
0answers
11 views

Cannot Compile CS50 Library

I've been running into this problem lately. Here's one of my code: #include <cs50.h> #include <stdio.h> #include <string.h> // ... for (int i = 0; i < voter_count; i++) { ...
0
votes
0answers
36 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 ":( ...
0
votes
1answer
43 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 ...
0
votes
0answers
47 views

Okay, legit think that check50 on Tideman is broken

Actually not, still I cannot grasp what is wrong with the lock_pairs function in my code. This is my lock_pairs function: // Loop to pass each pair for (int i = 0; i < pair_count; i++) { ...
0
votes
1answer
85 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 ...
0
votes
1answer
33 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&...
0
votes
1answer
60 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.
0
votes
0answers
65 views

Pset3 Runoff Tabulate Function

I'm stuck on tabulate function, my code didn't pass any of the requirements in check50. Requirements: tabulate counts votes when all candidates remain in election tabulate counts votes when one ...
0
votes
0answers
19 views

PSET 3 Plurality Print_winner function prints smallest number of votes too many times (sorting algorithm?)

I am doing Problem Set 3 Plurality. I am currently on the print_winner function. My program compiles but I'm having issues because it does not print the winner and any ties it prints whoever got the ...
0
votes
1answer
59 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: :) ...
0
votes
0answers
38 views

Need a bit of help in lock_pairs function of tidema(Pset3)

Here's my code for lock pairs- bool check_cycle(int start, int end) { if (end == start) { return false; } for (int i = 0; i < candidate_count; i++) { if (locked[...
0
votes
1answer
60 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 ...
1
vote
1answer
248 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 ...
1
vote
2answers
136 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 ...
0
votes
0answers
97 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 ...
0
votes
1answer
338 views

Pset3 Runoff is_tie

Having issues with Check 50 and the is_tie function: :( is_tie returns false when only some of the candidates are tied is_tie did not return false :( is_tie detects tie after some candidates have ...
0
votes
1answer
52 views

Pset3 Plurality: program runs fine when I check manually, but Check50 disagrees

I wish I could be more specific with my question, but the problem is as the title suggests, check50's results do not seem to comport to mine. When I put it through check50, it fails on print_winner ...
0
votes
0answers
28 views

Problem incrementing vote in plurality

EDIT: I FIGURED IT OUT AND IT IS NOW WORKING. My code does not increment the vote. It correctly prints the invalid vote- but its not increment the vote at all. #include <cs50.h> #include <...
0
votes
1answer
78 views

cs50 pset3 runoff tabulate function help

I have been stuck at the tabulate function for quite some time, I'm able to code all the other functions except for this tabulate functions. If possible do help me look to see what wrong with the ...

1
2 3 4 5
27