Skip to content

Instantly share code, notes, and snippets.

@MartinThoma
Created March 16, 2013 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartinThoma/5178175 to your computer and use it in GitHub Desktop.
Save MartinThoma/5178175 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding: utf-8 -*-
nodes = [float(i) for i in xrange(1,11)]
print nodes
for i in xrange(0,4000):
newList = []
for index in xrange(0,10):
if index == 0:
newList.append((nodes[0]+nodes[1])/2)
elif index == 9:
newList.append((nodes[8]+nodes[9])/2)
else:
newList.append((nodes[index-1]+nodes[index]+nodes[index+1])/3)
if (nodes == newList):
print("Helau!:" + str(i))
break
nodes = newList
print nodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment