User:StuRat/perm2

program perm2

implicit     none integer*2    A,B,C,D,E,F,G,LEVEL integer      NB_FOUND character*7  RESULT character*11 STRING(9) character*9  ARRAY(400000)


 * integer*2    bench ! For benchmarking only.

call system('ECHO. | time | find "urrent time is"')
 * DO bench = 1,100 ! For benchmarking only.

STRING(1) = ' 123456789 '

NB_FOUND = 0 DO A = 1,9 LEVEL = 1 RESULT = STRING(LEVEL)(A+1:A+1) STRING(LEVEL+1) = STRING(LEVEL)(:A)// +                  STRING(LEVEL)(A+2:) DO B = 1,8 LEVEL = 2 RESULT(LEVEL:LEVEL) = STRING(LEVEL)(B+1:B+1) STRING(LEVEL+1) = STRING(LEVEL)(:B)// +                   STRING(LEVEL)(B+2:) DO C = 1,7 LEVEL = 3 RESULT(LEVEL:LEVEL) = STRING(LEVEL)(C+1:C+1) STRING(LEVEL+1) = STRING(LEVEL)(:C)// +                    STRING(LEVEL)(C+2:) DO D = 1,6 LEVEL = 4 RESULT(LEVEL:LEVEL) = STRING(LEVEL)(D+1:D+1) STRING(LEVEL+1) = STRING(LEVEL)(:D)// +                     STRING(LEVEL)(D+2:) DO E = 1,5 LEVEL = 5 RESULT(LEVEL:LEVEL) = STRING(LEVEL)(E+1:E+1) STRING(LEVEL+1) = STRING(LEVEL)(:E)// +                      STRING(LEVEL)(E+2:) DO F = 1,4 LEVEL = 6 RESULT(LEVEL:LEVEL) = STRING(LEVEL)(F+1:F+1) STRING(LEVEL+1) = STRING(LEVEL)(:F)// +                       STRING(LEVEL)(F+2:) DO G = 1,3 LEVEL = 7 RESULT(LEVEL:LEVEL) = STRING(LEVEL)(G+1:G+1) STRING(LEVEL+1) = STRING(LEVEL)(:G)// +                        STRING(LEVEL)(G+2:) NB_FOUND=NB_FOUND+1 ARRAY(NB_FOUND)= RESULT// +         STRING(LEVEL+1)(2:2)// +         STRING(LEVEL+1)(3:3) NB_FOUND=NB_FOUND+1 ARRAY(NB_FOUND)= RESULT// +         STRING(LEVEL+1)(3:3)// +         STRING(LEVEL+1)(2:2) goto 100 ! Bypass all prints. print *,'ARRAY(',NB_FOUND-1,') =', +                ARRAY(  NB_FOUND-1  ) print *,'ARRAY(',NB_FOUND ,') =', +                ARRAY(  NB_FOUND    ) 100       continue ENDDO ENDDO ENDDO ENDDO ENDDO ENDDO ENDDO
 * if (NB_FOUND .gt. 24) goto 100 ! Bypass all but first 24 prints.


 * ENDDO ! For benchmarking only.

print *,'Last item found: ARRAY(',NB_FOUND,') =', +                         ARRAY(  NB_FOUND  )

call system('ECHO. | time | find "urrent time is"')

end