Home » CEEFAX disks » telesoftware17.adl » 25-08-89/SortSee

25-08-89/SortSee

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » CEEFAX disks » telesoftware17.adl
Filename: 25-08-89/SortSee
Read OK:
File size: 210A bytes
Load address: FFFF0E00
Exec address: FFFF802B
File contents
   10REM:SortSee by L.L.J.Vick (22/2/89)
   20C=246:DIMA% C,Q% C,P% C,C% 7,time%(9),M$(9),O$(6)
   30ONERROR:REPORT:PRINT" at line ";ERL:PROCquit:END
   40S$=" Sort":FORI=1TO6:READO$(I):NEXT
   50*KEY0RUN|M
   60REPEAT:MODE7:PROCinit
   70FORmthd=first TOlast
   80FORI%=0TON%:Q%?I%=I%:NEXT:delay=2E3
   90MODE4:PROCdisplay:*FX11,1
  100PROChalt:TIME=0:*FX12,1
  110IFspeed=1:PROCslow:ELSE:PROCfast
  120time%(mthd)=TIME
  130MOVE400,100:PRINT"Time taken = "FNtime:*FX12,0
  140PROChalt:PROCcont:NEXT
  150IFlast>first:PROCresults
  160UNTILFALSE
  170:
  180DEFPROCslow
  190IFmthd=1:PROCbubble
  200IFmthd=2:PROCbubble_flag
  210IFmthd=3:PROCbubble_monitor
  220IFmthd=4:PROCshaker
  230IFmthd=5:PROCstr_insertion
  240IFmthd=6:PROCbin_insertion
  250IFmthd=7:PROCselection
  260ENDPROC
  270:
  280DEFPROCfast
  290IFmthd=1:PROCshell(2)
  300IFmthd=2:PROCshell(3)
  310IFmthd=3:PROCquick
  320IFmthd=4:PROCquick_nr
  330IFmthd=5:PROCquickinsert
  340IFmthd=6:PROCheap
  350IFmthd=7:PROCradix
  360IFmthd=8:PROCstr_rad(2)
  370IFmthd=9:PROCmerge(1,N%)
  380ENDPROC
  390:
  400DATAPerfect,Near-Perfect,Reverse,Random,Well distributed,With many equal
  410DATA7,Bubble,Bubble (with Flag),Bubble (with Monitor),Shaker,Straight Insertion,Binary Insertion,Selection
  420DATA9,Shell(2),Shell(3),Quick (recursive),Quick (non-recursive),Quick/Insertion,Heap,Radix Exchange,Straight Radix,Merge
  430:
  440DEFPROCinit
  450FORI=0TO1:PRINTTAB(3,I)CHR$141"SORTING ALGORITHMS ON DISPLAY":NEXT
  460@%=&606:VDU28,1,24,39,2
  470REPEAT:CLS:PRINTTAB(2,9)"Choose a number, less than "STR$(C+1)"."
  480PRINTTAB(0,20)"Press H (RETURN) for Help & Information";
  490INPUTTAB(13,11)"N = "n$:IFLENn$<5:N%=VALn$:ELSE:N%=0:VDU7
  500IFn$="H"ORn$="h":S%=1:VDU7:CHAIN"T/Sorts"
  510UNTILN%>1ANDN%<=C
  520N$="The original Number Sequence ":n$=STR$(N%):CLS
  530P$="a Permutation of 1 to ":R$="a Random set "
  540PRINT'N$"consists"''"of a set of integers which can be:-"'
  550PRINT"EITHER "P$n$'
  560FORI=1TO4:PRINTI"...In "O$(I)" order"':NEXT
  570PRINT"OR "R$"in this range"'
  580FORI=5TO6:PRINTI"..."O$(I)':NEXT
  590REPEAT:PRINTTAB(5,21)"Choose (1 to 6) :";:O%=GET-48:UNTILO%>0ANDO%<7
  600PRINTTAB(24,21)STR$(O%)" wait!";
  610FORI%=0TON%:A%?I%=I%:NEXT
  620I=RND(-N%)
  630IFO%=2:PROCnear
  640IFO%=3:PROCrev
  650IFO%=4:PROCperm
  660IFO%=5:PROCrandom
  670IFO%=6:PROCequal_keys
  680X%=240:Y%=4:VDU23,X%,128,0,0,0,0,0,0,0
  690IFN%<124:Y%=8:VDU23,X%,192,192,0,0,0,0,0,0
  700IFN%<62:Y%=16:VDU23,X%,X%,X%,X%,X%,0,0,0,0
  710IFN%<31:I=255:Y%=32:VDU23,X%,I,I,I,I,I,I,I,I
  720CLS:PRINTTAB(0,9)"Do you want the 'slow' or the 'fast'"''TAB(8)"methods? (S/F) :";
  730speed=FNin("SF")
  740CLS:IFspeed=1:RESTORE410:ELSERESTORE420
  750READmethods:FORI=1TOmethods:READM$(I):PRINT'I"..."M$(I)S$:NEXT
  760REPEAT:PRINTTAB(0,21)"Choose an Algorithm (A for All) : ";
  770I=INSTR(LEFT$("123456789",methods)+"Aa",GET$):UNTILI
  780first=I:last=I:IFI>methods:first=1:last=methods
  790ENDPROC
  800:
  810DEFPROCperm
  820FORI%=1TON%:J%=RND(N%)
  830T%=A%?J%:A%?J%=A%?I%:A%?I%=T%
  840NEXT
  850ENDPROC
  860:
  870DEFPROCnear
  880L%=3:IFN%<8:L%=N%DIV4+1
  890FORI%=L%TON%-L%:J%=RND(L%*2)+I%-L%
  900T%=A%?J%:A%?J%=A%?I%:A%?I%=T%
  910NEXT
  920ENDPROC
  930:
  940DEFPROCrev
  950FORI%=1TON%
  960A%?I%=N%+1-I%
  970NEXT
  980ENDPROC
  990:
 1000DEFPROCrandom
 1010FORI%=1TON%
 1020A%?I%=RND(N%)
 1030NEXT
 1040ENDPROC
 1050:
 1060DEFPROCequal_keys
 1070K%=LN(N%+1):T%=N%DIVK%
 1080FORI%=1TOT%:Q%?I%=RND(T%):NEXT
 1090FORI%=1TON%
 1100A%?I%=(Q%?(RND(T%)))*K%
 1110NEXT
 1120ENDPROC
 1130:
 1140DEFPROCdisplay
 1150VDU26,12,16,5,29,0;32;:I=Y%-4
 1160MOVEI,0:DRAW1279,0:DRAW1279,991:DRAWI,991:DRAWI,0:MOVE64,955
 1170PRINTM$(mthd)S$''"  "n$" numbers"
 1180GCOL4,1
 1190FORI%=1TON%
 1200MOVEY%*I%,A%?I%*Y%:VDUX%
 1210NEXT
 1220ENDPROC
 1230:
 1240DEFPROCswap(U%,V%):IFU%=V%ENDPROC
 1250PROCshift(U%,V%,Q%?U%)
 1260PROCshift(V%,U%,Q%?V%)
 1270T%=Q%?V%:Q%?V%=Q%?U%:Q%?U%=T%
 1280ENDPROC
 1290:
 1300DEFPROCshift(U%,V%,D%)
 1310Z%=Y%*A%?D%:MOVEY%*U%,Z%:VDUX%
 1320MOVEY%*V%,Z%:VDUX%
 1330REPEAT:I=INKEY(2):UNTILI<>32
 1340ENDPROC
 1350:
 1360DEFPROCbubble
 1370FORI%=N%TO2STEP-1
 1380FORJ%=1TOI%-1
 1390IFA%?(Q%?J%)>A%?(Q%?(J%+1)):PROCswap(J%,J%+1)
 1400NEXT,
 1410ENDPROC
 1420:
 1430DEFPROCbubble_flag
 1440I%=N%:REPEAT:F%=TRUE
 1450FORJ%=1TOI%-1:IFA%?(Q%?J%)>A%?(Q%?(J%+1)):PROCswap(J%,J%+1):F%=FALSE
 1460NEXT:I%=I%-1
 1470UNTILF%
 1480ENDPROC
 1490:
 1500DEFPROCbubble_monitor
 1510I%=N%-1:REPEAT:F%=1
 1520FORJ%=1TOI%:IFA%?(Q%?J%)>A%?(Q%?(J%+1)):PROCswap(J%,J%+1):F%=J%
 1530NEXT:I%=F%-1
 1540UNTILF%=1
 1550ENDPROC
 1560:
 1570DEFPROCshaker
 1580L%=2:R%=N%:K%=N%
 1590REPEAT
 1600FORJ%=R%TOL%STEP-1
 1610IFA%?(Q%?(J%-1))>A%?(Q%?J%):PROCswap(J%-1,J%):K%=J%
 1620NEXT:L%=K%+1
 1630FORJ%=L%TOR%
 1640IFA%?(Q%?(J%-1))>A%?(Q%?J%):PROCswap(J%-1,J%):K%=J%
 1650NEXT:R%=K%-1
 1660UNTILL%>R%
 1670ENDPROC
 1680:
 1690DEFPROCstr_insertion:PROCinsert(1,N%):ENDPROC
 1700:
 1710DEFPROCinsert(L%,R%)
 1720FORI%=L%+1TOR%:W%=Q%?I%:J%=I%:F%=FALSE
 1730REPEAT
 1740IFA%?(Q%?(J%-1))>A%?W%:J%=J%-1:PROCshift(J%,J%+1,Q%?J%):Q%?(J%+1)=Q%?J%:ELSEF%=TRUE
 1750UNTILF%
 1760IFJ%<I%:PROCshift(I%,J%,W%):Q%?J%=W%
 1770NEXT
 1780ENDPROC
 1790:
 1800DEFPROCbin_insertion
 1810FORI%=2TON%:W%=Q%?I%:L%=1:R%=I%-1
 1820REPEAT
 1830M%=(L%+R%)DIV2:IFA%?(Q%?M%)>A%?W%:R%=M%-1:ELSE:L%=M%+1
 1840UNTILL%>R%
 1850IFL%<I%:FORJ%=I%-1TOL%STEP-1:PROCshift(J%,J%+1,Q%?J%):Q%?(J%+1)=Q%?J%:NEXT:PROCshift(I%,L%,W%):Q%?L%=W%
 1860NEXT
 1870ENDPROC
 1880:
 1890DEFPROCselection
 1900FORI%=1TON%-1:M%=I%
 1910FORJ%=(I%+1)TON%:IFA%?(Q%?J%)<A%?(Q%?M%):M%=J%
 1920NEXT:PROCswap(I%,M%)
 1930NEXT
 1940ENDPROC
 1950:
 1960DEFPROCshell(G%)
 1970H%=1:REPEAT:H%=G%*H%+1:UNTILH%>N%
 1980REPEAT:H%=H%DIVG%
 1990FORI%=(H%+1)TON%:W%=Q%?I%:J%=I%:F%=FALSE
 2000REPEAT
 2010IFA%?(Q%?(J%-H%))>A%?W%:J%=J%-H%:PROCshift(J%,J%+H%,Q%?J%):Q%?(J%+H%)=Q%?J%:ELSE:F%=TRUE
 2020UNTILF%ORJ%<=H%
 2030IFJ%<I%:PROCshift(I%,J%,W%):Q%?J%=W%
 2040NEXT
 2050IFH%>1:time%=TIME:PROCss:PROCcont:PROCss:TIME=time%
 2060UNTILH%=1
 2070ENDPROC
 2080:
 2090DEFPROCss:PROChalt:MOVE700,100:PRINT"Now "STR$(H%)"-sorted.";:ENDPROC
 2100:
 2110DEFPROCquick:G%=LN(N%)+3:PROCsort(1,N%):ENDPROC
 2120:
 2130REM:Quicksort : recursive
 2140DEFPROCsort(L%,R%)
 2150LOCALI%,J%
 2160IFR%-L%<G%:PROCinsert(L%,R%):ENDPROC
 2170PROCmedian
 2180W%=A%?(Q%?M%):I%=L%:J%=R%
 2190REPEAT
 2200REPEAT:I%=I%+1:UNTILA%?(Q%?I%)>=W%
 2210REPEAT:J%=J%-1:UNTILA%?(Q%?J%)<=W%
 2220IFI%<J%:PROCswap(J%,I%)
 2230UNTILJ%<I%
 2240IF(R%-I%)>(J%-L%):PROCsort(L%,J%):PROCsort(I%,R%):ELSE:PROCsort(I%,R%):PROCsort(L%,J%)
 2250ENDPROC
 2260:
 2270DEFPROCmedian
 2280IFA%?(Q%?L%)>A%?(Q%?R%):PROCswap(L%,R%)
 2290M%=(L%+R%)DIV2
 2300IFA%?(Q%?M%)>A%?(Q%?R%):PROCswap(M%,R%)
 2310IFA%?(Q%?L%)>A%?(Q%?M%):PROCswap(L%,M%)
 2320ENDPROC
 2330:
 2340DEFPROCquick_nr
 2350G%=LN(N%)+3:L%=1:R%=N%:S%=2
 2360REPEAT
 2370IFR%>L%:PROCnr_sort:ELSE:S%=S%-2:L%=P%?S%:R%=P%?(S%+1)
 2380UNTILS%<2
 2390ENDPROC
 2400:
 2410DEFPROCnr_sort
 2420IFR%-L%<G%:PROCinsert(L%,R%):R%=L%:ENDPROC
 2430PROCmedian
 2440W%=A%?(Q%?M%):I%=L%:J%=R%
 2450REPEAT
 2460REPEAT:I%=I%+1:UNTILA%?(Q%?I%)>=W%
 2470REPEAT:J%=J%-1:UNTILA%?(Q%?J%)<=W%
 2480IFI%<J%:PROCswap(J%,I%)
 2490UNTILJ%<I%
 2500IF(R%-I%)>(J%-L%):P%?S%=I%:P%?(S%+1)=R%:R%=J%:ELSE:P%?S%=L%:P%?(S%+1)=J%:L%=I%
 2510S%=S%+2
 2520ENDPROC
 2530:
 2540DEFPROCquickinsert
 2550G%=LN(N%)+3:L%=1:R%=N%:S%=2
 2560REPEAT
 2570IFR%>L%+G%:PROCsed_sort:ELSE:S%=S%-2:L%=P%?S%:R%=P%?(S%+1)
 2580UNTILS%<2
 2590time%=TIME:PROCis:PROCcont:PROCis:TIME=time%
 2600PROCstr_insertion
 2610ENDPROC
 2620:
 2630REM:Quicksort a la Sedgewick : non-recursive
 2640DEFPROCsed_sort
 2650PROCmedian
 2660I%=L%:J%=R%-1:PROCswap(M%,J%):W%=A%?(Q%?J%)
 2670REPEAT
 2680REPEAT:I%=I%+1:UNTILA%?(Q%?I%)>=W%
 2690REPEAT:J%=J%-1:UNTILA%?(Q%?J%)<=W%
 2700IFI%<J%:PROCswap(J%,I%)
 2710UNTILJ%<I%:PROCswap(I%,R%-1)
 2720IF(R%-I%)>(J%-L%):P%?S%=I%+1:P%?(S%+1)=R%:R%=I%-1:ELSE:P%?S%=L%:P%?(S%+1)=I%-1:L%=I%+1
 2730S%=S%+2
 2740ENDPROC
 2750:
 2760DEFPROCis
 2770PROChalt:MOVE500,100
 2780PRINT"Now for Insertion sort.";
 2790ENDPROC
 2800:
 2810DEFPROCheap
 2820M%=N%
 2830FORL%=N%DIV2TO1STEP-1:PROCdownheap(L%):NEXT
 2840time%=TIME:PROChf:PROCcont:PROChf:TIME=time%
 2850REPEAT
 2860PROCswap(1,M%):M%=M%-1:IFM%>1:PROCdownheap(1)
 2870UNTILM%=1
 2880ENDPROC
 2890:
 2900DEFPROCdownheap(K%)
 2910W%=Q%?K%:L%=K%:G%=M%DIV2:F%=FALSE
 2920REPEAT
 2930J%=K%+K%:IFJ%<M%:IFA%?(Q%?J%)<A%?(Q%?(J%+1)):J%=J%+1
 2940IFA%?W%>=A%?(Q%?J%):F%=TRUE:ELSE:PROCshift(J%,K%,Q%?J%):Q%?K%=Q%?J%:K%=J%
 2950UNTILF%ORK%>G%:IFK%>L%:PROCshift(L%,K%,W%):Q%?K%=W%
 2960ENDPROC
 2970:
 2980DEFPROChf
 2990PROChalt:MOVE500,900
 3000PRINT"Heap now formed.";
 3010ENDPROC
 3020:
 3030DEFPROCradix
 3040M%=2:REPEAT:M%=M%*2:UNTILM%>N%
 3050PROCrad(1,N%,M%)
 3060ENDPROC
 3070DEFPROCrad(L%,R%,B%)
 3080IFR%<=L%:ENDPROC
 3090LOCALI%,J%:I%=L%:J%=R%
 3100REPEAT
 3110F%=FALSE:REPEAT:IF(((A%?(Q%?I%))DIVB%)AND1)=0:IFI%<J%:I%=I%+1:ELSE:F%=TRUE
 3120UNTILF%
 3130F%=FALSE:REPEAT:IF(((A%?(Q%?J%))DIVB%)AND1):IFI%<J%:J%=J%-1:ELSE:F%=TRUE
 3140UNTILF%:PROCswap(I%,J%)
 3150UNTILJ%=I%:IF((A%?(Q%?R%)DIVB%)AND1)=0:J%=J%+1
 3160IFB%>1:B%=B%DIV2:PROCrad(L%,J%-1,B%):PROCrad(J%,R%,B%)
 3170ENDPROC
 3180:
 3190DEFPROCstr_rad(G%)
 3200M%=2^G%-1:G%=1
 3210REPEAT:FORJ%=0TOM%:C%?J%=0:NEXT
 3220FORI%=1TON%:J%=((A%?(Q%?I%))DIVG%)ANDM%:C%?J%=C%?J%+1:NEXT
 3230FORJ%=1TOM%:C%?J%=C%?(J%-1)+C%?J%:NEXT
 3240FORI%=N%TO1STEP-1:J%=((A%?(Q%?I%))DIVG%)ANDM%
 3250P%?(C%?J%)=Q%?I%:PROCshift(I%,C%?J%,Q%?I%):C%?J%=C%?J%-1:NEXT
 3260T%=Q%:Q%=P%:P%=T%:G%=(M%+1)*G%
 3270UNTILG%>N%
 3280ENDPROC
 3290REM:Above only possible with Indirection Operators
 3300FORI%=1TON%:Q%?I%=P%?I%:NEXT:G%=G%*(M%+1):UNTILG%>N%:ENDPROC
 3310:
 3320DEFPROCmerge(L%,R%):LOCALM%
 3330M%=(R%+L%)DIV2
 3340IFM%>L%:PROCmerge(L%,M%)
 3350IFM%+1<R%:PROCmerge(M%+1,R%)
 3360FORI%=L%TOM%:P%?I%=Q%?I%:NEXT:I%=L%
 3370T%=R%+M%+1:FORJ%=M%+1TOR%:P%?(T%-J%)=Q%?J%:PROCshift(J%,T%-J%,Q%?J%):NEXT:J%=R%
 3380FORK%=L%TOR%
 3390IFA%?(P%?I%)<A%?(P%?J%):Q%?K%=P%?I%:PROCshift(I%,K%,P%?I%):I%=I%+1:ELSE:Q%?K%=P%?J%:PROCshift(J%,K%,P%?J%):J%=J%-1
 3400NEXT
 3410ENDPROC
 3420:
 3430DEFPROCcont
 3440TIME=0:J=FALSE:*FX21,0
 3450REPEAT:J=NOTJ:PROCmes:I=INKEY(99):UNTILI=32ORTIME>delay
 3460IFJ:PROCmes
 3470ENDPROC
 3480:
 3490DEFPROCmes:MOVE96,-8
 3500PRINT"Press Spacebar to continue.";
 3510ENDPROC
 3520:
 3530DEFPROChalt:MOVE96,-8
 3540PRINT"Press Spacebar to Halt calculation.";
 3550ENDPROC
 3560:
 3570DEFPROCresults
 3580delay=2E5:print=FALSE:CLS:*FX12,0
 3590REPEAT
 3600IFprint:PRINT:VDU2,21,16:*FX21,0
 3610PRINT"  METHOD"SPC22;"TIME"
 3620FORmthd=first TOlast:T$=FNtime:PRINT'M$(mthd)S$TAB(36-LENT$)T$:NEXT
 3630PRINT''N$"was"'
 3640IFO%<5:PRINTP$n$" in"''O$(O%)" order.":ELSE:PRINTR$"between 1 and "n$''"- "O$(O%)"."
 3650PRINT:IFprint:VDU6,3:print=FALSE:ELSE:PRINT"Do you want a Printout (Y/N)? ";:print=1-FNin("NY")
 3660IFprint:INPUT'"Left margin (0-43) : "I:VDU2,1,27,1,108,1,I,3
 3670UNTILNOTprint
 3680VDU5:PROCcont
 3690ENDPROC
 3700:
 3710DEFFNin(d$):REPEAT:I=INSTR(d$,CHR$(GETAND&DF)):UNTILI:=I
 3720:
 3730DEFFNtime:=STR$(10*time%(mthd))+" ms"
 3740:
 3750DEFPROCquit:@%=10:VDU3:*FX12,0
 3760PRINT'"Press f0 to run again.";
 3770ENDPROC
 3780ENDIF"SortSee"

