def BuildPuzList(): g = whrandom() p = [] #size=matrix.value(self) for x in range(1033): # fills the list with a number coinciding with its position p.append(x) print "start list" for x in range(1,1032): # fill numbers p[x] = x for x in range(1,1032): # scrambles those numbers y=g.randint(1, 1032) z=p[x] p[x] = p[y] p[y] = z print x,",",p[x] for x in range(1,1032): # makes sure there were no "put backs" if p[x] == x: y=g.randint(1, 1032) z=p[x] p[x] = y p[y] = z print x,",,,",p[x] print "end list" return p
def BuildPuzList(): g = whrandom() p = [] #size=matrix.value(self) for x in range( 1033): # fills the list with a number coinciding with its position p.append(x) print "start list" for x in range(1, 1032): # fill numbers p[x] = x for x in range(1, 1032): # scrambles those numbers y = g.randint(1, 1032) z = p[x] p[x] = p[y] p[y] = z print x, ",", p[x] for x in range(1, 1032): # makes sure there were no "put backs" if p[x] == x: y = g.randint(1, 1032) z = p[x] p[x] = y p[y] = z print x, ",,,", p[x] print "end list" return p
def __init__(self): self.generator = whrandom() self.width = 400 self.height = 400 self.all = [] self.colors = ("red", "yellow", "green", "cyan", "blue", "magenta")
from os import * from mas_settings import * from whrandom import * import sys import regex randobj = whrandom() # Random port number - as a string def randport(): result = randobj.randint(1024, 65535) return '%d' % (result) # Obtain a port number from the user. def obtain_port_number(): while 1: try: print "Enter the server's port number. ", port = sys.stdin.readline()[:-1] result = int(port) except: print 'Invalid input.' continue if result < 1024: print 'You entered ' + port + ' (less than 1024).' print 'Do you really want to use that port number? ', answer = sys.stdin.readline() if regex.match("^[yY]", answer) != -1: break else: break return result