1000 rem heap's permutation algorithm 1010 rem micheal h. mccabe 1020 rem december 17, 2020 1030 dim a$(15) 1040 print 1050 print "TEXT PERMUTATIONS:" 1060 print 1070 input "ENTER WORD: ";w$ 1080 print 1090 let n = len(w$) 1100 for i = 1 to n 1110 a$(i-1) = mid$(w$,i,1) 1120 next i 1130 dim c(15) 1140 rem 1150 let i = 0 1160 gosub 1350 1170 if i >= n then 1340 1180 if c(i) >= i then 1310 1190 if int(i/2) <> (i/2) then 1240 1200 t$ = a$(0) 1210 a$(0) = a$(i) 1220 a$(i) = t$ 1230 goto 1270 1240 t$ = a$(c(i)) 1250 a$(c(i)) = a$(i) 1260 a$(i) = t$ 1270 gosub 1350 1280 c(i) = c(i)+1 1290 i = 0 1300 goto 1330 1310 c(i) = 0 1320 i = i+1 1330 goto 1170 1340 print : print "end program." : end 1350 let lc = lc+1 1360 print lc;": "; 1370 for j = 0 to n-1 : print a$(j); : next j : print : return