%�:SortSee by L.L.J.Vick (22/2/89)
3C=246:�A% C,Q% C,P% C,C% 7,time%(9),M$(9),O$(6)
�:�:�" at line ";�:�quit:�
(S$=" Sort":�I=1�6:�O$(I):�
2*KEY0RUN|M
<�:�7:�init
F�mthd=first �last
P!�I%=0�N%:Q%?I%=I%:�:delay=2E3
Z�4:�display:*FX11,1
d�halt:�=0:*FX12,1
n�speed=1:�slow:�:�fast
xtime%(mthd)=�
�*�400,100:�"Time taken = "�time:*FX12,0
��halt:�cont:�
��last>first:�results
���
�:
�
��slow
��mthd=1:�bubble
��mthd=2:�bubble_flag
��mthd=3:�bubble_monitor
��mthd=4:�shaker
��mthd=5:�str_insertion
��mthd=6:�bin_insertion
��mthd=7:�selection
�
:

��fast
"�mthd=1:�shell(2)
,�mthd=2:�shell(3)
6�mthd=3:�quick
@�mthd=4:�quick_nr
J�mthd=5:�quickinsert
T�mthd=6:�heap
^�mthd=7:�radix
h�mthd=8:�str_rad(2)
r�mthd=9:�merge(1,N%)
|�
�:
�I�Perfect,Near-Perfect,Reverse,Random,Well distributed,With many equal
�k�7,Bubble,Bubble (with Flag),Bubble (with Monitor),Shaker,Straight Insertion,Binary Insertion,Selection
�y�9,Shell(2),Shell(3),Quick (recursive),Quick (non-recursive),Quick/Insertion,Heap,Radix Exchange,Straight Radix,Merge
�:
�
��init
�6�I=0�1:�3,I)�141"SORTING ALGORITHMS ON DISPLAY":�
�@%=&606:�28,1,24,39,2
�4�:�:�2,9)"Choose a number, less than "�(C+1)"."
�5�0,20)"Press H (RETURN) for Help & Information";
�,�13,11)"N = "n$:�n$<5:N%=�n$:�:N%=0:�7
�%�n$="H"�n$="h":S%=1:�7:�"T/Sorts"
��N%>1�N%<=C
1N$="The original Number Sequence ":n$=�(N%):�
2P$="a Permutation of 1 to ":R$="a Random set "
:�'N$"consists"''"of a set of integers which can be:-"'
&�"EITHER "P$n$'
0%�I=1�4:�I"...In "O$(I)" order"':�
:�"OR "R$"in this range"'
D�I=5�6:�I"..."O$(I)':�
N4�:�5,21)"Choose (1 to 6) :";:O%=�-48:�O%>0�O%<7
X�24,21)�(O%)" wait!";
b�I%=0�N%:A%?I%=I%:�
lI=�(-N%)
v�O%=2:�near
��O%=3:�rev
��O%=4:�perm
��O%=5:�random
��O%=6:�equal_keys
�(X%=240:Y%=4:�23,X%,128,0,0,0,0,0,0,0
�+�N%<124:Y%=8:�23,X%,192,192,0,0,0,0,0,0
�+�N%<62:Y%=16:�23,X%,X%,X%,X%,X%,0,0,0,0
�-�N%<31:I=255:Y%=32:�23,X%,I,I,I,I,I,I,I,I
�J�:�0,9)"Do you want the 'slow' or the 'fast'"''�8)"methods? (S/F) :";
�speed=�in("SF")
��:�speed=1:��tZA:���tdA
�2�methods:�I=1�methods:�M$(I):�'I"..."M$(I)S$:�
�2�:�0,21)"Choose an Algorithm (A for All) : ";
'I=��"123456789",methods)+"Aa",�):�I
2first=I:last=I:�I>methods:first=1:last=methods
�
 :
*
��perm
4�I%=1�N%:J%=�(N%)
>!T%=A%?J%:A%?J%=A%?I%:A%?I%=T%
H�
R�
\:
f
��near
pL%=3:�N%<8:L%=N%�4+1
z!�I%=L%�N%-L%:J%=�(L%*2)+I%-L%
�!T%=A%?J%:A%?J%=A%?I%:A%?I%=T%
��
��
�:
�	��rev
��I%=1�N%
�A%?I%=N%+1-I%
��
��
�:
���random
��I%=1�N%
�A%?I%=�(N%)
�
�
:
$��equal_keys
.K%=�(N%+1):T%=N%�K%
8�I%=1�T%:Q%?I%=�(T%):�
B�I%=1�N%
LA%?I%=(Q%?(�(T%)))*K%
V�
`�
j:
t
��display
~�26,12,16,5,29,0;32;:I=Y%-4
�.�I,0:�1279,0:�1279,991:�I,991:�I,0:�64,955
�!�M$(mthd)S$''"  "n$" numbers"
��4,1
��I%=1�N%
��Y%*I%,A%?I%*Y%:�X%
��
��
�:
���swap(U%,V%):�U%=V%�
��shift(U%,V%,Q%?U%)
��shift(V%,U%,Q%?V%)
�!T%=Q%?V%:Q%?V%=Q%?U%:Q%?U%=T%
�

:
��shift(U%,V%,D%)
Z%=Y%*A%?D%:�Y%*U%,Z%:�X%
(�Y%*V%,Z%:�X%
2�:I=�(2):�I<>32
<�
F:
P��bubble
Z�I%=N%�2�-1
d�J%=1�I%-1
n-�A%?(Q%?J%)>A%?(Q%?(J%+1)):�swap(J%,J%+1)
x�,
��
�:
���bubble_flag
�I%=N%:�:F%=�
�=�J%=1�I%-1:�A%?(Q%?J%)>A%?(Q%?(J%+1)):�swap(J%,J%+1):F%=�
�
�:I%=I%-1
��F%
��
�:
���bubble_monitor
�I%=N%-1:�:F%=1
�<�J%=1�I%:�A%?(Q%?J%)>A%?(Q%?(J%+1)):�swap(J%,J%+1):F%=J%
�
�:I%=F%-1
	�F%=1
�
:
"��shaker
,L%=2:R%=N%:K%=N%
6�
@�J%=R%�L%�-1
J3�A%?(Q%?(J%-1))>A%?(Q%?J%):�swap(J%-1,J%):K%=J%
T
�:L%=K%+1
^
�J%=L%�R%
h3�A%?(Q%?(J%-1))>A%?(Q%?J%):�swap(J%-1,J%):K%=J%
r
�:R%=K%-1
|
�L%>R%
��
�:
�#��str_insertion:�insert(1,N%):�
�:
���insert(L%,R%)
�#�I%=L%+1�R%:W%=Q%?I%:J%=I%:F%=�
��
�M�A%?(Q%?(J%-1))>A%?W%:J%=J%-1:�shift(J%,J%+1,Q%?J%):Q%?(J%+1)=Q%?J%:�F%=�
��F%
�$�J%<I%:�shift(I%,J%,W%):Q%?J%=W%
��
��
�:
��bin_insertion
"�I%=2�N%:W%=Q%?I%:L%=1:R%=I%-1
�
&4M%=(L%+R%)�2:�A%?(Q%?M%)>A%?W%:R%=M%-1:�:L%=M%+1
0
�L%>R%
:[�L%<I%:�J%=I%-1�L%�-1:�shift(J%,J%+1,Q%?J%):Q%?(J%+1)=Q%?J%:�:�shift(I%,L%,W%):Q%?L%=W%
D�
N�
X:
b��selection
l�I%=1�N%-1:M%=I%
v.�J%=(I%+1)�N%:�A%?(Q%?J%)<A%?(Q%?M%):M%=J%
��:�swap(I%,M%)
��
��
�:
���shell(G%)
�H%=1:�:H%=G%*H%+1:�H%>N%
��:H%=H%�G%
�%�I%=(H%+1)�N%:W%=Q%?I%:J%=I%:F%=�
��
�R�A%?(Q%?(J%-H%))>A%?W%:J%=J%-H%:�shift(J%,J%+H%,Q%?J%):Q%?(J%+H%)=Q%?J%:�:F%=�
��F%�J%<=H%
�$�J%<I%:�shift(I%,J%,W%):Q%?J%=W%
��
'�H%>1:time%=�:�ss:�cont:�ss:�=time%
	�H%=1
�
 :
*1��ss:�halt:�700,100:�"Now "�(H%)"-sorted.";:�
4:
>$��quick:G%=�(N%)+3:�sort(1,N%):�
H:
R�:Quicksort : recursive
\��sort(L%,R%)
f
�I%,J%
p�R%-L%<G%:�insert(L%,R%):�
z�median
�W%=A%?(Q%?M%):I%=L%:J%=R%
��
��:I%=I%+1:�A%?(Q%?I%)>=W%
��:J%=J%-1:�A%?(Q%?J%)<=W%
��I%<J%:�swap(J%,I%)
�
�J%<I%
�J�(R%-I%)>(J%-L%):�sort(L%,J%):�sort(I%,R%):�:�sort(I%,R%):�sort(L%,J%)
��
�:
���median
�'�A%?(Q%?L%)>A%?(Q%?R%):�swap(L%,R%)
�M%=(L%+R%)�2
�'�A%?(Q%?M%)>A%?(Q%?R%):�swap(M%,R%)
	'�A%?(Q%?L%)>A%?(Q%?M%):�swap(L%,M%)
	�
	:
	$��quick_nr
	.G%=�(N%)+3:L%=1:R%=N%:S%=2
	8�
	B3�R%>L%:�nr_sort:�:S%=S%-2:L%=P%?S%:R%=P%?(S%+1)
	L	�S%<2
	V�
	`:
	j
��nr_sort
	t$�R%-L%<G%:�insert(L%,R%):R%=L%:�
	~�median
	�W%=A%?(Q%?M%):I%=L%:J%=R%
	��
	��:I%=I%+1:�A%?(Q%?I%)>=W%
	��:J%=J%-1:�A%?(Q%?J%)<=W%
	��I%<J%:�swap(J%,I%)
	�
�J%<I%
	�N�(R%-I%)>(J%-L%):P%?S%=I%:P%?(S%+1)=R%:R%=J%:�:P%?S%=L%:P%?(S%+1)=J%:L%=I%
	�S%=S%+2
	��
	�:
	���quickinsert
	�G%=�(N%)+3:L%=1:R%=N%:S%=2
�

7�R%>L%+G%:�sed_sort:�:S%=S%-2:L%=P%?S%:R%=P%?(S%+1)
	�S%<2
!time%=�:�is:�cont:�is:�=time%
(�str_insertion
2�
<:
F.�:Quicksort a la Sedgewick : non-recursive
P��sed_sort
Z�median
d,I%=L%:J%=R%-1:�swap(M%,J%):W%=A%?(Q%?J%)
n�
x�:I%=I%+1:�A%?(Q%?I%)>=W%
��:J%=J%-1:�A%?(Q%?J%)<=W%
��I%<J%:�swap(J%,I%)
��J%<I%:�swap(I%,R%-1)
�V�(R%-I%)>(J%-L%):P%?S%=I%+1:P%?(S%+1)=R%:R%=I%-1:�:P%?S%=L%:P%?(S%+1)=I%-1:L%=I%+1
�S%=S%+2
��
�:
���is
��halt:�500,100
��"Now for Insertion sort.";
��
�:
�
��heap
	M%=N%
!�L%=N%�2�1�-1:�downheap(L%):�
!time%=�:�hf:�cont:�hf:�=time%
"�
,*�swap(1,M%):M%=M%-1:�M%>1:�downheap(1)
6	�M%=1
@�
J:
T��downheap(K%)
^W%=Q%?K%:L%=K%:G%=M%�2:F%=�
h�
r6J%=K%+K%:�J%<M%:�A%?(Q%?J%)<A%?(Q%?(J%+1)):J%=J%+1
|C�A%?W%>=A%?(Q%?J%):F%=�:�:�shift(J%,K%,Q%?J%):Q%?K%=Q%?J%:K%=J%
�.�F%�K%>G%:�K%>L%:�shift(L%,K%,W%):Q%?K%=W%
��
�:
���hf
��halt:�500,900
��"Heap now formed.";
��
�:
���radix
�M%=2:�:M%=M%*2:�M%>N%
��rad(1,N%,M%)
��
���rad(L%,R%,B%)

�R%<=L%:�
�I%,J%:I%=L%:J%=R%
�
&9F%=�:�:�(((A%?(Q%?I%))�B%)�1)=0:�I%<J%:I%=I%+1:�:F%=�
0�F%
:7F%=�:�:�(((A%?(Q%?J%))�B%)�1):�I%<J%:J%=J%-1:�:F%=�
D�F%:�swap(I%,J%)
N)�J%=I%:�((A%?(Q%?R%)�B%)�1)=0:J%=J%+1
X1�B%>1:B%=B%�2:�rad(L%,J%-1,B%):�rad(J%,R%,B%)
b�
l:
v��str_rad(G%)
�M%=2^G%-1:G%=1
��:�J%=0�M%:C%?J%=0:�
�4�I%=1�N%:J%=((A%?(Q%?I%))�G%)�M%:C%?J%=C%?J%+1:�
�$�J%=1�M%:C%?J%=C%?(J%-1)+C%?J%:�
�'�I%=N%�1�-1:J%=((A%?(Q%?I%))�G%)�M%
�;P%?(C%?J%)=Q%?I%:�shift(I%,C%?J%,Q%?I%):C%?J%=C%?J%-1:�
�"T%=Q%:Q%=P%:P%=T%:G%=(M%+1)*G%
�
�G%>N%
��
�4�:Above only possible with Indirection Operators
�0�I%=1�N%:Q%?I%=P%?I%:�:G%=G%*(M%+1):�G%>N%:�
�:
���merge(L%,R%):�M%

M%=(R%+L%)�2

�M%>L%:�merge(L%,M%)

�M%+1<R%:�merge(M%+1,R%)

 !�I%=L%�M%:P%?I%=Q%?I%:�:I%=L%

*JT%=R%+M%+1:�J%=M%+1�R%:P%?(T%-J%)=Q%?J%:�shift(J%,T%-J%,Q%?J%):�:J%=R%

4
�K%=L%�R%

>l�A%?(P%?I%)<A%?(P%?J%):Q%?K%=P%?I%:�shift(I%,K%,P%?I%):I%=I%+1:�:Q%?K%=P%?J%:�shift(J%,K%,P%?J%):J%=J%-1

H�

R�

\:

f
��cont

p�=0:J=�:*FX21,0

z%�:J=�J:�mes:I=�(99):�I=32��>delay

��J:�mes

��

�:

���mes:�96,-8

�#�"Press Spacebar to continue.";

��

�:

���halt:�96,-8

�+�"Press Spacebar to Halt calculation.";

��

�:

�
��results

