Home » Personal collection » Acorn tapes » Electron_User » Electron_User_tape22a_acorn_eu_1991_may.wav » Permuta
Permuta
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 » Personal collection » Acorn tapes » Electron_User » Electron_User_tape22a_acorn_eu_1991_may.wav |
Filename: | Permuta |
Read OK: | ✔ |
File size: | 0285 bytes |
Load address: | FFFF1A00 |
Exec address: | FFFF8023 |
Duplicates
There are 3 duplicate copies of this file in the archive:
- AEW website » mu » mu_5_25_discs_Micro_User_09_03_D-MU09_03.ssd » Permuta
- AEW website » mu » mu_Micro_User_09_03_MU9-3_B.uef » Permuta
- Personal collection » Acorn tapes » Electron_User » Electron_User_tape22a_acorn_eu_1991_may.wav » Permuta
- Personal collection » Acorn tapes » Electron_User » Electron_User_tape22b_acorn_eu_1991_may.wav » Permuta
File contents
10REM > Permutatns 20REM ------------ 30REM by John Barnes 100WIDTH 0 110CLS:INPUT'''"Type in a string"''"This program will then print all the permutations of that string"''word$:N%=LEN(word$):CLS 120DIM A% N%+2 130$A%=CHR$0+word$ 140PROCsort 150W%=N%+3:WIDTH (39DIVW%)*W% 160TIME=0 170REPEAT PRINT $(A%+1)SPC3;:K%=N%+1 180REPEAT K%=K%-1:UNTIL A%?(K%-1)<A%?K% 190IF K%=1 GOTO 230 200S%=N%+1:REPEAT S%=S%-1:UNTIL A%?(K%-1)<A%?S% 210T%=A%?(K%-1):A%?(K%-1)=A%?S%:A%?S%=T% 220IF K%<N% FOR S%=0 TO INT((N%-K%)/2):T%=A%?(K%+S%):A%?(K%+S%)=A%?(N%-S%):A%?(N%-S%)=T%:NEXT 230UNTIL K%=1 240PRINT INT(TIME/6000+0.5)" mins" 250WIDTH 0 260END 270DEFPROCsort 280FOR X%=1 TO N%-1:FOR Y%=1 TO N%-X%:IF A%?Y%>A%?(Y%+1) T%=A%?Y%:A%?Y%=A%?(Y%+1):A%?(Y%+1)=T% 290NEXT:NEXT:ENDPROC
� > Permutatns � ------------ � by John Barnes d� 0 nu�:�'''"Type in a string"''"This program will then print all the permutations of that string"''word$:N%=�(word$):� x � A% N%+2 �$A%=�0+word$ � �sort �W%=N%+3:� (39�W%)*W% ��=0 �� � $(A%+1)�3;:K%=N%+1 �� K%=K%-1:� A%?(K%-1)<A%?K% �� K%=1 � �df@ �'S%=N%+1:� S%=S%-1:� A%?(K%-1)<A%?S% �)T%=A%?(K%-1):A%?(K%-1)=A%?S%:A%?S%=T% �U� K%<N% � S%=0 � �((N%-K%)/2):T%=A%?(K%+S%):A%?(K%+S%)=A%?(N%-S%):A%?(N%-S%)=T%:� � � K%=1 �� �(�/6000+0.5)" mins" �� 0 � ��sort X� X%=1 � N%-1:� Y%=1 � N%-X%:� A%?Y%>A%?(Y%+1) T%=A%?Y%:A%?Y%=A%?(Y%+1):A%?(Y%+1)=T% " �:�:� �
00000000 0d 00 0a 12 f4 20 3e 20 50 65 72 6d 75 74 61 74 |..... > Permutat| 00000010 6e 73 0d 00 14 12 f4 20 2d 2d 2d 2d 2d 2d 2d 2d |ns..... --------| 00000020 2d 2d 2d 2d 0d 00 1e 14 f4 20 62 79 20 4a 6f 68 |----..... by Joh| 00000030 6e 20 42 61 72 6e 65 73 0d 00 64 07 fe 20 30 0d |n Barnes..d.. 0.| 00000040 00 6e 75 db 3a e8 27 27 27 22 54 79 70 65 20 69 |.nu.:.'''"Type i| 00000050 6e 20 61 20 73 74 72 69 6e 67 22 27 27 22 54 68 |n a string"''"Th| 00000060 69 73 20 70 72 6f 67 72 61 6d 20 77 69 6c 6c 20 |is program will | 00000070 74 68 65 6e 20 70 72 69 6e 74 20 61 6c 6c 20 74 |then print all t| 00000080 68 65 20 70 65 72 6d 75 74 61 74 69 6f 6e 73 20 |he permutations | 00000090 6f 66 20 74 68 61 74 20 73 74 72 69 6e 67 22 27 |of that string"'| 000000a0 27 77 6f 72 64 24 3a 4e 25 3d a9 28 77 6f 72 64 |'word$:N%=.(word| 000000b0 24 29 3a db 0d 00 78 0d de 20 41 25 20 4e 25 2b |$):...x.. A% N%+| 000000c0 32 0d 00 82 10 24 41 25 3d bd 30 2b 77 6f 72 64 |2....$A%=.0+word| 000000d0 24 0d 00 8c 09 f2 73 6f 72 74 0d 00 96 18 57 25 |$.....sort....W%| 000000e0 3d 4e 25 2b 33 3a fe 20 28 33 39 81 57 25 29 2a |=N%+3:. (39.W%)*| 000000f0 57 25 0d 00 a0 07 d1 3d 30 0d 00 aa 1a f5 20 f1 |W%.....=0..... .| 00000100 20 24 28 41 25 2b 31 29 89 33 3b 3a 4b 25 3d 4e | $(A%+1).3;:K%=N| 00000110 25 2b 31 0d 00 b4 1f f5 20 4b 25 3d 4b 25 2d 31 |%+1..... K%=K%-1| 00000120 3a fd 20 41 25 3f 28 4b 25 2d 31 29 3c 41 25 3f |:. A%?(K%-1)<A%?| 00000130 4b 25 0d 00 be 11 e7 20 4b 25 3d 31 20 e5 20 8d |K%..... K%=1 . .| 00000140 64 66 40 0d 00 c8 27 53 25 3d 4e 25 2b 31 3a f5 |df@...'S%=N%+1:.| 00000150 20 53 25 3d 53 25 2d 31 3a fd 20 41 25 3f 28 4b | S%=S%-1:. A%?(K| 00000160 25 2d 31 29 3c 41 25 3f 53 25 0d 00 d2 29 54 25 |%-1)<A%?S%...)T%| 00000170 3d 41 25 3f 28 4b 25 2d 31 29 3a 41 25 3f 28 4b |=A%?(K%-1):A%?(K| 00000180 25 2d 31 29 3d 41 25 3f 53 25 3a 41 25 3f 53 25 |%-1)=A%?S%:A%?S%| 00000190 3d 54 25 0d 00 dc 55 e7 20 4b 25 3c 4e 25 20 e3 |=T%...U. K%<N% .| 000001a0 20 53 25 3d 30 20 b8 20 a8 28 28 4e 25 2d 4b 25 | S%=0 . .((N%-K%| 000001b0 29 2f 32 29 3a 54 25 3d 41 25 3f 28 4b 25 2b 53 |)/2):T%=A%?(K%+S| 000001c0 25 29 3a 41 25 3f 28 4b 25 2b 53 25 29 3d 41 25 |%):A%?(K%+S%)=A%| 000001d0 3f 28 4e 25 2d 53 25 29 3a 41 25 3f 28 4e 25 2d |?(N%-S%):A%?(N%-| 000001e0 53 25 29 3d 54 25 3a ed 0d 00 e6 0a fd 20 4b 25 |S%)=T%:...... K%| 000001f0 3d 31 0d 00 f0 1a f1 20 a8 28 91 2f 36 30 30 30 |=1..... .(./6000| 00000200 2b 30 2e 35 29 22 20 6d 69 6e 73 22 0d 00 fa 07 |+0.5)" mins"....| 00000210 fe 20 30 0d 01 04 05 e0 0d 01 0e 0a dd f2 73 6f |. 0...........so| 00000220 72 74 0d 01 18 58 e3 20 58 25 3d 31 20 b8 20 4e |rt...X. X%=1 . N| 00000230 25 2d 31 3a e3 20 59 25 3d 31 20 b8 20 4e 25 2d |%-1:. Y%=1 . N%-| 00000240 58 25 3a e7 20 41 25 3f 59 25 3e 41 25 3f 28 59 |X%:. A%?Y%>A%?(Y| 00000250 25 2b 31 29 20 54 25 3d 41 25 3f 59 25 3a 41 25 |%+1) T%=A%?Y%:A%| 00000260 3f 59 25 3d 41 25 3f 28 59 25 2b 31 29 3a 41 25 |?Y%=A%?(Y%+1):A%| 00000270 3f 28 59 25 2b 31 29 3d 54 25 0d 01 22 09 ed 3a |?(Y%+1)=T%.."..:| 00000280 ed 3a e1 0d ff |.:...| 00000285