open window 1655,1255 dim p(20) dim q(20) dim blk(20) dim tn(20) gap=120 x=10 //st=0 sa=0 sg=0 sv=0 mn=0 mn1=0 tek=0 // do 2 take //goa=0 // go to add ad=0 // sticks added blk(pot)=0 // no block of position ska=0 // don't skip add label make for nn=0 to 20 p(nn)=0 blk(nn)=0 tn(nn)=0 next nn sc=0 sd=0 tek=0 ad=0 sg=0 tn=0 //randomize p(0)=int(ran(10)) p(1)=int(ran(10)) p(2)=int(ran(10)) p(3)=int(ran(10)) print p(0) //p(1)=0 //p(2)=2 p1=100*p(1)+10*p(2)+p(3) p(6)=int(ran(10)) p(5)=int(ran(10)) p(7)=int(ran(10)) //p(4)=2 //p(5)=7 p2=100*p(5)+10*p(6)+p(7) m1=int(ran(2)) if m1=0 then p3=p1+p2 mn=1 end if if m1=1 then if p1>p2 then p3=p1-p2 mn=2 end if if p1<=p2 then p3=p1+p2 mn=1 end if end if print "m1=",m1 p(9)=int(p3/1000) p(10)=int((p3-p(9)*1000)/100) p(11)=int((p3-p(10)*100-p(9)*1000)/10) p(12)=p3-1000*p(9)-100*p(10)-10*p(11) q(10)=p(10) q(1)=p(1) q(2)=p(2) q(3)=p(3) q(11)=p(11) q(5)=p(5) q(6)=p(6) q(7)=p(7) q(12)=p(12) q(9)=p(9) sm=0 sn=0 for i=1 to 12 if p(i)=0 sm=sm+6 if p(i)=1 sm=sm+2 if p(i)=2 sm=sm+5 if p(i)=3 sm=sm+5 if p(i)=4 sm=sm+4 if p(i)=5 sm=sm+5 if p(i)=6 sm=sm+6 if p(i)=7 sm=sm+3 if p(i)=8 sm=sm+7 if p(i)=9 sm=sm+6 next i if mn=1 sm=sm+2 if mn=2 sm=sm+1 //print p1,p2,p3 //print p(1),p(2),p(3)," ",p(5),p(6),p(7)," ", p(9),p(10),p(11),p(12) //end label take //st=0 sg=0 sc=sc+1 if sc>10 goto make// remake if go into a loop //jsk=ran(1) //jdh=ran(1) pot=int(ran(12))+1 //pot=5 if tn(pot)=1 goto take if pot=4 then if mn=1 then //sm=sm+2 mn=2 //goto add tek=tek+1 blk(pot)=1 else //sm=sm+1 goto take end if end if k=p(pot) print "tek=",tek, p1,p2,p3 print p(1),p(2),p(3)," ",p(5),p(6),p(7)," ",p(9),p(10),p(11),p(12) print "pot=", pot, " ", "k=", k, "sg=", sg, "st=", st switch k case 0 if pot=1: sg=1: break if pot=2 and p(1)=0:sg=1:break if pot=4: sg=1: break if pot=5: sg=1: break if pot=6 and p(5)=0: sg=1: break if pot=8:sg=1:break if pot=9: sg=1: break if pot=10 and p(9)=0:sg=1: break if pot=11 and p(9)=0 and p(10)=0:sg=1:break //st=1 w0=int(ran(5)) switch w0 case 0 if ad<2 then p(pot)=6 tek=tek+1 ad=ad+1 blk(pot)=1 end if break case 1 if ad<2 then p(pot)=9 tek=tek+1 ad=ad+1 blk(pot)=1 end if break case 2 if tek=0 then p(pot)=2 tek=tek+2 ad=ad+1 blk(pot)=1 end if break case 3 if tek=0 and ad<2 then p(pot)=3 tek=tek+2 ad=ad+1 blk(pot)=1 end if break case 4 if tek=0 and ad<2 then p(pot)=5 tek=tek+2 ad=ad+1 blk(pot)=1 end if break end switch if tek>0 tn(pot)=1 break case 1 p(pot)=1 //if tek=0 and (pot<>1 or pot<>5 or pot<>9) then //p(pot)=0 //sg=1 //tek=tek+2 //end if //st=1 break case 2 w0=int(ran(3)) switch w0 case 0 if ad<2 then p(pot)=3 tek=tek+1 ad=ad+1 end if break case 1 if pot=1:sg=1:break if pot=2 and p(1)=0:sg=1:break if pot=4: sg=1: break if pot=5:sg=1:break if pot=6 and p(5)=0:sg=1:break if pot=8:sg=1:break if pot=9:sg=1:break if pot=10 and p(9)=0:sg=1:break if pot=11 and p(9)=0 and p(10)=0:sg=1:break if tek=0 then p(pot)=0 tek=tek+1 ad=ad+2 end if break case 2 if tek=0 then p(pot)=5 tek=tek+2 ad=ad+2 end if break end switch if tek>0 tn(pot)=1 break case 3 //st=2 w3=int(ran(4)) switch w3 case 0 if ad<2 then p(pot)=2 tek=tek+1 ad=ad+1 blk(pot)=1 end if break case 1 if ad<2 then p(pot)=5 tek=tek+1 ad=ad+1 blk(pot)=1 end if break case 2 if tek=0 then p(pot)=6 tek=tek+1 ad=ad+2 endif break end switch if tek>0 tn(pot)=1 break case 4 w0=int(ran(4)) switch w0 case 0 if tek=0 then p(pot)=1 tek=tek+2 blk(pot)=1 end if break case 1 if ad<1 then p(pot)=3 tek=tek+1 ad=ad+2 end if break case 2 if ad<1 then p(pot)=5 tek=tek+1 ad=ad+2 end if break case 3 if tek=0 and ad<2 then p(pot)=7 tek=tek+2 ad=ad+1 end if //st=1 break end switch if tek>0 tn(pot)=1 break case 5 w0=int(ran(4)) switch w0 case 0 if ad<2 then p(pot)=3 tek=tek+1 ad=ad+1 blk(pot)=1 //st=2 end if break case 1 if tek=0 then p(pot)=2 tek=tek+2 ad=ad+2 end if break case 2 if tek=0 and ad<2 then p(pot)=4 tek=tek+2 ad=ad+1 end if break case 3 if pot=1:sg=1:break if pot=2 and p(1)=0:sg=1:break if pot=4: sg=1: break if pot=5:sg=1:break if pot=6 and p(5)=0:sg=1:break if pot=8:sg=1:break if pot=9:sg=1:break if pot=10 and p(9)=0:sg=1:break if pot=11 and p(9)=0 and p(10)=0:sg=1:break if tek=0 then p(pot)=0 tek=tek+1 ad=ad+2 end if break end switch if tek>0 tn(pot)=1 break case 6 w6=int(ran(5)) switch w6 case 0 if pot=1:sg=1:break if pot=2 and p(1)=0:sg=1:break if pot=4: sg=1: break if pot=5:sg=1:break if pot=6 and p(5)=0:sg=1:break if pot=8:sg=1:break if pot=9:sg=1:break if pot=10 and p(9)=0:sg=1:break if pot=11 and p(9)=0 and p(10)=0:sg=1:break if ad<2 then p(pot)=0 tek=tek+1 ad=ad+1 blk(pot)=1 end if break case 1 //st=2 if tek=0 and ad<2 then p(pot)=2 tek=tek+2 ad=ad+1 end if break case 2 if tek=0 and ad<2 then p(pot)=3 tek=tek+2 ad=ad+1 blk(pot)=1 end if break case 3 p(pot)=5 tek=tek+1 blk(pot)=1 break case 4 if ad<2 then p(pot)=9 tek=tek+1 ad=ad+1 blk(pot)=1 end if break end switch if tek>0 tn(pot)=1 break case 7 w0=int(ran(2)) switch w0 case 0 p(pot)=1 tek=tek+1 blk(pot)=1 break case 1 if tek=0 then p(pot)=4 tek=tek+1 ad=ad+2 end if break end switch if tek>0 tn(pot)=1 break case 8 w8=int(ran(6)) switch w8 case 0 if pot=1:sg=1:break if pot=2 and p(1)=0:sg=1:break if pot=4: sg=1: break if pot=5:sg=1:break if pot=6 and p(5)=0:sg=1:break if pot=8:sg=1:break if pot=9:sg=1:break if pot=10 and p(9)=0:sg=1:break if pot=11 and p(9)=0 and p(10)=0:sg=1:break p(pot)=0 tek=tek+1 blk(pot)=1 break case 1 p(pot)=6 tek=tek+1 blk(pot)=1 break case 2 if tek=0 then p(pot)=2 tek=tek+2 blk(pot)=1 end if break case 3 if tek=0 then p(pot)=3 tek=tek+2 blk(pot)=1 end if break case 4 if tek=0 then p(pot)=5 tek=tek+2 blk(pot)=1 end if break case 5 p(pot)=9 tek=tek+1 blk(pot)=1 break end switch if tek>0 tn(pot)=1 break case 9 w9=int(ran(6)) switch w9 case 0 if pot=1:sg=1:break if pot=2 and p(1)=0:sg=1:break if pot=4: sg=1: break if pot=5:sg=1:break if pot=6 and p(5)=0:sg=1:break if pot=8:sg=1:break if pot=9:sg=1:break if pot=10 and p(9)=0:sg=1:break if pot=11 and p(9)=0 and p(10)=0:sg=1:break if ad<2 then p(pot)=0 //st=2 tek=tek+1 ad=ad+1 blk(pot)=1 end if break case 1 if tek=0 and ad<2 then p(pot)=2 tek=tek+2 ad=ad+1 end if break case 2 p(pot)=3 tek=tek+1 blk(pot)=1 break case 3 if tek=0 then p(pot)=4 tek=tek+2 blk(pot)=1 end if break case 4 p(pot)=5 tek=tek+1 blk(pot)=1 break case 5 if ad<2 then p(pot)=6 tek=tek+1 ad=ad+1 blk(pot)=1 end if break end switch if tek>0 tn(pot)=1 break default break end switch //if sg=1 goto take //if st=1 goto take //if st=2 goto display if tek < 2 goto take //print "hello" if ad=2 goto display label add sv=0 sa=0 sd=sd+1 // break the loop if sd>10 then sd=0 goto make end if poa=int(ran(9))+1 //if poa=3 goto add if blk(poa)=1 goto add // not add if blocked if poa=4 then// if sign is minus, can add 1 to become plus if mn=2 and blk(4)=0 then mn=1 ad=ad+1 end if end if z=p(poa) print "z=",z switch z case 0 if poa=1:sv=1:break if poa=2 and p(1)=0:sv=1:break if poa=4:sv=1:break if poa=5:sv=1:break if poa=6 and p(5):sv=1:break if poa=8:sv=1:break if poa=9:sv=1:break if poa=10 and p(9)=0:sv=1:break if poa=11 and p(9) and p(10)=0:sv=1:break p(poa)=8 ad=ad+1 break case 1 w0=int(ran(2)) switch w0 case 0 p(poa)=7 ad=ad+1 break case 1 if ad=0 then p(poa)=4 ad=ad+1 end if break end switch break case 2 if ad=0 then p(poa)=8 ad=ad+2 end if break case 3 w0=int(ran(2)) switch w0 case 0 p(poa)=9 ad=ad+1 break case 1 if ad=0 then p(poa)=8 ad=ad+2 end if end switch break case 4 if ad=0 then p(poa)=9 ad=d+2 //sa=1 end if break case 5 ww5=int(ran(3)) switch ww5 case 0 p(poa)=6 ad=ad+1 break case 1 p(poa)=9 ad=ad+1 break case 2 if ad=0 then p(poa)=8 ad=ad+2 end if break end switch break case 6 p(poa)=8 ad=ad+1 break case 7 if ad=0 then p(poa)=3 ad=ad+2 end if //sa=1 break case 8 p(poa)=8 //sa=1 break case 9 p(poa)=8 ad=ad+1 break default break end switch //if sa=1 goto add if sv=1 goto add if ad<2 goto add //p1=p(1)+10*p(2) //p2=p(4)+10*p(5) //p3=p(6)*100+p(7)*10,p(8) //text 20,300, p3 //end label display print p1,p2, p3 p1=100*p(1)+10*p(2)+p(3) p2=100*p(5)+10*p(6)+p(7) p3=p(9)*1000+100*p(10)+10*p(11)+p(12) print p1, p2, p3 print pot, poa print "mn=",mn sn=0 for i=1 to 12 if p(i)=0 sn=sn+6 if p(i)=1 sn=sn+2 if p(i)=2 sn=sn+5 if p(i)=3 sn=sn+5 if p(i)=4 sn=sn+4 if p(i)=5 sn=sn+5 if p(i)=6 sn=sn+6 if p(i)=7 sn=sn+3 if p(i)=8 sn=sn+7 if p(i)=9 sn=sn+6 next i if mn=1 sn=sn+2 if mn=2 sn=sn+1 print "sn=",sn,"sm=",sm if sn<>sm then print "heloolele" goto make end if //end n=1 for n=1 to 12 print p(n) switch p(n) case 0 if n=1 then x=x-gap break end if if n=2 and p(1)=0 then x=x-gap break end if if n=4 then if mn=1 then gosub plus else gosub minus end if break end if if n=5 then x=x-gap break end if if n=6 and p(5)=0 then x=x-gap break end if if n=8 then gosub equal break end if if n=9 then x=x-gap break end if if n=10 and p(9)=0 then x=x-gap break end if if n=11 and p(9)=0 and p(10)=0 then x=x-gap break end if gosub zero break case 1 gosub one break case 2 gosub two break case 3 gosub three break case 4 gosub four break case 5 gosub five break case 6 gosub six break case 7 gosub seven break case 8 gosub eight break case 9 gosub nine break default break end switch x=x+gap next n end label zero line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert line 8+x,12,x+8,96 // left top vert rem line x+12,100,x+98,100 // central hor line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert line x+12,202,x+98,202 // bottom hor return label one rem line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert rem line X+8,12,x+8,96 // left top vert rem line x+12,100,x+98,100 // central hor rem line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert rem line x+12,202,x+98,202 // bottom hor return label two line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert rem line X+8,12,x+8,96 // left top vert line x+12,100,x+98,100 // central hor line x+8,104,x+8,198 // left bottom vert rem line x+102,104,x+102,198 // right bottom vert line x+12,202,x+98,202 // bottom hor return label three line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert rem line X+8,12,x+8,96 // left top vert line x+12,100,x+98,100 // central hor rem line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert line x+12,202,x+98,202 // bottom hor return label four rem line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert line 8+x,12,x+8,96 // left top vert line x+12,100,x+98,100 // central hor rem line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert rem line x+12,202,x+98,202 // bottom hor return label five line x+12,8,x+98,8 // top hor rem line x+102,12,x+102,96 // right top vert line 8+x,12,x+8,96 // left top vert line x+12,100,x+98,100 // central hor rem line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert line x+12,202,x+98,202 // bottom hor return label six line x+12,8,x+98,8 // top hor rem line x+102,12,x+102,96 // right top vert line 8+x,12,x+8,96 // left top vert line x+12,100,x+98,100 // central hor line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert line x+12,202,x+98,202 // bottom hor return label seven line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert rem line X+8,12,x+8,96 // left top vert rem line x+12,100,x+98,100 // central hor rem line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert rem line x+12,202,x+98,202 // bottom hor return label eight line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert line 8+x,12,x+8,96 // left top vert line x+12,100,x+98,100 // central hor line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert line x+12,202,x+98,202 // bottom hor return label nine line x+12,8,x+98,8 // top hor line x+102,12,x+102,96 // right top vert line 8+x,12,x+8,96 // left top vert line x+12,100,x+98,100 // central hor rem line x+8,104,x+8,198 // left bottom vert line x+102,104,x+102,198 // right bottom vert line x+12,202,x+98,202 // bottom hor return label plus line x+12,100,x+98,100 line x+50,52,x+50,148 return label equal line x+12,120,x+98,120 line x+12,80,x+98,80 return label minus line x+12,100, x+98, 100 return