Created
May 29, 2012 00:33
-
-
Save blha303/2821879 to your computer and use it in GitHub Desktop.
consensus.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
x = 0 | |
v = "0" | |
int1 = 1 | |
int2 = inp | |
random.seed() | |
while x != 1000: | |
v = v + "," + str(random.randint(int1,int2)) | |
x += 1 | |
vlist = v.split(",") | |
print max(set(vlist), key=vlist.count) |
Generates 1000 numbers between int1 and int2, gets the most common number generated. 'Consensus' because it pretty much polls people asking for a certain answer.
Ah, fair enough 😄
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is this for?