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
0answers
8 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
18 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
17 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
27 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
43 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
17 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
29 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
29 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
11 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
20 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
27 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
40 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
58 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 ...
0
votes
2answers
65 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
79 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
87 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
32 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
25 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
49 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
1answer
29 views

Plurality print_winner function gives one error

This is my print_winner function void print_winner(void) { int winner_vote; for (int i = 0; i < candidate_count; i++) { for(int j = i + 1; j < candidate_count; j++) {...
0
votes
1answer
48 views

pset 3 tideman print winner does not exist despite being declared

I have such a strange behavior here in pset 3, tideman. I am doing the print_winner function because check50 says everything else is fine, but when i run the program it looks like print_winner does ...
0
votes
1answer
218 views

cs50 plurality non-void function does not return a value in all control paths error

I'm currently trying to do cs50 pset3 plurality problem and I have unfortunately ran into this error which I do not know how to overcome. The error is "non-void function does not return a value ...
0
votes
0answers
74 views

Tideman error: :( lock_pairs skips final pair if it creates cycle

It would be amazing if someone had the time to look through my code for the Tideman exercise :D I get the following error: :( lock_pairs skips final pair if it creates cycle lock_pairs did not ...
0
votes
1answer
33 views

Sort_pairs fails check50 tideman

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. In the pair type def, I ...
0
votes
1answer
25 views

Plurality error :( vote produces correct counts when all votes are zero

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int ...
0
votes
0answers
15 views

Problem set 3 plurality compilation mystery [duplicate]

In my program of problem set 3 plurality i compiled it and it got compiled and it was working good but when i ran check50 it is telling that "plurality.c code failed to complie" in a red ...
0
votes
0answers
30 views

pset3 plurality— my code is working fine and the prints out multiple winners as well but when i try check50 it fails can anyone tell what is wrong

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int votes; } ...
0
votes
1answer
131 views

PSET 3 - Tideman: Lock Pairs Function

So basically I've got ': )' on everything except : ( lock_pairs skips final pair if it creates cycle Cause lock_pairs did not correctly lock all non-cyclical pairs : ( lock_pairs skips middle pair if ...
0
votes
1answer
35 views

Pset3 Tideman: Why is my sort_pairs function not working?

I'm green on all the criteria before sort_pair. Here's my code so far: // Sort pairs in decreasing order by strength of victory void sort_pairs(void) { // TODO // Create array of strengths of ...
0
votes
0answers
20 views

PSET3 Lock Pairs Function Question

Is there any reason why the while-loop in the below code will not work? `#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // ...
0
votes
1answer
35 views

CS50 Tideman : Sort Pairs problem - check50 automatic test fails, but output seems correct

Good morning guys, I am working on implementation of tideman. Particulary at implementing sort_pairs function. I have written it and tested - and the output seems sorted in a proper way. However - ...
0
votes
1answer
41 views

CS50 Pset3 Plurality

I have issues compiling my program since the last two checks for checkcs50 wont work. It says:problem withprint_winner function did not print both winners of election :( print_winner prints all names ...
0
votes
1answer
226 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
276 views

PSET3 Tideman: Lock_Pairs Help

I've been stuck on this function of the PSET for a couple of days now. I have met every requirement in check50 except for the one that says, ":( lock_pairs skips final pair if it creates a cycle; ...
0
votes
0answers
18 views

Creating my own Header file

I am at pset3 and I decided to try creating my own mergeSort header file. This is something that I have never attempted and haven't learned much about yet so I am at a loss. I have created the the ...
0
votes
1answer
67 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 ...
-1
votes
1answer
33 views

pset3 - plurality - failing check50 'print multiple winners' - but my own tests say it works, not sure what I'm missing

I'm not sure why my program is failing check50, when I run my own tests it does seem to print multiple winners, but check50 says it doesn't print multiple winners [removed solution code]
1
vote
1answer
141 views

Tideman - :( lock_pairs skips final pair if it creates cycle

I have a problem in my Tideman program, it get the error ":( lock_pairs skips final pair if it creates cycle". Can anyone help me figure out what's going on? #include <cs50.h> #...
0
votes
1answer
94 views

Tideman: invalid operands to binary expression ('void' > and 'int')

I'm getting the following error on creating the lock-pair function: tideman.c:259:36: error: invalid operands to binary expression ('void' and 'int') if (check_winner(pairs[i]) == -1) Can someone ...
1
vote
1answer
37 views

Segmentation fault tideman swap function

I'm getting segmentation fault due to my swap function I believe - but can't figure out where it comes from. #include <cs50.h> #include <stdio.h> #include <string.h> // Max number ...
0
votes
1answer
35 views

Plurality - Why do I get segmentation fault?

I've tried running the program but when I put into an incorrect vote I get "segmentation fault". What's wrong? EDIT: I've changed: while (n < candidate_count) to while (n < ...
0
votes
1answer
31 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
53 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
58 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
0answers
32 views

Tabulate function in Runoff

Here is my code void tabulate(void) { for (int i = 0; i < candidate_count; i++) if (strcmp(candidates[preferences[i][0]].name, candidates[i].name) == 0) { ...
0
votes
1answer
59 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
40 views

PSET3 Tideman Sorting Check50 Error

What's the difference between these two codes? Why does the first return me no error from check50 while the second one does? void sort_pairs(void) { int max; for (int i = 0; i < pair_count; ...
0
votes
0answers
56 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
1answer
29 views

Are we supposed to use Algorithms in pset3?

I know it might sound silly but I've done Plurality and right now I am doing Runoff but I don't feel the need to use any of the algorithms like Bubble Sort etc. specifically. Is this right or should I ...
0
votes
0answers
33 views

pset 3 runoff - problem with tabulate

I am a (very) beginner coder, so pls be gentle!! I have numerous mistakes in my code, but am unsure how to fix them. The code is working for some things, and I have scored 73 % on the problem set, but ...

1
2 3 4 5
26