Home » Archimedes archive » Acorn User » AU 1998-07.adf » Regulars » StarInfo/Brobecker/Permute
StarInfo/Brobecker/Permute
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 » Archimedes archive » Acorn User » AU 1998-07.adf » Regulars |
Filename: | StarInfo/Brobecker/Permute |
Read OK: | ✔ |
File size: | 03DA bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
10REM>>> Recursively list all permutations 20REM Alain BROBECKER (baah/Arm's Tech) on 30-Jun-1997 30REM Poetry added thanks to MOLIERE on 29-Nov-1997 40INPUT"Are you a poet";p$:p%=(p$="y")OR(p$="Y") 50IFp%THENn%=5ELSEINPUT"How many elts to permute";n% 60DIMlist%(n%),used%(n%) 70FORc%=1TOn%:used%(c%)=FALSE:NEXT 80PROCpermute(1) 90END 100 110DEFPROCpermute(depth%) 120LOCALc% 130 FORc%=1TOn% 140 IFNOTused%(c%)THEN 150 list%(depth%)=c% 160 used%(c%)=TRUE 170 IFdepth%=n%THEN 180 IFp%THEN 190 FORd%=1TOn% 200 CASElist%(d%)OF 210 WHEN1:IFd%=1THENPRINT"Belle marquise,";ELSEIFd%=5THENPRINT", belle marquise."ELSEPRINT", belle marquise,"; 220 WHEN2:IFd%=1THENPRINT"Vos yeux";ELSEIFd%=5THENPRINT" vos yeux."ELSEPRINT" vos yeux"; 230 WHEN3:IFd%=1THENPRINT"Me font";ELSEIFd%=5THENPRINT" me font."ELSEPRINT" me font"; 240 WHEN4:IFd%=1THENPRINT"Mourir";ELSEIFd%=5THENPRINT" mourir."ELSEPRINT" mourir"; 250 WHEN5:IFd%=1THENPRINT"D'amour";ELSEIFd%=5THENPRINT" d'amour."ELSEPRINT" d'amour"; 260 ENDCASE 270 NEXT 280 ELSE 290 PRINT"(";:FORd%=1TOn%:PRINT;list%(d%);:NEXT:PRINT")" 300 ENDIF 310 ELSE 320 PROCpermute(depth%+1) 330 ENDIF 340 used%(c%)=FALSE 350 ENDIF 360 NEXT 370ENDPROC
*�>>> Recursively list all permutations 9� Alain BROBECKER (baah/Arm's Tech) on 30-Jun-1997 6� Poetry added thanks to MOLIERE on 29-Nov-1997 (-�"Are you a poet";p$:p%=(p$="y")�(p$="Y") 2+�p%�n%=5��"How many elts to permute";n% <�list%(n%),used%(n%) F�c%=1�n%:used%(c%)=�:� P�permute(1) Z� d n��permute(depth%) x�c% � �c%=1�n% � �used%(c%)� � list%(depth%)=c% � used%(c%)=� � �depth%=n%� � �p%� � �d%=1�n% � Ȏlist%(d%)� �X �1:�d%=1��"Belle marquise,";��d%=5��", belle marquise."��", belle marquise,"; �B �2:�d%=1��"Vos yeux";��d%=5��" vos yeux."��" vos yeux"; �? �3:�d%=1��"Me font";��d%=5��" me font."��" me font"; �< �4:�d%=1��"Mourir";��d%=5��" mourir."��" mourir"; �? �5:�d%=1��"D'amour";��d%=5��" d'amour."��" d'amour"; � � � "+ �"(";:�d%=1�n%:�;list%(d%);:�:�")" , � 6 � @ �permute(depth%+1) J � T used%(c%)=� ^ � h � r� �
00000000 0d 00 0a 2a f4 3e 3e 3e 20 52 65 63 75 72 73 69 |...*.>>> Recursi| 00000010 76 65 6c 79 20 6c 69 73 74 20 61 6c 6c 20 70 65 |vely list all pe| 00000020 72 6d 75 74 61 74 69 6f 6e 73 0d 00 14 39 f4 20 |rmutations...9. | 00000030 20 20 20 41 6c 61 69 6e 20 42 52 4f 42 45 43 4b | Alain BROBECK| 00000040 45 52 20 28 62 61 61 68 2f 41 72 6d 27 73 20 54 |ER (baah/Arm's T| 00000050 65 63 68 29 20 6f 6e 20 33 30 2d 4a 75 6e 2d 31 |ech) on 30-Jun-1| 00000060 39 39 37 0d 00 1e 36 f4 20 20 20 20 50 6f 65 74 |997...6. Poet| 00000070 72 79 20 61 64 64 65 64 20 74 68 61 6e 6b 73 20 |ry added thanks | 00000080 74 6f 20 4d 4f 4c 49 45 52 45 20 6f 6e 20 32 39 |to MOLIERE on 29| 00000090 2d 4e 6f 76 2d 31 39 39 37 0d 00 28 2d e8 22 41 |-Nov-1997..(-."A| 000000a0 72 65 20 79 6f 75 20 61 20 70 6f 65 74 22 3b 70 |re you a poet";p| 000000b0 24 3a 70 25 3d 28 70 24 3d 22 79 22 29 84 28 70 |$:p%=(p$="y").(p| 000000c0 24 3d 22 59 22 29 0d 00 32 2b e7 70 25 8c 6e 25 |$="Y")..2+.p%.n%| 000000d0 3d 35 8b e8 22 48 6f 77 20 6d 61 6e 79 20 65 6c |=5.."How many el| 000000e0 74 73 20 74 6f 20 70 65 72 6d 75 74 65 22 3b 6e |ts to permute";n| 000000f0 25 0d 00 3c 18 de 6c 69 73 74 25 28 6e 25 29 2c |%..<..list%(n%),| 00000100 75 73 65 64 25 28 6e 25 29 0d 00 46 1a e3 63 25 |used%(n%)..F..c%| 00000110 3d 31 b8 6e 25 3a 75 73 65 64 25 28 63 25 29 3d |=1.n%:used%(c%)=| 00000120 a3 3a ed 0d 00 50 0f f2 70 65 72 6d 75 74 65 28 |.:...P..permute(| 00000130 31 29 0d 00 5a 05 e0 0d 00 64 04 0d 00 6e 15 dd |1)..Z....d...n..| 00000140 f2 70 65 72 6d 75 74 65 28 64 65 70 74 68 25 29 |.permute(depth%)| 00000150 0d 00 78 07 ea 63 25 0d 00 82 0d 20 e3 63 25 3d |..x..c%.... .c%=| 00000160 31 b8 6e 25 0d 00 8c 12 20 20 e7 ac 75 73 65 64 |1.n%.... ..used| 00000170 25 28 63 25 29 8c 0d 00 96 17 20 20 20 6c 69 73 |%(c%)..... lis| 00000180 74 25 28 64 65 70 74 68 25 29 3d 63 25 0d 00 a0 |t%(depth%)=c%...| 00000190 12 20 20 20 75 73 65 64 25 28 63 25 29 3d b9 0d |. used%(c%)=..| 000001a0 00 aa 12 20 20 20 e7 64 65 70 74 68 25 3d 6e 25 |... .depth%=n%| 000001b0 8c 0d 00 b4 0c 20 20 20 20 e7 70 25 8c 0d 00 be |..... .p%....| 000001c0 11 20 20 20 20 20 e3 64 25 3d 31 b8 6e 25 0d 00 |. .d%=1.n%..| 000001d0 c8 16 20 20 20 20 20 20 c8 8e 6c 69 73 74 25 28 |.. ..list%(| 000001e0 64 25 29 ca 0d 00 d2 58 20 20 20 20 20 20 20 c9 |d%)....X .| 000001f0 31 3a e7 64 25 3d 31 8c f1 22 42 65 6c 6c 65 20 |1:.d%=1.."Belle | 00000200 6d 61 72 71 75 69 73 65 2c 22 3b 8b e7 64 25 3d |marquise,";..d%=| 00000210 35 8c f1 22 2c 20 62 65 6c 6c 65 20 6d 61 72 71 |5..", belle marq| 00000220 75 69 73 65 2e 22 8b f1 22 2c 20 62 65 6c 6c 65 |uise."..", belle| 00000230 20 6d 61 72 71 75 69 73 65 2c 22 3b 0d 00 dc 42 | marquise,";...B| 00000240 20 20 20 20 20 20 20 c9 32 3a e7 64 25 3d 31 8c | .2:.d%=1.| 00000250 f1 22 56 6f 73 20 79 65 75 78 22 3b 8b e7 64 25 |."Vos yeux";..d%| 00000260 3d 35 8c f1 22 20 76 6f 73 20 79 65 75 78 2e 22 |=5.." vos yeux."| 00000270 8b f1 22 20 76 6f 73 20 79 65 75 78 22 3b 0d 00 |.." vos yeux";..| 00000280 e6 3f 20 20 20 20 20 20 20 c9 33 3a e7 64 25 3d |.? .3:.d%=| 00000290 31 8c f1 22 4d 65 20 66 6f 6e 74 22 3b 8b e7 64 |1.."Me font";..d| 000002a0 25 3d 35 8c f1 22 20 6d 65 20 66 6f 6e 74 2e 22 |%=5.." me font."| 000002b0 8b f1 22 20 6d 65 20 66 6f 6e 74 22 3b 0d 00 f0 |.." me font";...| 000002c0 3c 20 20 20 20 20 20 20 c9 34 3a e7 64 25 3d 31 |< .4:.d%=1| 000002d0 8c f1 22 4d 6f 75 72 69 72 22 3b 8b e7 64 25 3d |.."Mourir";..d%=| 000002e0 35 8c f1 22 20 6d 6f 75 72 69 72 2e 22 8b f1 22 |5.." mourir.".."| 000002f0 20 6d 6f 75 72 69 72 22 3b 0d 00 fa 3f 20 20 20 | mourir";...? | 00000300 20 20 20 20 c9 35 3a e7 64 25 3d 31 8c f1 22 44 | .5:.d%=1.."D| 00000310 27 61 6d 6f 75 72 22 3b 8b e7 64 25 3d 35 8c f1 |'amour";..d%=5..| 00000320 22 20 64 27 61 6d 6f 75 72 2e 22 8b f1 22 20 64 |" d'amour.".." d| 00000330 27 61 6d 6f 75 72 22 3b 0d 01 04 0b 20 20 20 20 |'amour";.... | 00000340 20 20 cb 0d 01 0e 0a 20 20 20 20 20 ed 0d 01 18 | ..... ....| 00000350 09 20 20 20 20 cc 0d 01 22 2b 20 20 20 20 20 f1 |. ..."+ .| 00000360 22 28 22 3b 3a e3 64 25 3d 31 b8 6e 25 3a f1 3b |"(";:.d%=1.n%:.;| 00000370 6c 69 73 74 25 28 64 25 29 3b 3a ed 3a f1 22 29 |list%(d%);:.:.")| 00000380 22 0d 01 2c 09 20 20 20 20 cd 0d 01 36 08 20 20 |"..,. ...6. | 00000390 20 cc 0d 01 40 1a 20 20 20 20 f2 70 65 72 6d 75 | ...@. .permu| 000003a0 74 65 28 64 65 70 74 68 25 2b 31 29 0d 01 4a 08 |te(depth%+1)..J.| 000003b0 20 20 20 cd 0d 01 54 12 20 20 20 75 73 65 64 25 | ...T. used%| 000003c0 28 63 25 29 3d a3 0d 01 5e 07 20 20 cd 0d 01 68 |(c%)=...^. ...h| 000003d0 06 20 ed 0d 01 72 05 e1 0d ff |. ...r....| 000003da