Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
gaussian sonnet
import random
import sys
def somewhere_around_n(lines, n, stddev):
idx = int(random.gauss(n, stddev))
if idx < 0: idx = 0
if idx > len(lines) - 1: idx = len(lines) - 1
return lines[idx]
stddev = int(sys.argv[1])
lines = list()
for line in sys.stdin:
line = line.strip()
lines.append(line)
a, b, c, d, e, f, g = random.sample(range(len(lines)), 7)
print ""
print somewhere_around_n(lines, a, stddev)
print somewhere_around_n(lines, b, stddev)
print somewhere_around_n(lines, a, stddev)
print somewhere_around_n(lines, b, stddev)
print ""
print somewhere_around_n(lines, c, stddev)
print somewhere_around_n(lines, d, stddev)
print somewhere_around_n(lines, c, stddev)
print somewhere_around_n(lines, d, stddev)
print ""
print somewhere_around_n(lines, e, stddev)
print somewhere_around_n(lines, f, stddev)
print somewhere_around_n(lines, e, stddev)
print somewhere_around_n(lines, f, stddev)
print ""
print somewhere_around_n(lines, g, stddev)
print somewhere_around_n(lines, g, stddev)
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment