import math import numpy as np import random import cPickle execfile('niceplot2.py') def check(pins, newpin, width): for pin in pins: if abs(pin-newpin) < width*2: return False return True def cplace(pins = 10, width = 1.0/30, length = 1): while 1: x = [] for i in xrange(0,pins): x.append(random.random()*length) if not(length-width > x[-1] > width and check(x[:-1], x[-1], width)): x = [] break if x: return x def savefile(dat): with open('kol.dat', 'wb') as f: cPickle.dump(dat, f) d = [] for x in xrange(0,100000): d.extend(cplace()) if x % 10 == 0: print x savefile(d)