Questions tagged [runoff]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
15 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 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
1answer
42 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
15 views

Tabulate fails with candidate elimination

I 've tried many things and they didn't solve the problem. Thanks in advance.
0
votes
1answer
27 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
9 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
1answer
22 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
53 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
1answer
31 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
1answer
57 views

CS50 - pset3 - Runoff | Check50 failing print_winner on majority but works correctly for any manual test I can think of

I'm having trouble with getting Runoff to complete Check50. All checks are passing except the two below for the print_winner function :( print_winner prints name when someone has a majority Cause ...
0
votes
1answer
25 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
0answers
52 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
1answer
47 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
91 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
237 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
73 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 ...
0
votes
2answers
115 views

Runoff Help: Tabulate Handles Multiple Rounds of Preferences

I cannot figure out why I am getting rejected on check50 for ":( tabulate handles multiple rounds of preferences - tabulate function did not produce correct vote totals". I get green ...
0
votes
1answer
445 views

PSET 3 Runoff Error: variable length array declaration not allowed at file scope

I realize that this code is not well designed, however I will try to solve that once my code can compile. #include <stdio.h> #include <cs50.h> #include <string.h> typedef struct { ...
0
votes
1answer
129 views

Why do I keep getting the error "expression result unused" in PSET 3 runoff?

I keep getting the error "expression result unused" on the line with preferences[i][j]; . I've tried reinitializing the j and the i variable in the loop in different ways but nothing I've ...
0
votes
1answer
20 views

Tabulate not working when more than 1 candidate is eliminated

Here is my Tabulate Function - void tabulate(void) { int j = 0; for (int i = 0; i < voter_count; i++) { if (candidates[preferences[i][j]].eliminated == 1) { ...
0
votes
1answer
35 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
1answer
60 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
1answer
71 views

Tabulate in Runoff

Finally took a break for a few days to think about stuff and I am back at doing psets Now I am trying to fix the tabulate function, here's my code - void tabulate(void) { for (int i = 0; i < ...
0
votes
1answer
87 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
65 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
2answers
51 views

Check50 all green but my own tests fail

I completed Runoff with 100% pass in check50 but when i do my own tests i get wrong winners. I checked everything to the best of my abilities but i just can't find the problem and it's driving me ...
0
votes
1answer
230 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
1answer
267 views

Pset3 Runoff Find Min not Coded Properly - Can't Find Error

The way I have coded it, I believe my min should be set correctly, but when I try to run it, the check50 says it's wrong. I tested it by printing my min at various points in the code, and it is not ...
0
votes
1answer
75 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
1answer
111 views

Pset 3 runoff. Votes not updating, trying to understand the code sequencing

Ok so im stuck on the tabulate funtion in runoff for pset3. The issue im having is that when i call to "printf" the candidates vote counts the votes still come out as 0. So i dont think the ...
0
votes
1answer
40 views

PSET3 Runoff specification (year 2020): Multiple eliminated candidates featuring in the next-preferred candidates list

In the pset3 Runoff specification (year 2020), every voter effectively votes for their top-preferred candidate who has not already been eliminated. If the top-preferred candidate has already been ...
1
vote
1answer
199 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 ...
0
votes
1answer
77 views

*** No rule to make target 'runoff'. Stop. Even though I'm in the correct directory

I keep getting the No rule to make target error on the runoff problem even when I'm in the correct directory as you can see in the picture attached. Note: I have just completed the vote function for ...
1
vote
1answer
41 views

pset 3 runoff help again

I still dont know what to put in for loop :( I still dont know what to put in the for loop for(int k = 0; k < voter_count; k++) { for (int j = 0; j < candidate_count; j++) { ...
1
vote
3answers
82 views

PSET3 Runoff Help Please

for(m = 0; m < voter_count; m++) { for(t = 1; t < 4; t++) { string name = get_string("Rank %i: ", t); } printf("\n"); } } bool vote(int voter, int rank, string name) { ...
1
vote
1answer
157 views

runoff tabulate error :( tabulate counts votes when multiple candidates are eliminated

void tabulate(void) { for (int i = 0; i < voter_count; i++) //as long as the number of total voters has not been met; this increases which voter we are on { int j = 0; ...
0
votes
1answer
52 views

CS50 Runoff – Cannot get program to execute, am I stuck in an infinite loop somewhere?

I'm trying to execute runoff but after I enter the voters' ranks, the terminal window blinks back at me with nothing. I've scoured all over for similar problems but cannot figure out a solution. I've ...
0
votes
1answer
73 views

Pset3 runoff tabulation error

[![enter image description here][1]][1] I keep getting a tabulation error with check50 that I cannot replicate 11 voters, 4 candidates, 3 or 4 rounds of voting works fine with I run it, and debug50 ...
0
votes
1answer
153 views

Trouble with find_min

I'm trying to implement a bubble sort in the find_min function in pset3 runoff. But It looks like it is not returning the correct min. I think it is because candidates[0].votes may not be the lowest ...
1
vote
5answers
128 views

Trouble with tabulate and printwinner

I'm having a hard time with the runoff problem in pset3, especially with the tabulate function. Based on the instructions it looks like I need to update the preferences array but I'm not sure how. I'm ...
2
votes
2answers
87 views

Trouble with vote function

I can't get the vote function in Runoff to work properly. Can anyone help explain what I am doing wrong here? bool vote(int voter, int rank, string name) { for (int i = 0; i < voter_count; i++) ...
0
votes
2answers
160 views

Pset3 Runoff tabulation issues

I am so close to a successful runoff program, but I've been having issues with the tabulation section. I decided that this was a good place to implement a recursive function, but it is a new concept ...
0
votes
1answer
107 views

pset 3 runoff find_min - where is my logic failing ? - the check gives and error saying it doesn`t find the correct min

int find_min(void) { int min = voter_count; for (int i = 0; i < candidate_count; i++) { if (candidates[i].eliminated == false && candidates[i].votes < min) { min = ...
1
vote
1answer
59 views

Pset 3 Min function need some help

So my min code works, except it ignores the eliminate function. Can someone please show me where my logic is wrong? Thanks. int find_min(void) { int min = voter_count; int h = 0; for (int i = 0; i ...
2
votes
1answer
118 views

pset3 print_winner (prints name when someone has a majority)

I tried in two ways to show the winner of the election, and both testing manually are giving the correct result, but when testing by "check50" the message always appears: :( print_winner prints name ...
0
votes
1answer
99 views

Pset3 Runoff - Printing All Candidates

Could use some help with Runoff. If I do a simple clear winner (all voters vote for the same person as first choice) it prints out the winner just fine. But if I do the test input that the problem ...
0
votes
1answer
25 views

what does different return value signifies in this problem of runoff?

#include <cs50.h> #include <stdio.h> // Max voters and candidates #define MAX_VOTERS 100 #define MAX_CANDIDATES 9 // preferences[i][j] is jth preference for voter i int preferences[...
0
votes
1answer
118 views

pset3 runoff print_winner check50 error

So I have seen this issue mentioned here before and the others have suggested that printing a newline after the name is the solution. However, my code does print a newline and in my tests, I'm getting ...
1
vote
4answers
161 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 ...
0
votes
1answer
59 views

Back again with runoff problems, tabulate() passes no check50 tests

(I can't get formatting to work properly here so it might look a bit weird) void tabulate(void) { int j = 0; for(int i = 0; i < candidate_count; i++) { for( ; j < voter_count;) { ...