Skip to content

Instantly share code, notes, and snippets.

@blha303
Created May 29, 2012 00:33
Show Gist options
  • Select an option

  • Save blha303/2821879 to your computer and use it in GitHub Desktop.

Select an option

Save blha303/2821879 to your computer and use it in GitHub Desktop.
consensus.py
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)
@Mause

Mause commented Jun 14, 2012

Copy link
Copy Markdown

What is this for?

@blha303

blha303 commented Jun 14, 2012

Copy link
Copy Markdown
Author

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.

@Mause

Mause commented Jun 14, 2012

Copy link
Copy Markdown

Ah, fair enough 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment