Questions tagged [tideman]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
14 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 < ...
0
votes
0answers
9 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]....
0
votes
1answer
16 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
28 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
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
14 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
94 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 ...
0
votes
0answers
42 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
68 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
0answers
34 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
52 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
134 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
99 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
51 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
1answer
71 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
0answers
103 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
59 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
171 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
39 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
1answer
46 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 - ...
1
vote
1answer
481 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
1answer
185 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
2answers
60 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
1answer
166 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
43 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
180 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
1answer
88 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
1answer
44 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
1answer
33 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
1answer
2k 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
1answer
847 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
1answer
219 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 ...
0
votes
1answer
130 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 ...
0
votes
1answer
430 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 // ...
1
vote
1answer
427 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 ...
0
votes
1answer
53 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; ...
0
votes
1answer
532 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] = ...
0
votes
1answer
111 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++) ...
1
vote
0answers
258 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 ...
0
votes
1answer
27 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 ...
0
votes
1answer
59 views

p_set3 why does the int main clear the graph of locked in pairs?

hope everyone is staying safe. I am in week 3 and doing problem set # 3 - Tideman voting. In the main function it says the following: Why does it need to clear the graph of locked in pairs? (p.s. ...
1
vote
1answer
517 views

Failing add_pairs function check50

I'm in the midst of working on tideman, in the midst of it i decide to check for the add_pairs function but i realised check50 is throwing me red coloured texts, solely based on add_pairs. I debugged ...
0
votes
1answer
298 views

Pset3: Tideman - Sort_pairs function

I am trying to solve sort_pairs by including a property - int winsize - into the struct of pair. The new pair struct is: typedef struct { int winner; int loser; int winsize; } pair; I ...
0
votes
1answer
209 views

Tideman sort_pairs function

I tested this sort function separately and it sorts alright, but somehow doesn't pass the check50 test. The pairs.strength is the winning strength, recorded previously in add_pairs function. All my ...
0
votes
1answer
641 views

Tideman, my tests work but check50 says there is an error

When I test my code I get the correct output but check50 shows errors in print_winner function. :( print_winner prints winner of election when one candidate wins over all others print_winner did not ...
0
votes
1answer
151 views

Pset3: Tideman sort_pairs doesn't work?

I know this has been asked before but I've checked every thread and couldn't find a solution. According to check50, my code for sort_pairs() doesn't work, and I can't figure out what could be wrong ...
0
votes
1answer
80 views

pset3 record_prefernces : i have segmentation fault error

i'm trying to implement record_preferences function but when i try to run the program it stops after getting first voter choices sorry for my messy thanks in advance the code :
0
votes
1answer
356 views

How do I implement lock_pair function correctly in Tideman?

Can anyone help check what is wrong with my logic? I tried implementing lock_pairs using these lines of codes: void lock_pairs(void) { // TODO int count = 0; for (int i = 0; i < ...
0
votes
2answers
345 views

CS50x 2020 Problem Set 3 Tideman

I have been working on the Tideman problem for a while now, and am still not able to find out how to implement the sort_pairs() function. I have implemented my sort_pairs() function, but it is not ...
-1
votes
1answer
85 views

CS50 Pset3 Tideman

please let me know what’s wrong with my work. Thank you!