Skip to content

Commit 3b82c9c

Browse files
authored
Update nPartyCoinFlip.py
1 parent 006a7b1 commit 3b82c9c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

examples/pythonLib/coinflipLeader/nPartyCoinFlip.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,27 @@
33

44
def main():
55

6-
leaderChooser = CoinflipConsensus(arr)
6+
leaderChooser = CoinflipConsensus(arr) # Elects a leader from array that you declared
77
return leaderChooser.leader()
88

9-
10-
11-
arr = []
12-
veri = input("Add person")
13-
while veri:
9+
# For 12-13-14-15 lines: After seeing "Add person" sentence, you can add person that how many person you want to add.
10+
# After adding one person you should press "enter" and then you can continue to add person with press enter
11+
# If you want to cancel from adding person you should press enter again
12+
# After enter the all name that you wanted to add you should press "enter"
13+
# Note that: you should use name from cqc's names space such as Alice, Bob, David, Eve Charlie.., you cant't use name randomly such as Gozde, Axel ...
14+
arr = [] # Here an empty array was defined
15+
veri = input("Add person")
16+
while veri:
1417
arr.append(veri)
1518
veri = input("Add person")
1619

1720

18-
21+
# giving a value for each leader
1922
d = dict()
2023
for veri in arr:
2124
d[veri] = 0
2225

23-
26+
# Runs 20 rounds of leader election and prints the results.
2427
for i in range(0, 20):
2528
if i % 10 == 0:
2629
print(i)

0 commit comments

Comments
 (0)