Created
August 30, 2009 18:28
-
-
Save paulerickson/178068 to your computer and use it in GitHub Desktop.
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 | |
def stumble(size): | |
x = int(size / 2) | |
y = int(size / 2) | |
count = 0 | |
while -1 < x < size and -1 < y < size: | |
x += random.randint(-1, 1) | |
y += random.randint(-1, 1) | |
count += 1 | |
return count | |
def average(list): | |
return sum(list) / len(list) | |
for size in range(1, 50): | |
print("Size ", size, ": ", average([stumble(size) for x in range(1000)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment