Optimized* version of the laby.py program, the only exception is that it doesn’t work yet…
from kandinsky import draw_string as st, fill_rect as rt,set_pixel as px from random import random as ra,randint as ri,choice as ch from ion import keydown as k from time import sleep def rc(): return (ri(0,255),ri(0,255),ri(0,255)) def laby(X,Y,s,S,n): pos=[(0,0)] visted="1" visted+="0"*(n**2-1) # visted=[[0,]*n for i in range(n)] dirs=((-1,0),(1,0),(0,-1),(0,1)) # rt(X-S,Y-S,(s+S)*n+S,(s+S)*n+S,(255,)*3) # for i in range(n): # for j in range(n): # rt(X+i*(s+S),Y+j*(s+S),S,S,(255,0,0)) # I=0 while pos: allows=[] x,y=pos.pop() for i in dirs: if 0<=x+i[0]<n: if 0<=y+i[1]<n: if visted[y+i[0]+n*x+i[1]]=="0": allows.append(i) if allows: d=ch(allows) n_x,n_y=x+d[0],y+d[1] if len(allows)>1: pos.append((x,y)) pos.append((n_x,n_y)) visted=visted[:n_y+n*n_x]+"1"+visted[n_y+n*n_x+1:] w=s*d[0]if d[0]else 1 h=s*d[1]if d[1]else 1 _X=X+s*x _Y=Y+s*y rt(_X,_Y,w,h,(255,)*3) while 1: a=1 while a: try: rt(0,0,320,222,(0,0,0)) laby(10,10,10,10,10) a=0 except MemoryError:print(1) while not k(4)|k(52):1