-
-
Save nicknapoli82/2379634e87f24399ed1ed12c4c2e8c9a to your computer and use it in GitHub Desktop.
Here are the pairs, in my codes sorted order, that should be locked or not locked. The end is the winner. | |
This is considering the order of my pairs specifically. If your tied pairs are ordered different, the winner my be different. | |
(winner -> loser) | |
Locked g -> h | |
Locked e -> h | |
Locked e -> f | |
Locked i -> c | |
Locked b -> g | |
Locked b -> h | |
Locked d -> g | |
Locked d -> h | |
Locked f -> h | |
Locked g -> i | |
Did not lock c -> d | |
Locked c -> e | |
Locked c -> f | |
Did not lock c -> g | |
Locked c -> h | |
Locked d -> e | |
Locked d -> f | |
Locked b -> f | |
Locked a -> h | |
Locked e -> a | |
Did not lock e -> b | |
Did not lock a -> d | |
Did not lock e -> g | |
Did not lock a -> c | |
Did not lock e -> i | |
Locked f -> a | |
Did not lock f -> g | |
Locked b -> d | |
Did not lock a -> b | |
Did not lock c -> b | |
Locked i -> a | |
Did not lock i -> b | |
Did not lock a -> g | |
Did not lock i -> d | |
Locked i -> f | |
Locked i -> h | |
Winner = b |
9 | |
i | |
b | |
c | |
d | |
e | |
f | |
g | |
h | |
a | |
e | |
f | |
g | |
h | |
i | |
a | |
c | |
b | |
d | |
g | |
h | |
i | |
c | |
a | |
d | |
e | |
b | |
f | |
f | |
e | |
d | |
a | |
b | |
g | |
i | |
h | |
c | |
a | |
d | |
b | |
i | |
c | |
g | |
e | |
f | |
h | |
e | |
f | |
g | |
h | |
i | |
d | |
a | |
c | |
b | |
e | |
c | |
b | |
a | |
d | |
g | |
i | |
h | |
f | |
i | |
f | |
b | |
d | |
a | |
c | |
g | |
e | |
h | |
c | |
b | |
a | |
d | |
g | |
e | |
h | |
f | |
i |
If using the test mentioned by OP , I am getting different lock pairs array then does that mean that my lock pairs algorithm is wrong? I am not saying about the winner but just the lock pairs array
I also had differing lock pairs in this test at first. I then changed my sorting algorithm from "selection sort" to "bubble sort", which gave me the same results as the OP has posted here. So the answer to your question above is "may be, but not neccessarily".
You can also use check50 to check your results.
Actually, the influence of the order of the tied pairs, even on who the winner is, is discussed here above
Mahantesh1729 commented on 12 Sep 2020
is this the flaw in tideman? Since we get different winner if the tied pairs are ordered different
and OP replying
Yea. I would say this is the flaw in the tideman algorithm. Though in an actual election there would certainly be few candidates with many votes. The probability of ties in that case would be extremely small.
The reason is that there are many tied pairs that have the same winning margin in this test case here by OP. And depending on which sorting algorithm you use you may get a different order for these pairs.
But as I said, check50 may be helpful.
This may be a silly question but how do I use the test case provided? I've created the text file Tideman_test.txt and ran using "./tideman a b c d e f g h i < Tideman_test.txt"
but i just get the following output:
tideman/ $ ./tideman a b c d e f g h i < Tideman_test.txt
Number of voters: Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
Rank 1: Rank 2: Rank 3: Rank 4: Rank 5: Rank 6: Rank 7: Rank 8: Rank 9:
@Shanahando I am in the same boat as you. I cannot get this test to work and I think it may have to do with CS50 switching from using their IDE to the cloud codespace... I really hope someone knows a workaround because I have been stuck on locked pairs for far too long.
Does anyone know how to use a txt file like this with debug50, so that we can see each step of the functions as they execute?
I tried running debug50 tideman a b c d e f g h i < Tideman_test.txt , but that did not work
THANKS I WAS ALMOST TO GIVE UP BUT YOUR TEST CODE HELPED ME NOTICE SOMETHING IN MY CODE THAT WAS NOT WORKING IN A SPECIFIC CASE
Thanks man!