From 4d98e74255e875bef9a63cd8795f4f9768bcb981 Mon Sep 17 00:00:00 2001 From: apassenger Date: Mon, 6 May 2019 11:04:54 +0200 Subject: [PATCH 1/3] nPartyCoinFlip Users can add parties that they want to add(not only 4 party) --- .../pythonLib/coinflipLeader/nPartyCoinFlip | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/pythonLib/coinflipLeader/nPartyCoinFlip diff --git a/examples/pythonLib/coinflipLeader/nPartyCoinFlip b/examples/pythonLib/coinflipLeader/nPartyCoinFlip new file mode 100644 index 0000000..bb0b69a --- /dev/null +++ b/examples/pythonLib/coinflipLeader/nPartyCoinFlip @@ -0,0 +1,30 @@ +from cqc.pythonLib_protocols.coinflip_leader import CoinflipConsensus + + +def main(): + + leaderChooser = CoinflipConsensus(arr) + return leaderChooser.leader() + + + +arr = [] +veri = input("Add person") +while veri: + arr.append(veri) + veri = input("Add person") + + + +d = dict() +for veri in arr: + d[veri] = 0 + + +for i in range(0, 20): + if i % 10 == 0: + print(i) + d[main()] += 1 + + +print(d) From 006a7b1183dc16665aa6d2c4cb84913a162518bc Mon Sep 17 00:00:00 2001 From: apassenger Date: Mon, 6 May 2019 11:05:27 +0200 Subject: [PATCH 2/3] Rename nPartyCoinFlip to nPartyCoinFlip.py --- .../coinflipLeader/{nPartyCoinFlip => nPartyCoinFlip.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/pythonLib/coinflipLeader/{nPartyCoinFlip => nPartyCoinFlip.py} (100%) diff --git a/examples/pythonLib/coinflipLeader/nPartyCoinFlip b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py similarity index 100% rename from examples/pythonLib/coinflipLeader/nPartyCoinFlip rename to examples/pythonLib/coinflipLeader/nPartyCoinFlip.py From 3b82c9c235a51630eab65dd90f494936e1756331 Mon Sep 17 00:00:00 2001 From: apassenger Date: Tue, 21 May 2019 17:43:28 +0300 Subject: [PATCH 3/3] Update nPartyCoinFlip.py --- .../coinflipLeader/nPartyCoinFlip.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py index bb0b69a..b01041f 100644 --- a/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py +++ b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py @@ -3,24 +3,27 @@ def main(): - leaderChooser = CoinflipConsensus(arr) + leaderChooser = CoinflipConsensus(arr) # Elects a leader from array that you declared return leaderChooser.leader() - - -arr = [] -veri = input("Add person") -while veri: +# For 12-13-14-15 lines: After seeing "Add person" sentence, you can add person that how many person you want to add. +# After adding one person you should press "enter" and then you can continue to add person with press enter +# If you want to cancel from adding person you should press enter again +# After enter the all name that you wanted to add you should press "enter" +# 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 ... +arr = [] # Here an empty array was defined +veri = input("Add person") +while veri: arr.append(veri) veri = input("Add person") - +# giving a value for each leader d = dict() for veri in arr: d[veri] = 0 - +# Runs 20 rounds of leader election and prints the results. for i in range(0, 20): if i % 10 == 0: print(i)