Questions tagged [tideman]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
7 views

Pset3 Tideman, I dont understand why the locked_pairs doesn’t work :(

the last few days I worked very hard on the Pset3. I worked out pretty much all of the functions in the tideman problem. But I just can’t get the locked_pairs function done. I try to fix it but with ...
user avatar
0 votes
0 answers
5 views

Why does this change in my Tideman sort_pairs function cause it to work?

I was surprised to see that in my sort_pairs function for Week 3's problem Tideman, changing the boundaries of my two for-loops from pair_count to pair_count - 1 causes check50 to say that the pairs ...
user avatar
0 votes
0 answers
7 views

Code prints correct answer but check50 show errors (Tideman week 3 problem set)

My answer is correct when I ran the code according to the sample test. So I ran checkcs50, but it came back with sorting and locking errors, even though my code is able to print the correct winner. ...
user avatar
0 votes
0 answers
7 views

Failing to increment pair count correctly add_pairs Tideman CS50

When testing with a print statement the pair count seems to be correct even when there are ties between 4 voters or when there are no ties. But for some reason I'm still failing. Could someone please ...
user avatar
0 votes
0 answers
40 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 ...
user avatar
0 votes
0 answers
111 views

CS50 2022 Pset3 (Tideman) print winner works but cannot pass check50

I wrote the code according to the specifications. I had tried some examples I can imagine and was able to print out the winner correctly. But check50 said there was still something wrong with the ...
user avatar
0 votes
1 answer
53 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 ...
user avatar
0 votes
0 answers
25 views

Can someone help me with Tideman, specifically lock_pairs?

When I submit my code, every single section checks out, except, :( lock_pairs skips final pair if it creates a cycle. Could someone give some tips on what I should do to resolve this error? void ...
user avatar
0 votes
0 answers
15 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[...
user avatar
0 votes
0 answers
53 views

lock_pairs did not correctly lock all non-cyclical pairs

this is my code within the lock_pairs function for the tideman problem in pset3. I've looked through it numerous times and I can't find anything wrong with it. However, when I run it through check50, ...
user avatar
  • 1
0 votes
0 answers
25 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 ...
user avatar
  • 1
0 votes
0 answers
25 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 ...
user avatar
0 votes
0 answers
17 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 < ...
user avatar
0 votes
0 answers
16 views

Pset3: Tideman - Sort_pairs

Check50 says that my sort_pairs function is wrong, but with the tests I've used, everything is alright. Here's the code: void sort_pairs(void) { int biggest_strength_of_victory = preferences[pairs[0]....
user avatar
0 votes
1 answer
24 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, ...
user avatar
0 votes
0 answers
49 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 ...
user avatar
0 votes
0 answers
12 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 = ...
user avatar
  • 72
0 votes
0 answers
23 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 ...
user avatar
  • 1
0 votes
1 answer
426 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 ...
user avatar
0 votes
1 answer
111 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 ...
user avatar
  • 129
0 votes
1 answer
68 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 ...
user avatar
1 vote
1 answer
327 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 ...
user avatar
1 vote
2 answers
177 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 ...
user avatar
1 vote
0 answers
79 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 ...
user avatar
  • 11
0 votes
1 answer
96 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 ...
user avatar
0 votes
0 answers
166 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 ...
user avatar
  • 1
0 votes
1 answer
112 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 ...
user avatar
0 votes
1 answer
293 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 ...
user avatar
0 votes
1 answer
49 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 ...
user avatar
0 votes
1 answer
69 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 - ...
user avatar
1 vote
1 answer
813 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; ...
user avatar
1 vote
1 answer
240 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> #...
user avatar
1 vote
2 answers
82 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 ...
user avatar
0 votes
1 answer
443 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 ...
user avatar
1 vote
1 answer
57 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 ...
user avatar
0 votes
1 answer
279 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 ...
user avatar
0 votes
1 answer
118 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 ...
user avatar
0 votes
1 answer
51 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;...
user avatar
  • 1
0 votes
1 answer
52 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 ...
user avatar
  • 1
0 votes
1 answer
4k 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 ...
user avatar
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 ...
user avatar
0 votes
1 answer
266 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 ...
user avatar
0 votes
1 answer
161 views

My print_winner from pset3/tideman is doing everything right and still check50 says it's wrong

void print_winner(void) { bool looser; for (int i = 0; i < pair_count; i++) { looser = false; for (int j = 0; j < pair_count; j++) //checks if each winner ever lost ...
user avatar
  • 1
0 votes
1 answer
450 views

Pset 3 Tideman lock pairs function

Help, i'm losing my mind. I'm not sure where i'm going wrong in this function, it gives me an error on every line of check50 after sort pairs. Can anybody shed any light? Thank you in advance! J // ...
user avatar
1 vote
1 answer
547 views

Logical flaw in Problem Set 3 - Tideman?

Whilst writing my code for Tideman in Problem Set 3, I had many problems with the lock pair function, as I am very new to coding. Some research I did online also showed that this question is ...
user avatar
0 votes
1 answer
57 views

sort_pairs function not working as per check50

This seems to be a common problem where the check50 program indicates a problem with the sort_pairs function. Here was my implementation of that function: int w; int l; int w1; int l1; for (int i=0; ...
user avatar
0 votes
1 answer
569 views

Please help about tideman lock_pair function!

// Lock pairs into the candidate graph in order, without creating cycles void lock_pairs(void) { for (int i = 0; i < pair_count; i++) { locked[pairs[i].winner][pairs[i].loser] = ...
user avatar
0 votes
1 answer
128 views

Program and debug50 different results

I'm trying to do pset3/tideman. My question is, why when I run program, I get different result (matrix[m]) than run with debug50? void lock_pairs(void) { for (int i = 0; i < pair_count; i++) ...
user avatar
1 vote
0 answers
280 views

Pset3 Tideman: lock_pairs skips middle pair if it creates a cycle

I'm having issues figuring out how to solve this problem without using recursion (I'm not sure how to solve things recursively). Its a program that determines the winner of a Tideman election and I'm ...
user avatar
  • 11
0 votes
1 answer
32 views

What's in the bool function parenthesis?

hope everyone is staying safe. I just want to understand what's inside the parenthesis of the vote function in pset3 - Tideman: bool vote(int rank, string name, int ranks[]) What does it mean to ...
user avatar