�delay=2E5:print=�:�:*FX12,0
�
�print:�:�2,21,16:*FX21,0
�"  METHOD"�22;"TIME"
$7�mthd=first �last:T$=�time:�'M$(mthd)S$�36-�T$)T$:�
.�''N$"was"'
8L�O%<5:�P$n$" in"''O$(O%)" order.":�:�R$"between 1 and "n$''"- "O$(O%)"."
BP�:�print:�6,3:print=�:�:�"Do you want a Printout (Y/N)? ";:print=1-�in("NY")
L9�print:�'"Left margin (0-43) : "I:�2,1,27,1,108,1,I,3
V��print
`�5:�cont
j�
t:
~$ݤin(d$):�:I=�d$,�(��&DF)):�I:=I
�:
�#ݤtime:=�(10*time%(mthd))+" ms"
�:
���quit:@%=10:�3:*FX12,0
��'"Press f0 to run again.";
��
��"SortSee"
�
00000000  0d 00 0a 25 f4 3a 53 6f  72 74 53 65 65 20 62 79  |...%.:SortSee by|
00000010  20 4c 2e 4c 2e 4a 2e 56  69 63 6b 20 28 32 32 2f  | L.L.J.Vick (22/|
00000020  32 2f 38 39 29 0d 00 14  33 43 3d 32 34 36 3a de  |2/89)...3C=246:.|
00000030  41 25 20 43 2c 51 25 20  43 2c 50 25 20 43 2c 43  |A% C,Q% C,P% C,C|
00000040  25 20 37 2c 74 69 6d 65  25 28 39 29 2c 4d 24 28  |% 7,time%(9),M$(|
00000050  39 29 2c 4f 24 28 36 29  0d 00 1e 1f ee 85 3a f6  |9),O$(6)......:.|
00000060  3a f1 22 20 61 74 20 6c  69 6e 65 20 22 3b 9e 3a  |:." at line ";.:|
00000070  f2 71 75 69 74 3a e0 0d  00 28 1e 53 24 3d 22 20  |.quit:...(.S$=" |
00000080  53 6f 72 74 22 3a e3 49  3d 31 b8 36 3a f3 4f 24  |Sort":.I=1.6:.O$|
00000090  28 49 29 3a ed 0d 00 32  0e 2a 4b 45 59 30 52 55  |(I):...2.*KEY0RU|
000000a0  4e 7c 4d 0d 00 3c 0e f5  3a eb 37 3a f2 69 6e 69  |N|M..<..:.7:.ini|
000000b0  74 0d 00 46 15 e3 6d 74  68 64 3d 66 69 72 73 74  |t..F..mthd=first|
000000c0  20 b8 6c 61 73 74 0d 00  50 21 e3 49 25 3d 30 b8  | .last..P!.I%=0.|
000000d0  4e 25 3a 51 25 3f 49 25  3d 49 25 3a ed 3a 64 65  |N%:Q%?I%=I%:.:de|
000000e0  6c 61 79 3d 32 45 33 0d  00 5a 17 eb 34 3a f2 64  |lay=2E3..Z..4:.d|
000000f0  69 73 70 6c 61 79 3a 2a  46 58 31 31 2c 31 0d 00  |isplay:*FX11,1..|
00000100  64 15 f2 68 61 6c 74 3a  d1 3d 30 3a 2a 46 58 31  |d..halt:.=0:*FX1|
00000110  32 2c 31 0d 00 6e 1a e7  73 70 65 65 64 3d 31 3a  |2,1..n..speed=1:|
00000120  f2 73 6c 6f 77 3a 8b 3a  f2 66 61 73 74 0d 00 78  |.slow:.:.fast..x|
00000130  11 74 69 6d 65 25 28 6d  74 68 64 29 3d 91 0d 00  |.time%(mthd)=...|
00000140  82 2a ec 34 30 30 2c 31  30 30 3a f1 22 54 69 6d  |.*.400,100:."Tim|
00000150  65 20 74 61 6b 65 6e 20  3d 20 22 a4 74 69 6d 65  |e taken = ".time|
00000160  3a 2a 46 58 31 32 2c 30  0d 00 8c 11 f2 68 61 6c  |:*FX12,0.....hal|
00000170  74 3a f2 63 6f 6e 74 3a  ed 0d 00 96 18 e7 6c 61  |t:.cont:......la|
00000180  73 74 3e 66 69 72 73 74  3a f2 72 65 73 75 6c 74  |st>first:.result|
00000190  73 0d 00 a0 06 fd a3 0d  00 aa 05 3a 0d 00 b4 0a  |s..........:....|
000001a0  dd f2 73 6c 6f 77 0d 00  be 13 e7 6d 74 68 64 3d  |..slow.....mthd=|
000001b0  31 3a f2 62 75 62 62 6c  65 0d 00 c8 18 e7 6d 74  |1:.bubble.....mt|
000001c0  68 64 3d 32 3a f2 62 75  62 62 6c 65 5f 66 6c 61  |hd=2:.bubble_fla|
000001d0  67 0d 00 d2 1b e7 6d 74  68 64 3d 33 3a f2 62 75  |g.....mthd=3:.bu|
000001e0  62 62 6c 65 5f 6d 6f 6e  69 74 6f 72 0d 00 dc 13  |bble_monitor....|
000001f0  e7 6d 74 68 64 3d 34 3a  f2 73 68 61 6b 65 72 0d  |.mthd=4:.shaker.|
00000200  00 e6 1a e7 6d 74 68 64  3d 35 3a f2 73 74 72 5f  |....mthd=5:.str_|
00000210  69 6e 73 65 72 74 69 6f  6e 0d 00 f0 1a e7 6d 74  |insertion.....mt|
00000220  68 64 3d 36 3a f2 62 69  6e 5f 69 6e 73 65 72 74  |hd=6:.bin_insert|
00000230  69 6f 6e 0d 00 fa 16 e7  6d 74 68 64 3d 37 3a f2  |ion.....mthd=7:.|
00000240  73 65 6c 65 63 74 69 6f  6e 0d 01 04 05 e1 0d 01  |selection.......|
00000250  0e 05 3a 0d 01 18 0a dd  f2 66 61 73 74 0d 01 22  |..:......fast.."|
00000260  15 e7 6d 74 68 64 3d 31  3a f2 73 68 65 6c 6c 28  |..mthd=1:.shell(|
00000270  32 29 0d 01 2c 15 e7 6d  74 68 64 3d 32 3a f2 73  |2)..,..mthd=2:.s|
00000280  68 65 6c 6c 28 33 29 0d  01 36 12 e7 6d 74 68 64  |hell(3)..6..mthd|
00000290  3d 33 3a f2 71 75 69 63  6b 0d 01 40 15 e7 6d 74  |=3:.quick..@..mt|
000002a0  68 64 3d 34 3a f2 71 75  69 63 6b 5f 6e 72 0d 01  |hd=4:.quick_nr..|
000002b0  4a 18 e7 6d 74 68 64 3d  35 3a f2 71 75 69 63 6b  |J..mthd=5:.quick|
000002c0  69 6e 73 65 72 74 0d 01  54 11 e7 6d 74 68 64 3d  |insert..T..mthd=|
000002d0  36 3a f2 68 65 61 70 0d  01 5e 12 e7 6d 74 68 64  |6:.heap..^..mthd|
000002e0  3d 37 3a f2 72 61 64 69  78 0d 01 68 17 e7 6d 74  |=7:.radix..h..mt|
000002f0  68 64 3d 38 3a f2 73 74  72 5f 72 61 64 28 32 29  |hd=8:.str_rad(2)|
00000300  0d 01 72 18 e7 6d 74 68  64 3d 39 3a f2 6d 65 72  |..r..mthd=9:.mer|
00000310  67 65 28 31 2c 4e 25 29  0d 01 7c 05 e1 0d 01 86  |ge(1,N%)..|.....|
00000320  05 3a 0d 01 90 49 dc 50  65 72 66 65 63 74 2c 4e  |.:...I.Perfect,N|
00000330  65 61 72 2d 50 65 72 66  65 63 74 2c 52 65 76 65  |ear-Perfect,Reve|
00000340  72 73 65 2c 52 61 6e 64  6f 6d 2c 57 65 6c 6c 20  |rse,Random,Well |
00000350  64 69 73 74 72 69 62 75  74 65 64 2c 57 69 74 68  |distributed,With|
00000360  20 6d 61 6e 79 20 65 71  75 61 6c 0d 01 9a 6b dc  | many equal...k.|
00000370  37 2c 42 75 62 62 6c 65  2c 42 75 62 62 6c 65 20  |7,Bubble,Bubble |
00000380  28 77 69 74 68 20 46 6c  61 67 29 2c 42 75 62 62  |(with Flag),Bubb|
00000390  6c 65 20 28 77 69 74 68  20 4d 6f 6e 69 74 6f 72  |le (with Monitor|
000003a0  29 2c 53 68 61 6b 65 72  2c 53 74 72 61 69 67 68  |),Shaker,Straigh|
000003b0  74 20 49 6e 73 65 72 74  69 6f 6e 2c 42 69 6e 61  |t Insertion,Bina|
000003c0  72 79 20 49 6e 73 65 72  74 69 6f 6e 2c 53 65 6c  |ry Insertion,Sel|
000003d0  65 63 74 69 6f 6e 0d 01  a4 79 dc 39 2c 53 68 65  |ection...y.9,She|
000003e0  6c 6c 28 32 29 2c 53 68  65 6c 6c 28 33 29 2c 51  |ll(2),Shell(3),Q|
000003f0  75 69 63 6b 20 28 72 65  63 75 72 73 69 76 65 29  |uick (recursive)|
00000400  2c 51 75 69 63 6b 20 28  6e 6f 6e 2d 72 65 63 75  |,Quick (non-recu|
00000410  72 73 69 76 65 29 2c 51  75 69 63 6b 2f 49 6e 73  |rsive),Quick/Ins|
00000420  65 72 74 69 6f 6e 2c 48  65 61 70 2c 52 61 64 69  |ertion,Heap,Radi|
00000430  78 20 45 78 63 68 61 6e  67 65 2c 53 74 72 61 69  |x Exchange,Strai|
00000440  67 68 74 20 52 61 64 69  78 2c 4d 65 72 67 65 0d  |ght Radix,Merge.|
00000450  01 ae 05 3a 0d 01 b8 0a  dd f2 69 6e 69 74 0d 01  |...:......init..|
00000460  c2 36 e3 49 3d 30 b8 31  3a f1 8a 33 2c 49 29 bd  |.6.I=0.1:..3,I).|
00000470  31 34 31 22 53 4f 52 54  49 4e 47 20 41 4c 47 4f  |141"SORTING ALGO|
00000480  52 49 54 48 4d 53 20 4f  4e 20 44 49 53 50 4c 41  |RITHMS ON DISPLA|
00000490  59 22 3a ed 0d 01 cc 19  40 25 3d 26 36 30 36 3a  |Y":.....@%=&606:|
000004a0  ef 32 38 2c 31 2c 32 34  2c 33 39 2c 32 0d 01 d6  |.28,1,24,39,2...|
000004b0  34 f5 3a db 3a f1 8a 32  2c 39 29 22 43 68 6f 6f  |4.:.:..2,9)"Choo|
000004c0  73 65 20 61 20 6e 75 6d  62 65 72 2c 20 6c 65 73  |se a number, les|
000004d0  73 20 74 68 61 6e 20 22  c3 28 43 2b 31 29 22 2e  |s than ".(C+1)".|
000004e0  22 0d 01 e0 35 f1 8a 30  2c 32 30 29 22 50 72 65  |"...5..0,20)"Pre|
000004f0  73 73 20 48 20 28 52 45  54 55 52 4e 29 20 66 6f  |ss H (RETURN) fo|
00000500  72 20 48 65 6c 70 20 26  20 49 6e 66 6f 72 6d 61  |r Help & Informa|
00000510  74 69 6f 6e 22 3b 0d 01  ea 2c e8 8a 31 33 2c 31  |tion";...,..13,1|
00000520  31 29 22 4e 20 3d 20 22  6e 24 3a e7 a9 6e 24 3c  |1)"N = "n$:..n$<|
00000530  35 3a 4e 25 3d bb 6e 24  3a 8b 3a 4e 25 3d 30 3a  |5:N%=.n$:.:N%=0:|
00000540  ef 37 0d 01 f4 25 e7 6e  24 3d 22 48 22 84 6e 24  |.7...%.n$="H".n$|
00000550  3d 22 68 22 3a 53 25 3d  31 3a ef 37 3a d7 22 54  |="h":S%=1:.7:."T|
00000560  2f 53 6f 72 74 73 22 0d  01 fe 0f fd 4e 25 3e 31  |/Sorts".....N%>1|
00000570  80 4e 25 3c 3d 43 0d 02  08 31 4e 24 3d 22 54 68  |.N%<=C...1N$="Th|
00000580  65 20 6f 72 69 67 69 6e  61 6c 20 4e 75 6d 62 65  |e original Numbe|
00000590  72 20 53 65 71 75 65 6e  63 65 20 22 3a 6e 24 3d  |r Sequence ":n$=|
000005a0  c3 28 4e 25 29 3a db 0d  02 12 32 50 24 3d 22 61  |.(N%):....2P$="a|
000005b0  20 50 65 72 6d 75 74 61  74 69 6f 6e 20 6f 66 20  | Permutation of |
000005c0  31 20 74 6f 20 22 3a 52  24 3d 22 61 20 52 61 6e  |1 to ":R$="a Ran|
000005d0  64 6f 6d 20 73 65 74 20  22 0d 02 1c 3a f1 27 4e  |dom set "...:.'N|
000005e0  24 22 63 6f 6e 73 69 73  74 73 22 27 27 22 6f 66  |$"consists"''"of|
000005f0  20 61 20 73 65 74 20 6f  66 20 69 6e 74 65 67 65  | a set of intege|
00000600  72 73 20 77 68 69 63 68  20 63 61 6e 20 62 65 3a  |rs which can be:|
00000610  2d 22 27 0d 02 26 13 f1  22 45 49 54 48 45 52 20  |-"'..&.."EITHER |
00000620  22 50 24 6e 24 27 0d 02  30 25 e3 49 3d 31 b8 34  |"P$n$'..0%.I=1.4|
00000630  3a f1 49 22 2e 2e 2e 49  6e 20 22 4f 24 28 49 29  |:.I"...In "O$(I)|
00000640  22 20 6f 72 64 65 72 22  27 3a ed 0d 02 3a 1c f1  |" order"':...:..|
00000650  22 4f 52 20 22 52 24 22  69 6e 20 74 68 69 73 20  |"OR "R$"in this |
00000660  72 61 6e 67 65 22 27 0d  02 44 1a e3 49 3d 35 b8  |range"'..D..I=5.|
00000670  36 3a f1 49 22 2e 2e 2e  22 4f 24 28 49 29 27 3a  |6:.I"..."O$(I)':|
00000680  ed 0d 02 4e 34 f5 3a f1  8a 35 2c 32 31 29 22 43  |...N4.:..5,21)"C|
00000690  68 6f 6f 73 65 20 28 31  20 74 6f 20 36 29 20 3a  |hoose (1 to 6) :|
000006a0  22 3b 3a 4f 25 3d a5 2d  34 38 3a fd 4f 25 3e 30  |";:O%=.-48:.O%>0|
000006b0  80 4f 25 3c 37 0d 02 58  1a f1 8a 32 34 2c 32 31  |.O%<7..X...24,21|
000006c0  29 c3 28 4f 25 29 22 20  77 61 69 74 21 22 3b 0d  |).(O%)" wait!";.|
000006d0  02 62 17 e3 49 25 3d 30  b8 4e 25 3a 41 25 3f 49  |.b..I%=0.N%:A%?I|
000006e0  25 3d 49 25 3a ed 0d 02  6c 0c 49 3d b3 28 2d 4e  |%=I%:...l.I=.(-N|
000006f0  25 29 0d 02 76 0f e7 4f  25 3d 32 3a f2 6e 65 61  |%)..v..O%=2:.nea|
00000700  72 0d 02 80 0e e7 4f 25  3d 33 3a f2 72 65 76 0d  |r.....O%=3:.rev.|
00000710  02 8a 0f e7 4f 25 3d 34  3a f2 70 65 72 6d 0d 02  |....O%=4:.perm..|
00000720  94 11 e7 4f 25 3d 35 3a  f2 72 61 6e 64 6f 6d 0d  |...O%=5:.random.|
00000730  02 9e 15 e7 4f 25 3d 36  3a f2 65 71 75 61 6c 5f  |....O%=6:.equal_|
00000740  6b 65 79 73 0d 02 a8 28  58 25 3d 32 34 30 3a 59  |keys...(X%=240:Y|
00000750  25 3d 34 3a ef 32 33 2c  58 25 2c 31 32 38 2c 30  |%=4:.23,X%,128,0|
00000760  2c 30 2c 30 2c 30 2c 30  2c 30 2c 30 0d 02 b2 2b  |,0,0,0,0,0,0...+|
00000770  e7 4e 25 3c 31 32 34 3a  59 25 3d 38 3a ef 32 33  |.N%<124:Y%=8:.23|
00000780  2c 58 25 2c 31 39 32 2c  31 39 32 2c 30 2c 30 2c  |,X%,192,192,0,0,|
00000790  30 2c 30 2c 30 2c 30 0d  02 bc 2b e7 4e 25 3c 36  |0,0,0,0...+.N%<6|
000007a0  32 3a 59 25 3d 31 36 3a  ef 32 33 2c 58 25 2c 58  |2:Y%=16:.23,X%,X|
000007b0  25 2c 58 25 2c 58 25 2c  58 25 2c 30 2c 30 2c 30  |%,X%,X%,X%,0,0,0|
000007c0  2c 30 0d 02 c6 2d e7 4e  25 3c 33 31 3a 49 3d 32  |,0...-.N%<31:I=2|
000007d0  35 35 3a 59 25 3d 33 32  3a ef 32 33 2c 58 25 2c  |55:Y%=32:.23,X%,|
000007e0  49 2c 49 2c 49 2c 49 2c  49 2c 49 2c 49 2c 49 0d  |I,I,I,I,I,I,I,I.|
000007f0  02 d0 4a db 3a f1 8a 30  2c 39 29 22 44 6f 20 79  |..J.:..0,9)"Do y|
00000800  6f 75 20 77 61 6e 74 20  74 68 65 20 27 73 6c 6f  |ou want the 'slo|
00000810  77 27 20 6f 72 20 74 68  65 20 27 66 61 73 74 27  |w' or the 'fast'|
00000820  22 27 27 8a 38 29 22 6d  65 74 68 6f 64 73 3f 20  |"''.8)"methods? |
00000830  28 53 2f 46 29 20 3a 22  3b 0d 02 da 13 73 70 65  |(S/F) :";....spe|
00000840  65 64 3d a4 69 6e 28 22  53 46 22 29 0d 02 e4 1b  |ed=.in("SF")....|
00000850  db 3a e7 73 70 65 65 64  3d 31 3a f7 8d 74 5a 41  |.:.speed=1:..tZA|
00000860  3a 8b f7 8d 74 64 41 0d  02 ee 32 f3 6d 65 74 68  |:...tdA...2.meth|
00000870  6f 64 73 3a e3 49 3d 31  b8 6d 65 74 68 6f 64 73  |ods:.I=1.methods|
00000880  3a f3 4d 24 28 49 29 3a  f1 27 49 22 2e 2e 2e 22  |:.M$(I):.'I"..."|
00000890  4d 24 28 49 29 53 24 3a  ed 0d 02 f8 32 f5 3a f1  |M$(I)S$:....2.:.|
000008a0  8a 30 2c 32 31 29 22 43  68 6f 6f 73 65 20 61 6e  |.0,21)"Choose an|
000008b0  20 41 6c 67 6f 72 69 74  68 6d 20 28 41 20 66 6f  | Algorithm (A fo|
000008c0  72 20 41 6c 6c 29 20 3a  20 22 3b 0d 03 02 27 49  |r All) : ";...'I|
000008d0  3d a7 c0 22 31 32 33 34  35 36 37 38 39 22 2c 6d  |=.."123456789",m|
000008e0  65 74 68 6f 64 73 29 2b  22 41 61 22 2c be 29 3a  |ethods)+"Aa",.):|
000008f0  fd 49 0d 03 0c 32 66 69  72 73 74 3d 49 3a 6c 61  |.I...2first=I:la|
00000900  73 74 3d 49 3a e7 49 3e  6d 65 74 68 6f 64 73 3a  |st=I:.I>methods:|
00000910  66 69 72 73 74 3d 31 3a  6c 61 73 74 3d 6d 65 74  |first=1:last=met|
00000920  68 6f 64 73 0d 03 16 05  e1 0d 03 20 05 3a 0d 03  |hods....... .:..|
00000930  2a 0a dd f2 70 65 72 6d  0d 03 34 15 e3 49 25 3d  |*...perm..4..I%=|
00000940  31 b8 4e 25 3a 4a 25 3d  b3 28 4e 25 29 0d 03 3e  |1.N%:J%=.(N%)..>|
00000950  21 54 25 3d 41 25 3f 4a  25 3a 41 25 3f 4a 25 3d  |!T%=A%?J%:A%?J%=|
00000960  41 25 3f 49 25 3a 41 25  3f 49 25 3d 54 25 0d 03  |A%?I%:A%?I%=T%..|
00000970  48 05 ed 0d 03 52 05 e1  0d 03 5c 05 3a 0d 03 66  |H....R....\.:..f|
00000980  0a dd f2 6e 65 61 72 0d  03 70 18 4c 25 3d 33 3a  |...near..p.L%=3:|
00000990  e7 4e 25 3c 38 3a 4c 25  3d 4e 25 81 34 2b 31 0d  |.N%<8:L%=N%.4+1.|
000009a0  03 7a 21 e3 49 25 3d 4c  25 b8 4e 25 2d 4c 25 3a  |.z!.I%=L%.N%-L%:|
000009b0  4a 25 3d b3 28 4c 25 2a  32 29 2b 49 25 2d 4c 25  |J%=.(L%*2)+I%-L%|
000009c0  0d 03 84 21 54 25 3d 41  25 3f 4a 25 3a 41 25 3f  |...!T%=A%?J%:A%?|
000009d0  4a 25 3d 41 25 3f 49 25  3a 41 25 3f 49 25 3d 54  |J%=A%?I%:A%?I%=T|
000009e0  25 0d 03 8e 05 ed 0d 03  98 05 e1 0d 03 a2 05 3a  |%..............:|
000009f0  0d 03 ac 09 dd f2 72 65  76 0d 03 b6 0c e3 49 25  |......rev.....I%|
00000a00  3d 31 b8 4e 25 0d 03 c0  11 41 25 3f 49 25 3d 4e  |=1.N%....A%?I%=N|
00000a10  25 2b 31 2d 49 25 0d 03  ca 05 ed 0d 03 d4 05 e1  |%+1-I%..........|
00000a20  0d 03 de 05 3a 0d 03 e8  0c dd f2 72 61 6e 64 6f  |....:......rando|
00000a30  6d 0d 03 f2 0c e3 49 25  3d 31 b8 4e 25 0d 03 fc  |m.....I%=1.N%...|
00000a40  0f 41 25 3f 49 25 3d b3  28 4e 25 29 0d 04 06 05  |.A%?I%=.(N%)....|
00000a50  ed 0d 04 10 05 e1 0d 04  1a 05 3a 0d 04 24 10 dd  |..........:..$..|
00000a60  f2 65 71 75 61 6c 5f 6b  65 79 73 0d 04 2e 17 4b  |.equal_keys....K|
00000a70  25 3d aa 28 4e 25 2b 31  29 3a 54 25 3d 4e 25 81  |%=.(N%+1):T%=N%.|
00000a80  4b 25 0d 04 38 1a e3 49  25 3d 31 b8 54 25 3a 51  |K%..8..I%=1.T%:Q|
00000a90  25 3f 49 25 3d b3 28 54  25 29 3a ed 0d 04 42 0c  |%?I%=.(T%):...B.|
00000aa0  e3 49 25 3d 31 b8 4e 25  0d 04 4c 19 41 25 3f 49  |.I%=1.N%..L.A%?I|
00000ab0  25 3d 28 51 25 3f 28 b3  28 54 25 29 29 29 2a 4b  |%=(Q%?(.(T%)))*K|
00000ac0  25 0d 04 56 05 ed 0d 04  60 05 e1 0d 04 6a 05 3a  |%..V....`....j.:|
00000ad0  0d 04 74 0d dd f2 64 69  73 70 6c 61 79 0d 04 7e  |..t...display..~|
00000ae0  1f ef 32 36 2c 31 32 2c  31 36 2c 35 2c 32 39 2c  |..26,12,16,5,29,|
00000af0  30 3b 33 32 3b 3a 49 3d  59 25 2d 34 0d 04 88 2e  |0;32;:I=Y%-4....|
00000b00  ec 49 2c 30 3a df 31 32  37 39 2c 30 3a df 31 32  |.I,0:.1279,0:.12|
00000b10  37 39 2c 39 39 31 3a df  49 2c 39 39 31 3a df 49  |79,991:.I,991:.I|
00000b20  2c 30 3a ec 36 34 2c 39  35 35 0d 04 92 21 f1 4d  |,0:.64,955...!.M|
00000b30  24 28 6d 74 68 64 29 53  24 27 27 22 20 20 22 6e  |$(mthd)S$''"  "n|
00000b40  24 22 20 6e 75 6d 62 65  72 73 22 0d 04 9c 08 e6  |$" numbers".....|
00000b50  34 2c 31 0d 04 a6 0c e3  49 25 3d 31 b8 4e 25 0d  |4,1.....I%=1.N%.|
00000b60  04 b0 17 ec 59 25 2a 49  25 2c 41 25 3f 49 25 2a  |....Y%*I%,A%?I%*|
00000b70  59 25 3a ef 58 25 0d 04  ba 05 ed 0d 04 c4 05 e1  |Y%:.X%..........|
00000b80  0d 04 ce 05 3a 0d 04 d8  19 dd f2 73 77 61 70 28  |....:......swap(|
00000b90  55 25 2c 56 25 29 3a e7  55 25 3d 56 25 e1 0d 04  |U%,V%):.U%=V%...|
00000ba0  e2 17 f2 73 68 69 66 74  28 55 25 2c 56 25 2c 51  |...shift(U%,V%,Q|
00000bb0  25 3f 55 25 29 0d 04 ec  17 f2 73 68 69 66 74 28  |%?U%).....shift(|
00000bc0  56 25 2c 55 25 2c 51 25  3f 56 25 29 0d 04 f6 21  |V%,U%,Q%?V%)...!|
00000bd0  54 25 3d 51 25 3f 56 25  3a 51 25 3f 56 25 3d 51  |T%=Q%?V%:Q%?V%=Q|
00000be0  25 3f 55 25 3a 51 25 3f  55 25 3d 54 25 0d 05 00  |%?U%:Q%?U%=T%...|
00000bf0  05 e1 0d 05 0a 05 3a 0d  05 14 15 dd f2 73 68 69  |......:......shi|
00000c00  66 74 28 55 25 2c 56 25  2c 44 25 29 0d 05 1e 1d  |ft(U%,V%,D%)....|
00000c10  5a 25 3d 59 25 2a 41 25  3f 44 25 3a ec 59 25 2a  |Z%=Y%*A%?D%:.Y%*|
00000c20  55 25 2c 5a 25 3a ef 58  25 0d 05 28 11 ec 59 25  |U%,Z%:.X%..(..Y%|
00000c30  2a 56 25 2c 5a 25 3a ef  58 25 0d 05 32 13 f5 3a  |*V%,Z%:.X%..2..:|
00000c40  49 3d a6 28 32 29 3a fd  49 3c 3e 33 32 0d 05 3c  |I=.(2):.I<>32..<|
00000c50  05 e1 0d 05 46 05 3a 0d  05 50 0c dd f2 62 75 62  |....F.:..P...bub|
00000c60  62 6c 65 0d 05 5a 0f e3  49 25 3d 4e 25 b8 32 88  |ble..Z..I%=N%.2.|
00000c70  2d 31 0d 05 64 0e e3 4a  25 3d 31 b8 49 25 2d 31  |-1..d..J%=1.I%-1|
00000c80  0d 05 6e 2d e7 41 25 3f  28 51 25 3f 4a 25 29 3e  |..n-.A%?(Q%?J%)>|
00000c90  41 25 3f 28 51 25 3f 28  4a 25 2b 31 29 29 3a f2  |A%?(Q%?(J%+1)):.|
00000ca0  73 77 61 70 28 4a 25 2c  4a 25 2b 31 29 0d 05 78  |swap(J%,J%+1)..x|
00000cb0  06 ed 2c 0d 05 82 05 e1  0d 05 8c 05 3a 0d 05 96  |..,.........:...|
00000cc0  11 dd f2 62 75 62 62 6c  65 5f 66 6c 61 67 0d 05  |...bubble_flag..|
00000cd0  a0 10 49 25 3d 4e 25 3a  f5 3a 46 25 3d b9 0d 05  |..I%=N%:.:F%=...|
00000ce0  aa 3d e3 4a 25 3d 31 b8  49 25 2d 31 3a e7 41 25  |.=.J%=1.I%-1:.A%|
00000cf0  3f 28 51 25 3f 4a 25 29  3e 41 25 3f 28 51 25 3f  |?(Q%?J%)>A%?(Q%?|
00000d00  28 4a 25 2b 31 29 29 3a  f2 73 77 61 70 28 4a 25  |(J%+1)):.swap(J%|
00000d10  2c 4a 25 2b 31 29 3a 46  25 3d a3 0d 05 b4 0d ed  |,J%+1):F%=......|
00000d20  3a 49 25 3d 49 25 2d 31  0d 05 be 07 fd 46 25 0d  |:I%=I%-1.....F%.|
00000d30  05 c8 05 e1 0d 05 d2 05  3a 0d 05 dc 14 dd f2 62  |........:......b|
00000d40  75 62 62 6c 65 5f 6d 6f  6e 69 74 6f 72 0d 05 e6  |ubble_monitor...|
00000d50  12 49 25 3d 4e 25 2d 31  3a f5 3a 46 25 3d 31 0d  |.I%=N%-1:.:F%=1.|
00000d60  05 f0 3c e3 4a 25 3d 31  b8 49 25 3a e7 41 25 3f  |..<.J%=1.I%:.A%?|
00000d70  28 51 25 3f 4a 25 29 3e  41 25 3f 28 51 25 3f 28  |(Q%?J%)>A%?(Q%?(|
00000d80  4a 25 2b 31 29 29 3a f2  73 77 61 70 28 4a 25 2c  |J%+1)):.swap(J%,|
00000d90  4a 25 2b 31 29 3a 46 25  3d 4a 25 0d 05 fa 0d ed  |J%+1):F%=J%.....|
00000da0  3a 49 25 3d 46 25 2d 31  0d 06 04 09 fd 46 25 3d  |:I%=F%-1.....F%=|
00000db0  31 0d 06 0e 05 e1 0d 06  18 05 3a 0d 06 22 0c dd  |1.........:.."..|
00000dc0  f2 73 68 61 6b 65 72 0d  06 2c 14 4c 25 3d 32 3a  |.shaker..,.L%=2:|
00000dd0  52 25 3d 4e 25 3a 4b 25  3d 4e 25 0d 06 36 05 f5  |R%=N%:K%=N%..6..|
00000de0  0d 06 40 10 e3 4a 25 3d  52 25 b8 4c 25 88 2d 31  |..@..J%=R%.L%.-1|
00000df0  0d 06 4a 33 e7 41 25 3f  28 51 25 3f 28 4a 25 2d  |..J3.A%?(Q%?(J%-|
00000e00  31 29 29 3e 41 25 3f 28  51 25 3f 4a 25 29 3a f2  |1))>A%?(Q%?J%):.|
00000e10  73 77 61 70 28 4a 25 2d  31 2c 4a 25 29 3a 4b 25  |swap(J%-1,J%):K%|
00000e20  3d 4a 25 0d 06 54 0d ed  3a 4c 25 3d 4b 25 2b 31  |=J%..T..:L%=K%+1|
00000e30  0d 06 5e 0d e3 4a 25 3d  4c 25 b8 52 25 0d 06 68  |..^..J%=L%.R%..h|
00000e40  33 e7 41 25 3f 28 51 25  3f 28 4a 25 2d 31 29 29  |3.A%?(Q%?(J%-1))|
00000e50  3e 41 25 3f 28 51 25 3f  4a 25 29 3a f2 73 77 61  |>A%?(Q%?J%):.swa|
00000e60  70 28 4a 25 2d 31 2c 4a  25 29 3a 4b 25 3d 4a 25  |p(J%-1,J%):K%=J%|
00000e70  0d 06 72 0d ed 3a 52 25  3d 4b 25 2d 31 0d 06 7c  |..r..:R%=K%-1..||
00000e80  0a fd 4c 25 3e 52 25 0d  06 86 05 e1 0d 06 90 05  |..L%>R%.........|
00000e90  3a 0d 06 9a 23 dd f2 73  74 72 5f 69 6e 73 65 72  |:...#..str_inser|
00000ea0  74 69 6f 6e 3a f2 69 6e  73 65 72 74 28 31 2c 4e  |tion:.insert(1,N|
00000eb0  25 29 3a e1 0d 06 a4 05  3a 0d 06 ae 13 dd f2 69  |%):.....:......i|
00000ec0  6e 73 65 72 74 28 4c 25  2c 52 25 29 0d 06 b8 23  |nsert(L%,R%)...#|
00000ed0  e3 49 25 3d 4c 25 2b 31  b8 52 25 3a 57 25 3d 51  |.I%=L%+1.R%:W%=Q|
00000ee0  25 3f 49 25 3a 4a 25 3d  49 25 3a 46 25 3d a3 0d  |%?I%:J%=I%:F%=..|
00000ef0  06 c2 05 f5 0d 06 cc 4d  e7 41 25 3f 28 51 25 3f  |.......M.A%?(Q%?|
00000f00  28 4a 25 2d 31 29 29 3e  41 25 3f 57 25 3a 4a 25  |(J%-1))>A%?W%:J%|
00000f10  3d 4a 25 2d 31 3a f2 73  68 69 66 74 28 4a 25 2c  |=J%-1:.shift(J%,|
00000f20  4a 25 2b 31 2c 51 25 3f  4a 25 29 3a 51 25 3f 28  |J%+1,Q%?J%):Q%?(|
00000f30  4a 25 2b 31 29 3d 51 25  3f 4a 25 3a 8b 46 25 3d  |J%+1)=Q%?J%:.F%=|
00000f40  b9 0d 06 d6 07 fd 46 25  0d 06 e0 24 e7 4a 25 3c  |......F%...$.J%<|
00000f50  49 25 3a f2 73 68 69 66  74 28 49 25 2c 4a 25 2c  |I%:.shift(I%,J%,|
00000f60  57 25 29 3a 51 25 3f 4a  25 3d 57 25 0d 06 ea 05  |W%):Q%?J%=W%....|
00000f70  ed 0d 06 f4 05 e1 0d 06  fe 05 3a 0d 07 08 13 dd  |..........:.....|
00000f80  f2 62 69 6e 5f 69 6e 73  65 72 74 69 6f 6e 0d 07  |.bin_insertion..|
00000f90  12 22 e3 49 25 3d 32 b8  4e 25 3a 57 25 3d 51 25  |.".I%=2.N%:W%=Q%|
00000fa0  3f 49 25 3a 4c 25 3d 31  3a 52 25 3d 49 25 2d 31  |?I%:L%=1:R%=I%-1|
00000fb0  0d 07 1c 05 f5 0d 07 26  34 4d 25 3d 28 4c 25 2b  |.......&4M%=(L%+|
00000fc0  52 25 29 81 32 3a e7 41  25 3f 28 51 25 3f 4d 25  |R%).2:.A%?(Q%?M%|
00000fd0  29 3e 41 25 3f 57 25 3a  52 25 3d 4d 25 2d 31 3a  |)>A%?W%:R%=M%-1:|
00000fe0  8b 3a 4c 25 3d 4d 25 2b  31 0d 07 30 0a fd 4c 25  |.:L%=M%+1..0..L%|
00000ff0  3e 52 25 0d 07 3a 5b e7  4c 25 3c 49 25 3a e3 4a  |>R%..:[.L%<I%:.J|
00001000  25 3d 49 25 2d 31 b8 4c  25 88 2d 31 3a f2 73 68  |%=I%-1.L%.-1:.sh|
00001010  69 66 74 28 4a 25 2c 4a  25 2b 31 2c 51 25 3f 4a  |ift(J%,J%+1,Q%?J|
00001020  25 29 3a 51 25 3f 28 4a  25 2b 31 29 3d 51 25 3f  |%):Q%?(J%+1)=Q%?|
00001030  4a 25 3a ed 3a f2 73 68  69 66 74 28 49 25 2c 4c  |J%:.:.shift(I%,L|
00001040  25 2c 57 25 29 3a 51 25  3f 4c 25 3d 57 25 0d 07  |%,W%):Q%?L%=W%..|
00001050  44 05 ed 0d 07 4e 05 e1  0d 07 58 05 3a 0d 07 62  |D....N....X.:..b|
00001060  0f dd f2 73 65 6c 65 63  74 69 6f 6e 0d 07 6c 14  |...selection..l.|
00001070  e3 49 25 3d 31 b8 4e 25  2d 31 3a 4d 25 3d 49 25  |.I%=1.N%-1:M%=I%|
00001080  0d 07 76 2e e3 4a 25 3d  28 49 25 2b 31 29 b8 4e  |..v..J%=(I%+1).N|
00001090  25 3a e7 41 25 3f 28 51  25 3f 4a 25 29 3c 41 25  |%:.A%?(Q%?J%)<A%|
000010a0  3f 28 51 25 3f 4d 25 29  3a 4d 25 3d 4a 25 0d 07  |?(Q%?M%):M%=J%..|
000010b0  80 12 ed 3a f2 73 77 61  70 28 49 25 2c 4d 25 29  |...:.swap(I%,M%)|
000010c0  0d 07 8a 05 ed 0d 07 94  05 e1 0d 07 9e 05 3a 0d  |..............:.|
000010d0  07 a8 0f dd f2 73 68 65  6c 6c 28 47 25 29 0d 07  |.....shell(G%)..|
000010e0  b2 1c 48 25 3d 31 3a f5  3a 48 25 3d 47 25 2a 48  |..H%=1:.:H%=G%*H|
000010f0  25 2b 31 3a fd 48 25 3e  4e 25 0d 07 bc 0e f5 3a  |%+1:.H%>N%.....:|
00001100  48 25 3d 48 25 81 47 25  0d 07 c6 25 e3 49 25 3d  |H%=H%.G%...%.I%=|
00001110  28 48 25 2b 31 29 b8 4e  25 3a 57 25 3d 51 25 3f  |(H%+1).N%:W%=Q%?|
00001120  49 25 3a 4a 25 3d 49 25  3a 46 25 3d a3 0d 07 d0  |I%:J%=I%:F%=....|
00001130  05 f5 0d 07 da 52 e7 41  25 3f 28 51 25 3f 28 4a  |.....R.A%?(Q%?(J|
00001140  25 2d 48 25 29 29 3e 41  25 3f 57 25 3a 4a 25 3d  |%-H%))>A%?W%:J%=|
00001150  4a 25 2d 48 25 3a f2 73  68 69 66 74 28 4a 25 2c  |J%-H%:.shift(J%,|
00001160  4a 25 2b 48 25 2c 51 25  3f 4a 25 29 3a 51 25 3f  |J%+H%,Q%?J%):Q%?|
00001170  28 4a 25 2b 48 25 29 3d  51 25 3f 4a 25 3a 8b 3a  |(J%+H%)=Q%?J%:.:|
00001180  46 25 3d b9 0d 07 e4 0e  fd 46 25 84 4a 25 3c 3d  |F%=......F%.J%<=|
00001190  48 25 0d 07 ee 24 e7 4a  25 3c 49 25 3a f2 73 68  |H%...$.J%<I%:.sh|
000011a0  69 66 74 28 49 25 2c 4a  25 2c 57 25 29 3a 51 25  |ift(I%,J%,W%):Q%|
000011b0  3f 4a 25 3d 57 25 0d 07  f8 05 ed 0d 08 02 27 e7  |?J%=W%........'.|
000011c0  48 25 3e 31 3a 74 69 6d  65 25 3d 91 3a f2 73 73  |H%>1:time%=.:.ss|
000011d0  3a f2 63 6f 6e 74 3a f2  73 73 3a d1 3d 74 69 6d  |:.cont:.ss:.=tim|
000011e0  65 25 0d 08 0c 09 fd 48  25 3d 31 0d 08 16 05 e1  |e%.....H%=1.....|
000011f0  0d 08 20 05 3a 0d 08 2a  31 dd f2 73 73 3a f2 68  |.. .:..*1..ss:.h|
00001200  61 6c 74 3a ec 37 30 30  2c 31 30 30 3a f1 22 4e  |alt:.700,100:."N|
00001210  6f 77 20 22 c3 28 48 25  29 22 2d 73 6f 72 74 65  |ow ".(H%)"-sorte|
00001220  64 2e 22 3b 3a e1 0d 08  34 05 3a 0d 08 3e 24 dd  |d.";:...4.:..>$.|
00001230  f2 71 75 69 63 6b 3a 47  25 3d aa 28 4e 25 29 2b  |.quick:G%=.(N%)+|
00001240  33 3a f2 73 6f 72 74 28  31 2c 4e 25 29 3a e1 0d  |3:.sort(1,N%):..|
00001250  08 48 05 3a 0d 08 52 1b  f4 3a 51 75 69 63 6b 73  |.H.:..R..:Quicks|
00001260  6f 72 74 20 3a 20 72 65  63 75 72 73 69 76 65 0d  |ort : recursive.|
00001270  08 5c 11 dd f2 73 6f 72  74 28 4c 25 2c 52 25 29  |.\...sort(L%,R%)|
00001280  0d 08 66 0a ea 49 25 2c  4a 25 0d 08 70 1e e7 52  |..f..I%,J%..p..R|
00001290  25 2d 4c 25 3c 47 25 3a  f2 69 6e 73 65 72 74 28  |%-L%<G%:.insert(|
000012a0  4c 25 2c 52 25 29 3a e1  0d 08 7a 0b f2 6d 65 64  |L%,R%):...z..med|
000012b0  69 61 6e 0d 08 84 1d 57  25 3d 41 25 3f 28 51 25  |ian....W%=A%?(Q%|
000012c0  3f 4d 25 29 3a 49 25 3d  4c 25 3a 4a 25 3d 52 25  |?M%):I%=L%:J%=R%|
000012d0  0d 08 8e 05 f5 0d 08 98  1d f5 3a 49 25 3d 49 25  |..........:I%=I%|
000012e0  2b 31 3a fd 41 25 3f 28  51 25 3f 49 25 29 3e 3d  |+1:.A%?(Q%?I%)>=|
000012f0  57 25 0d 08 a2 1d f5 3a  4a 25 3d 4a 25 2d 31 3a  |W%.....:J%=J%-1:|
00001300  fd 41 25 3f 28 51 25 3f  4a 25 29 3c 3d 57 25 0d  |.A%?(Q%?J%)<=W%.|
00001310  08 ac 17 e7 49 25 3c 4a  25 3a f2 73 77 61 70 28  |....I%<J%:.swap(|
00001320  4a 25 2c 49 25 29 0d 08  b6 0a fd 4a 25 3c 49 25  |J%,I%).....J%<I%|
00001330  0d 08 c0 4a e7 28 52 25  2d 49 25 29 3e 28 4a 25  |...J.(R%-I%)>(J%|
00001340  2d 4c 25 29 3a f2 73 6f  72 74 28 4c 25 2c 4a 25  |-L%):.sort(L%,J%|
00001350  29 3a f2 73 6f 72 74 28  49 25 2c 52 25 29 3a 8b  |):.sort(I%,R%):.|
00001360  3a f2 73 6f 72 74 28 49  25 2c 52 25 29 3a f2 73  |:.sort(I%,R%):.s|
00001370  6f 72 74 28 4c 25 2c 4a  25 29 0d 08 ca 05 e1 0d  |ort(L%,J%)......|
00001380  08 d4 05 3a 0d 08 de 0c  dd f2 6d 65 64 69 61 6e  |...:......median|
00001390  0d 08 e8 27 e7 41 25 3f  28 51 25 3f 4c 25 29 3e  |...'.A%?(Q%?L%)>|
000013a0  41 25 3f 28 51 25 3f 52  25 29 3a f2 73 77 61 70  |A%?(Q%?R%):.swap|
000013b0  28 4c 25 2c 52 25 29 0d  08 f2 10 4d 25 3d 28 4c  |(L%,R%)....M%=(L|
000013c0  25 2b 52 25 29 81 32 0d  08 fc 27 e7 41 25 3f 28  |%+R%).2...'.A%?(|
000013d0  51 25 3f 4d 25 29 3e 41  25 3f 28 51 25 3f 52 25  |Q%?M%)>A%?(Q%?R%|
000013e0  29 3a f2 73 77 61 70 28  4d 25 2c 52 25 29 0d 09  |):.swap(M%,R%)..|
000013f0  06 27 e7 41 25 3f 28 51  25 3f 4c 25 29 3e 41 25  |.'.A%?(Q%?L%)>A%|
00001400  3f 28 51 25 3f 4d 25 29  3a f2 73 77 61 70 28 4c  |?(Q%?M%):.swap(L|
00001410  25 2c 4d 25 29 0d 09 10  05 e1 0d 09 1a 05 3a 0d  |%,M%).........:.|
00001420  09 24 0e dd f2 71 75 69  63 6b 5f 6e 72 0d 09 2e  |.$...quick_nr...|
00001430  1e 47 25 3d aa 28 4e 25  29 2b 33 3a 4c 25 3d 31  |.G%=.(N%)+3:L%=1|
00001440  3a 52 25 3d 4e 25 3a 53  25 3d 32 0d 09 38 05 f5  |:R%=N%:S%=2..8..|
00001450  0d 09 42 33 e7 52 25 3e  4c 25 3a f2 6e 72 5f 73  |..B3.R%>L%:.nr_s|
00001460  6f 72 74 3a 8b 3a 53 25  3d 53 25 2d 32 3a 4c 25  |ort:.:S%=S%-2:L%|
00001470  3d 50 25 3f 53 25 3a 52  25 3d 50 25 3f 28 53 25  |=P%?S%:R%=P%?(S%|
00001480  2b 31 29 0d 09 4c 09 fd  53 25 3c 32 0d 09 56 05  |+1)..L..S%<2..V.|
00001490  e1 0d 09 60 05 3a 0d 09  6a 0d dd f2 6e 72 5f 73  |...`.:..j...nr_s|
000014a0  6f 72 74 0d 09 74 24 e7  52 25 2d 4c 25 3c 47 25  |ort..t$.R%-L%<G%|
000014b0  3a f2 69 6e 73 65 72 74  28 4c 25 2c 52 25 29 3a  |:.insert(L%,R%):|
000014c0  52 25 3d 4c 25 3a e1 0d  09 7e 0b f2 6d 65 64 69  |R%=L%:...~..medi|
000014d0  61 6e 0d 09 88 1d 57 25  3d 41 25 3f 28 51 25 3f  |an....W%=A%?(Q%?|
000014e0  4d 25 29 3a 49 25 3d 4c  25 3a 4a 25 3d 52 25 0d  |M%):I%=L%:J%=R%.|
000014f0  09 92 05 f5 0d 09 9c 1d  f5 3a 49 25 3d 49 25 2b  |.........:I%=I%+|
00001500  31 3a fd 41 25 3f 28 51  25 3f 49 25 29 3e 3d 57  |1:.A%?(Q%?I%)>=W|
00001510  25 0d 09 a6 1d f5 3a 4a  25 3d 4a 25 2d 31 3a fd  |%.....:J%=J%-1:.|
00001520  41 25 3f 28 51 25 3f 4a  25 29 3c 3d 57 25 0d 09  |A%?(Q%?J%)<=W%..|
00001530  b0 17 e7 49 25 3c 4a 25  3a f2 73 77 61 70 28 4a  |...I%<J%:.swap(J|
00001540  25 2c 49 25 29 0d 09 ba  0a fd 4a 25 3c 49 25 0d  |%,I%).....J%<I%.|
00001550  09 c4 4e e7 28 52 25 2d  49 25 29 3e 28 4a 25 2d  |..N.(R%-I%)>(J%-|
00001560  4c 25 29 3a 50 25 3f 53  25 3d 49 25 3a 50 25 3f  |L%):P%?S%=I%:P%?|
00001570  28 53 25 2b 31 29 3d 52  25 3a 52 25 3d 4a 25 3a  |(S%+1)=R%:R%=J%:|
00001580  8b 3a 50 25 3f 53 25 3d  4c 25 3a 50 25 3f 28 53  |.:P%?S%=L%:P%?(S|
00001590  25 2b 31 29 3d 4a 25 3a  4c 25 3d 49 25 0d 09 ce  |%+1)=J%:L%=I%...|
000015a0  0b 53 25 3d 53 25 2b 32  0d 09 d8 05 e1 0d 09 e2  |.S%=S%+2........|
000015b0  05 3a 0d 09 ec 11 dd f2  71 75 69 63 6b 69 6e 73  |.:......quickins|
000015c0  65 72 74 0d 09 f6 1e 47  25 3d aa 28 4e 25 29 2b  |ert....G%=.(N%)+|
000015d0  33 3a 4c 25 3d 31 3a 52  25 3d 4e 25 3a 53 25 3d  |3:L%=1:R%=N%:S%=|
000015e0  32 0d 0a 00 05 f5 0d 0a  0a 37 e7 52 25 3e 4c 25  |2........7.R%>L%|
000015f0  2b 47 25 3a f2 73 65 64  5f 73 6f 72 74 3a 8b 3a  |+G%:.sed_sort:.:|
00001600  53 25 3d 53 25 2d 32 3a  4c 25 3d 50 25 3f 53 25  |S%=S%-2:L%=P%?S%|
00001610  3a 52 25 3d 50 25 3f 28  53 25 2b 31 29 0d 0a 14  |:R%=P%?(S%+1)...|
00001620  09 fd 53 25 3c 32 0d 0a  1e 21 74 69 6d 65 25 3d  |..S%<2...!time%=|
00001630  91 3a f2 69 73 3a f2 63  6f 6e 74 3a f2 69 73 3a  |.:.is:.cont:.is:|
00001640  d1 3d 74 69 6d 65 25 0d  0a 28 12 f2 73 74 72 5f  |.=time%..(..str_|
00001650  69 6e 73 65 72 74 69 6f  6e 0d 0a 32 05 e1 0d 0a  |insertion..2....|
00001660  3c 05 3a 0d 0a 46 2e f4  3a 51 75 69 63 6b 73 6f  |<.:..F..:Quickso|
00001670  72 74 20 61 20 6c 61 20  53 65 64 67 65 77 69 63  |rt a la Sedgewic|
00001680  6b 20 3a 20 6e 6f 6e 2d  72 65 63 75 72 73 69 76  |k : non-recursiv|
00001690  65 0d 0a 50 0e dd f2 73  65 64 5f 73 6f 72 74 0d  |e..P...sed_sort.|
000016a0  0a 5a 0b f2 6d 65 64 69  61 6e 0d 0a 64 2c 49 25  |.Z..median..d,I%|
000016b0  3d 4c 25 3a 4a 25 3d 52  25 2d 31 3a f2 73 77 61  |=L%:J%=R%-1:.swa|
000016c0  70 28 4d 25 2c 4a 25 29  3a 57 25 3d 41 25 3f 28  |p(M%,J%):W%=A%?(|
000016d0  51 25 3f 4a 25 29 0d 0a  6e 05 f5 0d 0a 78 1d f5  |Q%?J%)..n....x..|
000016e0  3a 49 25 3d 49 25 2b 31  3a fd 41 25 3f 28 51 25  |:I%=I%+1:.A%?(Q%|
000016f0  3f 49 25 29 3e 3d 57 25  0d 0a 82 1d f5 3a 4a 25  |?I%)>=W%.....:J%|
00001700  3d 4a 25 2d 31 3a fd 41  25 3f 28 51 25 3f 4a 25  |=J%-1:.A%?(Q%?J%|
00001710  29 3c 3d 57 25 0d 0a 8c  17 e7 49 25 3c 4a 25 3a  |)<=W%.....I%<J%:|
00001720  f2 73 77 61 70 28 4a 25  2c 49 25 29 0d 0a 96 19  |.swap(J%,I%)....|
00001730  fd 4a 25 3c 49 25 3a f2  73 77 61 70 28 49 25 2c  |.J%<I%:.swap(I%,|
00001740  52 25 2d 31 29 0d 0a a0  56 e7 28 52 25 2d 49 25  |R%-1)...V.(R%-I%|
00001750  29 3e 28 4a 25 2d 4c 25  29 3a 50 25 3f 53 25 3d  |)>(J%-L%):P%?S%=|
00001760  49 25 2b 31 3a 50 25 3f  28 53 25 2b 31 29 3d 52  |I%+1:P%?(S%+1)=R|
00001770  25 3a 52 25 3d 49 25 2d  31 3a 8b 3a 50 25 3f 53  |%:R%=I%-1:.:P%?S|
00001780  25 3d 4c 25 3a 50 25 3f  28 53 25 2b 31 29 3d 49  |%=L%:P%?(S%+1)=I|
00001790  25 2d 31 3a 4c 25 3d 49  25 2b 31 0d 0a aa 0b 53  |%-1:L%=I%+1....S|
000017a0  25 3d 53 25 2b 32 0d 0a  b4 05 e1 0d 0a be 05 3a  |%=S%+2.........:|
000017b0  0d 0a c8 08 dd f2 69 73  0d 0a d2 12 f2 68 61 6c  |......is.....hal|
000017c0  74 3a ec 35 30 30 2c 31  30 30 0d 0a dc 1f f1 22  |t:.500,100....."|
000017d0  4e 6f 77 20 66 6f 72 20  49 6e 73 65 72 74 69 6f  |Now for Insertio|
000017e0  6e 20 73 6f 72 74 2e 22  3b 0d 0a e6 05 e1 0d 0a  |n sort.";.......|
000017f0  f0 05 3a 0d 0a fa 0a dd  f2 68 65 61 70 0d 0b 04  |..:......heap...|
00001800  09 4d 25 3d 4e 25 0d 0b  0e 21 e3 4c 25 3d 4e 25  |.M%=N%...!.L%=N%|
00001810  81 32 b8 31 88 2d 31 3a  f2 64 6f 77 6e 68 65 61  |.2.1.-1:.downhea|
00001820  70 28 4c 25 29 3a ed 0d  0b 18 21 74 69 6d 65 25  |p(L%):....!time%|
00001830  3d 91 3a f2 68 66 3a f2  63 6f 6e 74 3a f2 68 66  |=.:.hf:.cont:.hf|
00001840  3a d1 3d 74 69 6d 65 25  0d 0b 22 05 f5 0d 0b 2c  |:.=time%.."....,|
00001850  2a f2 73 77 61 70 28 31  2c 4d 25 29 3a 4d 25 3d  |*.swap(1,M%):M%=|
00001860  4d 25 2d 31 3a e7 4d 25  3e 31 3a f2 64 6f 77 6e  |M%-1:.M%>1:.down|
00001870  68 65 61 70 28 31 29 0d  0b 36 09 fd 4d 25 3d 31  |heap(1)..6..M%=1|
00001880  0d 0b 40 05 e1 0d 0b 4a  05 3a 0d 0b 54 12 dd f2  |..@....J.:..T...|
00001890  64 6f 77 6e 68 65 61 70  28 4b 25 29 0d 0b 5e 1f  |downheap(K%)..^.|
000018a0  57 25 3d 51 25 3f 4b 25  3a 4c 25 3d 4b 25 3a 47  |W%=Q%?K%:L%=K%:G|
000018b0  25 3d 4d 25 81 32 3a 46  25 3d a3 0d 0b 68 05 f5  |%=M%.2:F%=...h..|
000018c0  0d 0b 72 36 4a 25 3d 4b  25 2b 4b 25 3a e7 4a 25  |..r6J%=K%+K%:.J%|
000018d0  3c 4d 25 3a e7 41 25 3f  28 51 25 3f 4a 25 29 3c  |<M%:.A%?(Q%?J%)<|
000018e0  41 25 3f 28 51 25 3f 28  4a 25 2b 31 29 29 3a 4a  |A%?(Q%?(J%+1)):J|
000018f0  25 3d 4a 25 2b 31 0d 0b  7c 43 e7 41 25 3f 57 25  |%=J%+1..|C.A%?W%|
00001900  3e 3d 41 25 3f 28 51 25  3f 4a 25 29 3a 46 25 3d  |>=A%?(Q%?J%):F%=|
00001910  b9 3a 8b 3a f2 73 68 69  66 74 28 4a 25 2c 4b 25  |.:.:.shift(J%,K%|
00001920  2c 51 25 3f 4a 25 29 3a  51 25 3f 4b 25 3d 51 25  |,Q%?J%):Q%?K%=Q%|
00001930  3f 4a 25 3a 4b 25 3d 4a  25 0d 0b 86 2e fd 46 25  |?J%:K%=J%.....F%|
00001940  84 4b 25 3e 47 25 3a e7  4b 25 3e 4c 25 3a f2 73  |.K%>G%:.K%>L%:.s|
00001950  68 69 66 74 28 4c 25 2c  4b 25 2c 57 25 29 3a 51  |hift(L%,K%,W%):Q|
00001960  25 3f 4b 25 3d 57 25 0d  0b 90 05 e1 0d 0b 9a 05  |%?K%=W%.........|
00001970  3a 0d 0b a4 08 dd f2 68  66 0d 0b ae 12 f2 68 61  |:......hf.....ha|
00001980  6c 74 3a ec 35 30 30 2c  39 30 30 0d 0b b8 18 f1  |lt:.500,900.....|
00001990  22 48 65 61 70 20 6e 6f  77 20 66 6f 72 6d 65 64  |"Heap now formed|
000019a0  2e 22 3b 0d 0b c2 05 e1  0d 0b cc 05 3a 0d 0b d6  |.";.........:...|
000019b0  0b dd f2 72 61 64 69 78  0d 0b e0 19 4d 25 3d 32  |...radix....M%=2|
000019c0  3a f5 3a 4d 25 3d 4d 25  2a 32 3a fd 4d 25 3e 4e  |:.:M%=M%*2:.M%>N|
000019d0  25 0d 0b ea 11 f2 72 61  64 28 31 2c 4e 25 2c 4d  |%.....rad(1,N%,M|
000019e0  25 29 0d 0b f4 05 e1 0d  0b fe 13 dd f2 72 61 64  |%)...........rad|
000019f0  28 4c 25 2c 52 25 2c 42  25 29 0d 0c 08 0d e7 52  |(L%,R%,B%).....R|
00001a00  25 3c 3d 4c 25 3a e1 0d  0c 12 16 ea 49 25 2c 4a  |%<=L%:......I%,J|
00001a10  25 3a 49 25 3d 4c 25 3a  4a 25 3d 52 25 0d 0c 1c  |%:I%=L%:J%=R%...|
00001a20  05 f5 0d 0c 26 39 46 25  3d a3 3a f5 3a e7 28 28  |....&9F%=.:.:.((|
00001a30  28 41 25 3f 28 51 25 3f  49 25 29 29 81 42 25 29  |(A%?(Q%?I%)).B%)|
00001a40  80 31 29 3d 30 3a e7 49  25 3c 4a 25 3a 49 25 3d  |.1)=0:.I%<J%:I%=|
00001a50  49 25 2b 31 3a 8b 3a 46  25 3d b9 0d 0c 30 07 fd  |I%+1:.:F%=...0..|
00001a60  46 25 0d 0c 3a 37 46 25  3d a3 3a f5 3a e7 28 28  |F%..:7F%=.:.:.((|
00001a70  28 41 25 3f 28 51 25 3f  4a 25 29 29 81 42 25 29  |(A%?(Q%?J%)).B%)|
00001a80  80 31 29 3a e7 49 25 3c  4a 25 3a 4a 25 3d 4a 25  |.1):.I%<J%:J%=J%|
00001a90  2d 31 3a 8b 3a 46 25 3d  b9 0d 0c 44 14 fd 46 25  |-1:.:F%=...D..F%|
00001aa0  3a f2 73 77 61 70 28 49  25 2c 4a 25 29 0d 0c 4e  |:.swap(I%,J%)..N|
00001ab0  29 fd 4a 25 3d 49 25 3a  e7 28 28 41 25 3f 28 51  |).J%=I%:.((A%?(Q|
00001ac0  25 3f 52 25 29 81 42 25  29 80 31 29 3d 30 3a 4a  |%?R%).B%).1)=0:J|
00001ad0  25 3d 4a 25 2b 31 0d 0c  58 31 e7 42 25 3e 31 3a  |%=J%+1..X1.B%>1:|
00001ae0  42 25 3d 42 25 81 32 3a  f2 72 61 64 28 4c 25 2c  |B%=B%.2:.rad(L%,|
00001af0  4a 25 2d 31 2c 42 25 29  3a f2 72 61 64 28 4a 25  |J%-1,B%):.rad(J%|
00001b00  2c 52 25 2c 42 25 29 0d  0c 62 05 e1 0d 0c 6c 05  |,R%,B%)..b....l.|
00001b10  3a 0d 0c 76 11 dd f2 73  74 72 5f 72 61 64 28 47  |:..v...str_rad(G|
00001b20  25 29 0d 0c 80 12 4d 25  3d 32 5e 47 25 2d 31 3a  |%)....M%=2^G%-1:|
00001b30  47 25 3d 31 0d 0c 8a 18  f5 3a e3 4a 25 3d 30 b8  |G%=1.....:.J%=0.|
00001b40  4d 25 3a 43 25 3f 4a 25  3d 30 3a ed 0d 0c 94 34  |M%:C%?J%=0:....4|
00001b50  e3 49 25 3d 31 b8 4e 25  3a 4a 25 3d 28 28 41 25  |.I%=1.N%:J%=((A%|
00001b60  3f 28 51 25 3f 49 25 29  29 81 47 25 29 80 4d 25  |?(Q%?I%)).G%).M%|
00001b70  3a 43 25 3f 4a 25 3d 43  25 3f 4a 25 2b 31 3a ed  |:C%?J%=C%?J%+1:.|
00001b80  0d 0c 9e 24 e3 4a 25 3d  31 b8 4d 25 3a 43 25 3f  |...$.J%=1.M%:C%?|
00001b90  4a 25 3d 43 25 3f 28 4a  25 2d 31 29 2b 43 25 3f  |J%=C%?(J%-1)+C%?|
00001ba0  4a 25 3a ed 0d 0c a8 27  e3 49 25 3d 4e 25 b8 31  |J%:....'.I%=N%.1|
00001bb0  88 2d 31 3a 4a 25 3d 28  28 41 25 3f 28 51 25 3f  |.-1:J%=((A%?(Q%?|
00001bc0  49 25 29 29 81 47 25 29  80 4d 25 0d 0c b2 3b 50  |I%)).G%).M%...;P|
00001bd0  25 3f 28 43 25 3f 4a 25  29 3d 51 25 3f 49 25 3a  |%?(C%?J%)=Q%?I%:|
00001be0  f2 73 68 69 66 74 28 49  25 2c 43 25 3f 4a 25 2c  |.shift(I%,C%?J%,|
00001bf0  51 25 3f 49 25 29 3a 43  25 3f 4a 25 3d 43 25 3f  |Q%?I%):C%?J%=C%?|
00001c00  4a 25 2d 31 3a ed 0d 0c  bc 22 54 25 3d 51 25 3a  |J%-1:...."T%=Q%:|
00001c10  51 25 3d 50 25 3a 50 25  3d 54 25 3a 47 25 3d 28  |Q%=P%:P%=T%:G%=(|
00001c20  4d 25 2b 31 29 2a 47 25  0d 0c c6 0a fd 47 25 3e  |M%+1)*G%.....G%>|
00001c30  4e 25 0d 0c d0 05 e1 0d  0c da 34 f4 3a 41 62 6f  |N%........4.:Abo|
00001c40  76 65 20 6f 6e 6c 79 20  70 6f 73 73 69 62 6c 65  |ve only possible|
00001c50  20 77 69 74 68 20 49 6e  64 69 72 65 63 74 69 6f  | with Indirectio|
00001c60  6e 20 4f 70 65 72 61 74  6f 72 73 0d 0c e4 30 e3  |n Operators...0.|
00001c70  49 25 3d 31 b8 4e 25 3a  51 25 3f 49 25 3d 50 25  |I%=1.N%:Q%?I%=P%|
00001c80  3f 49 25 3a ed 3a 47 25  3d 47 25 2a 28 4d 25 2b  |?I%:.:G%=G%*(M%+|
00001c90  31 29 3a fd 47 25 3e 4e  25 3a e1 0d 0c ee 05 3a  |1):.G%>N%:.....:|
00001ca0  0d 0c f8 16 dd f2 6d 65  72 67 65 28 4c 25 2c 52  |......merge(L%,R|
00001cb0  25 29 3a ea 4d 25 0d 0d  02 10 4d 25 3d 28 52 25  |%):.M%....M%=(R%|
00001cc0  2b 4c 25 29 81 32 0d 0d  0c 18 e7 4d 25 3e 4c 25  |+L%).2.....M%>L%|
00001cd0  3a f2 6d 65 72 67 65 28  4c 25 2c 4d 25 29 0d 0d  |:.merge(L%,M%)..|
00001ce0  16 1c e7 4d 25 2b 31 3c  52 25 3a f2 6d 65 72 67  |...M%+1<R%:.merg|
00001cf0  65 28 4d 25 2b 31 2c 52  25 29 0d 0d 20 21 e3 49  |e(M%+1,R%).. !.I|
00001d00  25 3d 4c 25 b8 4d 25 3a  50 25 3f 49 25 3d 51 25  |%=L%.M%:P%?I%=Q%|
00001d10  3f 49 25 3a ed 3a 49 25  3d 4c 25 0d 0d 2a 4a 54  |?I%:.:I%=L%..*JT|
00001d20  25 3d 52 25 2b 4d 25 2b  31 3a e3 4a 25 3d 4d 25  |%=R%+M%+1:.J%=M%|
00001d30  2b 31 b8 52 25 3a 50 25  3f 28 54 25 2d 4a 25 29  |+1.R%:P%?(T%-J%)|
00001d40  3d 51 25 3f 4a 25 3a f2  73 68 69 66 74 28 4a 25  |=Q%?J%:.shift(J%|
00001d50  2c 54 25 2d 4a 25 2c 51  25 3f 4a 25 29 3a ed 3a  |,T%-J%,Q%?J%):.:|
00001d60  4a 25 3d 52 25 0d 0d 34  0d e3 4b 25 3d 4c 25 b8  |J%=R%..4..K%=L%.|
00001d70  52 25 0d 0d 3e 6c e7 41  25 3f 28 50 25 3f 49 25  |R%..>l.A%?(P%?I%|
00001d80  29 3c 41 25 3f 28 50 25  3f 4a 25 29 3a 51 25 3f  |)<A%?(P%?J%):Q%?|
00001d90  4b 25 3d 50 25 3f 49 25  3a f2 73 68 69 66 74 28  |K%=P%?I%:.shift(|
00001da0  49 25 2c 4b 25 2c 50 25  3f 49 25 29 3a 49 25 3d  |I%,K%,P%?I%):I%=|
00001db0  49 25 2b 31 3a 8b 3a 51  25 3f 4b 25 3d 50 25 3f  |I%+1:.:Q%?K%=P%?|
00001dc0  4a 25 3a f2 73 68 69 66  74 28 4a 25 2c 4b 25 2c  |J%:.shift(J%,K%,|
00001dd0  50 25 3f 4a 25 29 3a 4a  25 3d 4a 25 2d 31 0d 0d  |P%?J%):J%=J%-1..|
00001de0  48 05 ed 0d 0d 52 05 e1  0d 0d 5c 05 3a 0d 0d 66  |H....R....\.:..f|
00001df0  0a dd f2 63 6f 6e 74 0d  0d 70 13 d1 3d 30 3a 4a  |...cont..p..=0:J|
00001e00  3d a3 3a 2a 46 58 32 31  2c 30 0d 0d 7a 25 f5 3a  |=.:*FX21,0..z%.:|
00001e10  4a 3d ac 4a 3a f2 6d 65  73 3a 49 3d a6 28 39 39  |J=.J:.mes:I=.(99|
00001e20  29 3a fd 49 3d 33 32 84  91 3e 64 65 6c 61 79 0d  |):.I=32..>delay.|
00001e30  0d 84 0b e7 4a 3a f2 6d  65 73 0d 0d 8e 05 e1 0d  |....J:.mes......|
00001e40  0d 98 05 3a 0d 0d a2 10  dd f2 6d 65 73 3a ec 39  |...:......mes:.9|
00001e50  36 2c 2d 38 0d 0d ac 23  f1 22 50 72 65 73 73 20  |6,-8...#."Press |
00001e60  53 70 61 63 65 62 61 72  20 74 6f 20 63 6f 6e 74  |Spacebar to cont|
00001e70  69 6e 75 65 2e 22 3b 0d  0d b6 05 e1 0d 0d c0 05  |inue.";.........|
00001e80  3a 0d 0d ca 11 dd f2 68  61 6c 74 3a ec 39 36 2c  |:......halt:.96,|
00001e90  2d 38 0d 0d d4 2b f1 22  50 72 65 73 73 20 53 70  |-8...+."Press Sp|
00001ea0  61 63 65 62 61 72 20 74  6f 20 48 61 6c 74 20 63  |acebar to Halt c|
00001eb0  61 6c 63 75 6c 61 74 69  6f 6e 2e 22 3b 0d 0d de  |alculation.";...|
00001ec0  05 e1 0d 0d e8 05 3a 0d  0d f2 0d dd f2 72 65 73  |......:......res|
00001ed0  75 6c 74 73 0d 0d fc 1f  64 65 6c 61 79 3d 32 45  |ults....delay=2E|
00001ee0  35 3a 70 72 69 6e 74 3d  a3 3a db 3a 2a 46 58 31  |5:print=.:.:*FX1|
00001ef0  32 2c 30 0d 0e 06 05 f5  0d 0e 10 1d e7 70 72 69  |2,0..........pri|
00001f00  6e 74 3a f1 3a ef 32 2c  32 31 2c 31 36 3a 2a 46  |nt:.:.2,21,16:*F|
00001f10  58 32 31 2c 30 0d 0e 1a  19 f1 22 20 20 4d 45 54  |X21,0....."  MET|
00001f20  48 4f 44 22 89 32 32 3b  22 54 49 4d 45 22 0d 0e  |HOD".22;"TIME"..|
00001f30  24 37 e3 6d 74 68 64 3d  66 69 72 73 74 20 b8 6c  |$7.mthd=first .l|
00001f40  61 73 74 3a 54 24 3d a4  74 69 6d 65 3a f1 27 4d  |ast:T$=.time:.'M|
00001f50  24 28 6d 74 68 64 29 53  24 8a 33 36 2d a9 54 24  |$(mthd)S$.36-.T$|
00001f60  29 54 24 3a ed 0d 0e 2e  0f f1 27 27 4e 24 22 77  |)T$:......''N$"w|
00001f70  61 73 22 27 0d 0e 38 4c  e7 4f 25 3c 35 3a f1 50  |as"'..8L.O%<5:.P|
00001f80  24 6e 24 22 20 69 6e 22  27 27 4f 24 28 4f 25 29  |$n$" in"''O$(O%)|
00001f90  22 20 6f 72 64 65 72 2e  22 3a 8b 3a f1 52 24 22  |" order.":.:.R$"|
00001fa0  62 65 74 77 65 65 6e 20  31 20 61 6e 64 20 22 6e  |between 1 and "n|
00001fb0  24 27 27 22 2d 20 22 4f  24 28 4f 25 29 22 2e 22  |$''"- "O$(O%)"."|
00001fc0  0d 0e 42 50 f1 3a e7 70  72 69 6e 74 3a ef 36 2c  |..BP.:.print:.6,|
00001fd0  33 3a 70 72 69 6e 74 3d  a3 3a 8b 3a f1 22 44 6f  |3:print=.:.:."Do|
00001fe0  20 79 6f 75 20 77 61 6e  74 20 61 20 50 72 69 6e  | you want a Prin|
00001ff0  74 6f 75 74 20 28 59 2f  4e 29 3f 20 22 3b 3a 70  |tout (Y/N)? ";:p|
00002000  72 69 6e 74 3d 31 2d a4  69 6e 28 22 4e 59 22 29  |rint=1-.in("NY")|
00002010  0d 0e 4c 39 e7 70 72 69  6e 74 3a e8 27 22 4c 65  |..L9.print:.'"Le|
00002020  66 74 20 6d 61 72 67 69  6e 20 28 30 2d 34 33 29  |ft margin (0-43)|
00002030  20 3a 20 22 49 3a ef 32  2c 31 2c 32 37 2c 31 2c  | : "I:.2,1,27,1,|
00002040  31 30 38 2c 31 2c 49 2c  33 0d 0e 56 0b fd ac 70  |108,1,I,3..V...p|
00002050  72 69 6e 74 0d 0e 60 0c  ef 35 3a f2 63 6f 6e 74  |rint..`..5:.cont|
00002060  0d 0e 6a 05 e1 0d 0e 74  05 3a 0d 0e 7e 24 dd a4  |..j....t.:..~$..|
00002070  69 6e 28 64 24 29 3a f5  3a 49 3d a7 64 24 2c bd  |in(d$):.:I=.d$,.|
00002080  28 a5 80 26 44 46 29 29  3a fd 49 3a 3d 49 0d 0e  |(..&DF)):.I:=I..|
00002090  88 05 3a 0d 0e 92 23 dd  a4 74 69 6d 65 3a 3d c3  |..:...#..time:=.|
000020a0  28 31 30 2a 74 69 6d 65  25 28 6d 74 68 64 29 29  |(10*time%(mthd))|
000020b0  2b 22 20 6d 73 22 0d 0e  9c 05 3a 0d 0e a6 1b dd  |+" ms"....:.....|
000020c0  f2 71 75 69 74 3a 40 25  3d 31 30 3a ef 33 3a 2a  |.quit:@%=10:.3:*|
000020d0  46 58 31 32 2c 30 0d 0e  b0 1f f1 27 22 50 72 65  |FX12,0.....'"Pre|
000020e0  73 73 20 66 30 20 74 6f  20 72 75 6e 20 61 67 61  |ss f0 to run aga|
000020f0  69 6e 2e 22 3b 0d 0e ba  05 e1 0d 0e c4 0e cd 22  |in.";.........."|
00002100  53 6f 72 74 53 65 65 22  0d ff                    |SortSee"..|
0000210a
25-08-89/SortSee.m0
25-08-89/SortSee.m1
25-08-89/SortSee.m2
25-08-89/SortSee.m4
25-08-89/SortSee.m5