100 REM The operation of this program is described in the paper 110 REM "Permutation Lattices Revisited", written by George Markowsky 120 REM and published in Mathematical Social Sciences, 27 (1994), pp. 59-74 130 REM The program is copyrighted 2001 and maybe freely distributed 140 REM provided this notice is included in the program. 150 REM This program is designed to illustrate the principles discussed 160 REM in the paper. It is left to the user to adapt it to any particular 170 REM purpose. All risks associated with using this program are assumed 180 REM by the user. The code is provided as is for instructional purposes. 190 REM This program creates tables to convert between multi-permutations 200 REM and permutations. Sample data is included in the program. 210 READ K,N 220 DATA 5,16 230 DIM START(K),OFFSET(K),BACK(N),IP(N),OP(N) 240 LET START(1) = 1 250 FOR I = 1 TO K-1 260 READ J 270 LET START(I+1) = START(I)+J 280 FOR A = START(I) TO START(I+1)-1 : LET BACK(A) = I : NEXT A 290 NEXT I 300 DATA 3,4,3,2 310 FOR A = START(K) TO N : LET BACK(A) = K : NEXT A 320 REM This part converts a multi-permutation to a permutation. 330 FOR I = 1 TO K : LET OFFSET(I) = 0 : NEXT I 340 FOR I = 1 TO N 350 READ IP(I) 360 DATA 2,1,3,5,2,5,4,4,1,2,5,3,3,5,2,1 370 LET OP(I) = START(IP(I))+OFFSET(IP(I)) 380 LET OFFSET(IP(I)) = OFFSET(IP(I)) + 1 390 NEXT I 400 FOR I = 1 TO N : PRINT IP(I); : NEXT I : PRINT 410 FOR I = 1 TO N : PRINT OP(I); : NEXT I : PRINT 420 REM This converts a permutation to a multi-permutation. 430 FOR I = 1 TO N : IP(I) = BACK(OP(I)) : NEXT I 440 FOR I = 1 TO N : PRINT IP(I); : NEXT I : PRINT