Towers of Hanoi: Difference between revisions

Content added Content deleted
Line 411: Line 411:
{{works with|Commodore BASIC}}
{{works with|Commodore BASIC}}
Very fast version in BASIC V2 on Commodore C-64
Very fast version in BASIC V2 on Commodore C-64
<lang gwbasic> 10 def fnm(x)=x-int(x/3)*3:rem modulo
<lang gwbasic>10 def fnm(x)=x-int(x/3)*3:rem modulo
20 n=4
20 n=8:gosub 100
30 gosub 100
30 end
40 end
100 rem hanoi
100 rem hanoi
110 for m=1 to 2^n-1
110 :for m=1 to 2^n-1
120 :print m;":",fnm(m and m-1)+1;" to ";fnm((m or m-1)+1)+1
120 ::print m;":",fnm(m and m-1)+1;" to ";fnm((m or m-1)+1)+1
130 next
130 :next
140 return</lang>
140 return</lang>
{{out}}
{{out}}