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
12 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
17 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
5 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
17 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
38 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
15 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
27 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
35 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
0answers
10 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
13 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
25 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
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
23 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
14 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
18 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
15 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
13 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
41 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
28 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
29 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
40 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
65 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
23 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
49 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
47 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
12 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
40 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
33 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
48 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
108 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
90 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
84 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
172 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
41 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
27 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
66 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
33 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
69 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
330 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
96 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
50 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
37 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
33 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
161 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
38 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
21 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 // ...

1
2 3 4 5
27