Questions tagged [tideman]
The tideman tag has no usage guidance.
79
questions
0
votes
0
answers
11
views
Pset3 tideman error at lock_pairs
void lock_pairs(void)
{
int cycle = 0;
int winner;
for(int i = 0; i < pair_count;i++)
{
locked[pairs[i].winner][pairs[i].loser] = true;
if (pairs[i].loser == pairs[i+...
0
votes
0
answers
19
views
Tideman PSET03 - lock_pairs ERROR
I'm currently doing the Tideman PSET03 and I've completed almost everything except ``. Could you tell me why this is happening? It'd appreciated.
Check50:
https://submit.cs50.io/check50/...
0
votes
0
answers
13
views
How to use .txt file with debug50 - pset3 tideman
Does anyone know if there is a way to store a bunch of data, e.g. number of voters and votes for the Tideman problem, as a .txt file, and then run that with debug50, so that I don't have to manually ...
0
votes
0
answers
9
views
Tideman - First Error of lock_pairs function is not working
I'm currently doing the lock_pairs function of tideman. I have completed most of the requirements of check50 in the lock_pairs function except :( lock_pairs locks all pairs when no cycles. I don't ...
0
votes
0
answers
13
views
Tideman PSET03 - Add_Pairs errors!
I'm currently doing the tideman pset and i have some errors on the add_pairs function and the lock_pais function but I'm more focused now on the add_pairs function. I don't know why these errors are ...
0
votes
0
answers
11
views
Tideman PSET03 - Please Help Me!
I've been doing Tideman and I've completed every function required. But when I run Check50, it gives me some errors: add_pairs function did not produce 2 pairs , lock_pairs did not lock all pairs, ...
0
votes
0
answers
24
views
Tideman - sample votes
I am very close to solving the lock_pairs function in tideman. Everything passed, except that check50 is saying that :( lock_pairs locks all pairs when no cycles isn't working correctly.
But it does ...
0
votes
0
answers
7
views
Sorting an array based on ints within a strut
I'm looking for a way to implement merge sort to sort the pairs[] array in the tideman problem. The problem being the array is made up of the strut pair, not ints. However, I have added an element to ...
0
votes
0
answers
11
views
What is the difference between these 2 'check_cycle' functions?
This is in regard to the 'lock_pairs()' function that calls on a recursive function 'check_cycle(w, l)' function to check if a cycle will be created before locking a pair of winner (w) and loser (l).
...
0
votes
0
answers
7
views
Tideman: Is there only one original winner (first sorted pair winner) that should be considered while locking subsequent pairs elements?
Seeking help if there is only one original winner to be considered while deciding if subsequent pairs to be locked or not.
0
votes
0
answers
12
views
What is wrong in the else condition with this for loop?
Although the code below does not solve the Tideman problem making use of recursion, still it will help to know why the else condition with the for loop below does not print when pairs are not locked.
...
0
votes
0
answers
32
views
Working on add_pairs function
While continuing working on add_pairs function (https://www.reddit.com/r/cs50/comments/123dtp8/understanding_add_pairs_function/), this is the pseudocode I have formed just to figure out if a is ...
0
votes
0
answers
29
views
Need help in Tideman Problem set 3
My code fails to pass through below three test cases. can you please take a look at the code and suggest what is wrong. Im able to get correct answers but its not passing all test cases.
:( ...
0
votes
0
answers
16
views
Pset3 Tideman add_pair error
the check command says my add_pairs funtions doesnt count or produces the corrects pair but when I run it works fine:
debug50 testing with three candidates a, b, c; preferences are in the same order ...
0
votes
0
answers
56
views
Tideman - print_winner function fails to pass check50
Been scratching my head about this: I can't pass the Check50 test for my Tideman codes, under the following 2 conditions, despite that I had tried with different voting tests and the script always ...
1
vote
1
answer
152
views
CS50 Pset3 - Tideman - I passed all the checks except for "lock_pairs skips final pair if it creates cycle". What am I doing wrong!
I am unable to pass the above-mentioned check. I can't see the issue. I would greatly appreciate if someone can share some insights. Code is below:
// Lock pairs into the candidate graph in order, ...
0
votes
0
answers
48
views
pset 3 tideman - vote function - rank int
I am having trouble figuring out how to set up the rank integer in the vote function of pset3.
I could do this to ask the user to rank the candidate, but I assume that wouldn't work with the sample ...
0
votes
1
answer
30
views
Invalid vote while testing Tideman problem
am working on Tideman.c problem. When I go to test the code by doing the following:
-cd Tideman.c
-clang tideman.c -lcs50
-./tideman Alice Bob Charlie
-Number of voters: 3
-Rank 1: Alice
"Invalid ...
0
votes
1
answer
42
views
Lock pairs function not locking for final pair, but works for middle pairs
I wrote the following code:
void lock_pairs(void)
{
for (int i = 0; i < pair_count; i ++)
{
bool createsLoop = false;
for (int j = 0; j < pair_count; j ++)
{
...
0
votes
2
answers
34
views
What to do to solve while making Tideman.c file? Each time I enter "make + Tideman.c" followed by yes, the terminal prints "y" forever
When I go to make my solution to Tideman.c for testing/debugging, I see no bugs are thrown when I go to compile the file. However, the terminal prints "y" forever once I have stated "...
1
vote
0
answers
206
views
CS50 Tideman locked and cycle question
So i am trying to figure our something i have seen so far as some solutions for the Tideman problem from the CS50 course. My doubt is the following>>
We have this code>>
// Test for cycle ...
0
votes
0
answers
25
views
PSET3 - Tideman - lock_pairs help needed
Pasting my code for the function lock_pairs below. I know it's not the best way to do it but nevertheless I was sure the logic behind it is sound because when I did my own testing it modified locked[][...
0
votes
1
answer
410
views
pset3 Tideman record_preferences
Even from my view it's not the most effective solution, but I though it should work properly, however I can't really understand my mistake. Check50 says the function works incorrectly.
void ...
1
vote
1
answer
339
views
Pset3 Tideman: add_pairs function
Here is my code for the add_pairs() function. I have tested it with the debugger and it seems to work fine. However, check50 tells me that it's not generating correct pair count.
'''
void add_pairs(...
1
vote
0
answers
450
views
Tideman test case with equal pairs
I have a feeling that I'm missing something, but have no clue what exactly...
Recently I found this test case:
Input: for candidates A(0), B(1), C(2) and D(3)
Number of Voters: 8
A B C D
A B C D
B C D ...
0
votes
1
answer
517
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
1
answer
36
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
1
answer
2k
views
(Solved) Problem Set 3 - (Tideman) Print Winner Function
I have implemented everything successfully up until the 'Print Winner Function', and although I'm pretty sure my logic is correct,
and doing manual tests myself yield the correct winner's name.
The ...
1
vote
1
answer
443
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
1
answer
118
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
1
answer
382
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
1
answer
368
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 ...
1
vote
0
answers
134
views
CS50 Tideman lock_pairs function
I am now in tideman and every function seems to work fine but I've been stuck on lock_pairs. I have come up with this solution and when I try to simulate an election it seems to run fine and produces ...
0
votes
1
answer
171
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
0
answers
252
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
1
answer
361
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
1
answer
956
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
1
answer
62
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 ...
1
vote
1
answer
1k
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; ...
1
vote
1
answer
369
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>
#...
1
vote
2
answers
172
views
Tideman : "sort_array" rejected by check50
I am working on Tideman today, and I am stuck on the "sort_array" function. The output my function produces is the one I expect but he 'check50' send me this ":( sort_pairs sorts pairs ...
0
votes
1
answer
860
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
1
answer
82
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
1
answer
525
views
pset3 tideman lock_pairs: why does "lock_pairs locks all pairs when no cycles" fail?
My code fails at check50 but I can't understand why. It that seems my code actually finds cycles, but also produces false-positives (I guess).
check50 output for the lock_pairs function:
:( lock_pairs ...
0
votes
1
answer
155
views
pset3 tideman cs502020 locked pairs error
I am new to coding and I am trying to solve the locked pairs part of the Tideman problem.
Currently, I am receiving the following two errors:
:) lock_pairs locks all pairs when no cycles
:( lock_pairs ...
0
votes
1
answer
67
views
Tideman sort_pairs seems correct but check50 tells me it isn't
Here is the code for my pair sorting algorithm.
void sort_pairs(void)
{
int sorted_pairs_added = 0;
for (int i = voter_count; i > 0; i += -1)
{
for (int j = 0; j < pair_count;...
0
votes
1
answer
75
views
Converting Tideman Cycle test from Python to C
I have written a program in python that (as far as I know) successfully determines whether the locked matrix has a loop in it. However I am having a bit of trouble converting it to C. I am getting an ...
0
votes
1
answer
7k
views
How to swap elements in "struct" data type?
I am working on "tideman" from pset3 and stuck on sorting the data that i have in "struct" data type.
Don't really know if it was supposed to be figured out on our own, but they ...
2
votes
1
answer
1k
views
lock_pairs skips final pair if it creates cycle lock_pairs did not correctly lock all non-cyclical pairs
can anyone please help I got only one error which is:-
lock_pairs skips final pair if it creates cycle
lock_pairs did not correctly lock all non-cyclical pairs
and this is my code
bool hash_cycle(int ...
0
votes
1
answer
433
views
pset3 Tideman: checking for cycles
I made it so that if a losing candidate in any pair wins in another, a function checks whether there's the losing candidate in that pair wins in any other, and so forth.
this here is the unlocks the ...