Questions tagged [tideman]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
12 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
60 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
0answers
23 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
16 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
0answers
8 views

cs50 pset3 print winner function

Im strugling with print_winner function in Tideman election program. In my opinion function workes fine. It prints the candidate which has all false values in column under his name (number) in locked ...
0
votes
1answer
29 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
12 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
0answers
17 views

help with pset3 tideman lock_pairs function

This function is a recursive function, that lock_pairs is using to understand if a pair will create a cycle: bool create_cycle(int win_idx, int orig_idx) { if (win_idx == orig_idx) // if it's not ...
0
votes
0answers
24 views

PSET3 Tideman: Help with lock_pairs function

how's it going? I'm now working on Tideman but I'm now having a hard time why my code does not satisfy all the condition, only the first one: :) lock_pairs locks all pairs when no cycles These two ...
0
votes
1answer
122 views

How to set rank for all preferences?

Any thoughts on that to set rank for all preferences?
0
votes
0answers
34 views

I'm STUCK for a good while in pset3 Tideman last 3 functions :(

I'm mostly concerned about the sort_pairs() function atm, but i'm willing to receive answers regarding the whole code. I can't really see what's wrong with the way i coded it in general, but mostly ...
0
votes
0answers
11 views

My program does **NOT** skip the last pair if it creates cycle. #PSET3 #Tideman

my program has apparently one bug. check50 says my program does NOT skip the last pair if it creates cycle. However, I ran my function through debug and it did skip the last pair and did not write ...
0
votes
1answer
32 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 ...
0
votes
1answer
301 views

pset3 Tideman: function to print out preferences array is not working

I have written a function, print2d(), to print out a 2D array. I am using it to print out the preferences array after calling record_preferences() in main according to the provided template. The ...
0
votes
0answers
24 views

tideman sort pairs not working

dont know why my function isn't working, i suspect the while loop triggers even when it shouldn't. void sort_pairs(void) { // TODO supair supairs[pair_count]; supair unSorted[pair_count]; ...
0
votes
0answers
33 views

CS50 tideman Lockpairs function (Doesn't skip the last pair?)

So in order to solve lockpairs function, I made a custom function that can detect a cycle (it would return true if it has a cycle, false if it doesn't). My custom functions logic is: Check each pair ...
0
votes
0answers
34 views

Could someone explain why this function for pset3/tideman isn't correct

So as seems to be the case with many people, I'm struggling a bit with tideman. My code scores full marks up until the point where the pairs become "locked." The code for my lock_pairs ...
0
votes
0answers
17 views

Tideman: linking pairs to candidates

and thanks for helping. I am confused with Tideman, and would love some enlightenment: I successfully sorted pairs, and can't figure out, in order to fill the bool locked, how to link the candidates ...
0
votes
0answers
44 views

lock_pairs skips final pair if it creates cycle

I have been working on the tideman problem from Problem Set 3. After multiple attempts, I have been able to pass all the required checks except one: "lock_pairs skips final pair if it creates ...
0
votes
1answer
77 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
0answers
34 views

Problem Set 3 - Tideman Lock Pairs

I am trying to solve the tideman problem for pset3. I have managed to get all parts of my code working apart from the the two parts which relate to checking whether cycles are created. :( lock_pairs ...
0
votes
0answers
28 views

Error in recursive cycle check function for pset3 tideman

I've implemented a recursive function to check for cycles and return a boolean based on if a cycle is found or not. Check50 only returns one error, and that is for "lock_pairs skips final pair if ...
1
vote
1answer
229 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
0answers
30 views

PSET 3 TIDEMAN Locked pairs Function

I am relatively new to the community so please forgive me should my question not be coherent enough. Ok so basically check 50 tells me that everything in my code is okay except for the locked pairs ...
0
votes
0answers
25 views

Lock pairs and Recursivity

I've been trying to solve this pset since more than a month and don't want to give up... so this is the first time I'm coming to ask for help. Basically I separated in two parts the lock_pairs ...
0
votes
0answers
90 views

Can't get pset3/tideman's lock-pairs function to work

Before going to Python I thought I'd go back to some previous homework that I hadn't been able to solve - pset3/tideman. I've spent ages on this but I just can't seem to figure out the lock function. ...
0
votes
1answer
98 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
0answers
500 views

PSET3 -Tideman - lock_pairs

I'm doing tideman and I can't understand where is the problem: my code seems to be working but the test says that it does not. I will share a bit of my code: int count = 1 void lock_pairs(void) { ...
0
votes
0answers
43 views

PSET 3 CS50x: Need help with print_winner

here's my print_winner code. Could someone help me see what's wrong? Thanks so much. void print_winner(void) { //dummy number. just so loser != 0 for later on. int loser = 90000; for (int ...
0
votes
1answer
202 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 // ...
0
votes
1answer
336 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] = ...
1
vote
1answer
189 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
409 views

pset3: code failed to compile

Now I am doing tideman and I already test and all are working well and get the expected result.but when I check with Check50,I got this msg :( tideman compiles code failed to compile I just ...
1
vote
2answers
4k views

PSET3 -Tideman - Locking Pairs

I'm looking for a little help to check my logic on this problem set. My program currently passes all the check50 tests up until I have to lock in the pairs to the locked array. You must lock all ...
0
votes
1answer
171 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
43 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
300 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
43 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. ...
0
votes
1answer
134 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
88 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
198 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
0answers
99 views

pset3 tideman; can't pass check50 “lock_pairs skips final pair if it creates cycle”

I'm kind of confused about what the last pairs should be if it creates cycle. Like, if a->b, b->c, and the last pair is c->a, should I just skip it or turn it around, make it a->c? I tried both idea, ...
0
votes
1answer
21 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 ...
1
vote
1answer
233 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
0answers
72 views

pset3 tideman ranks array

In the tideman distribution code and the logic itself, the ranks[] array in the vote function is never actually sent outside the vote function. The array that's going to be passed into the ...
-1
votes
1answer
74 views

CS50 Pset3 Tideman

please let me know what’s wrong with my work. Thank you!
0
votes
0answers
48 views

cs50x tideman sort not work

// Sort pairs in decreasing order by strength of victory void sort_pairs(void) { // TODO printf("=-------------------------- sort---------------pair=%d\n",pair_count); pair pairx[...
0
votes
1answer
124 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
278 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
275 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 ...