Hi,

I'm new to Python and am very impressed with it.  Unfortunately I am not yet
at the stage where I can convert the GFA Basic code below into Python.  Can
anyone help please?  Any response appreciated and will certainly help me to
understand more about Python.  BTW This is not a challenge to Python, it's
more like a challenge from a pal to me.

Thanks Ed

--------------------------   GFA Basic
Code ----------------------------------

I made a speed test with the following
program. It writes all 8 million combinations of
6 of 45 into a field R() and gives each combination
a line number, starting from 1 to 8145060 and then
it prints the last line to show that all lines are filled.
Option Base 1 means, that the first index starts with
1 and not with 0.


Print "starting time    ";
Print Time$
Global a As Int = 0
Global b As Int = 0
Global c As Int = 0
Global d As Int = 0
Global e As Int = 0
Global f As Int = 0
Local i As Int = 0

Dim R(8145060, 7) As Int
Option Base 1

For a = 1 To 40
  For b = a + 1 To 41
    For c = b + 1 To 42
      For d = c + 1 To 43
        For e = d + 1 To 44
          For f = e + 1 To  45

            i =  i + 1
            R(i, 1) = a
            R(i, 2) = b
            R(i, 3) = c
            R(i, 4) = d
            R(i, 5) = e
            R(i, 6) = f
            R(i, 7) = i

          Next f
        Next e
      Next d
    Next c
  Next b
Next a
Print "finished time   ";
Print Time$
Print "i =" ; i
Print R(i, 7), R(i, 1); R(i, 2); R(i, 3); R(i, 4); R(i, 5); R(i, 6)


The result of this code:

starting time :    10:06:30
finished time:    10:06:41
i = 8145060
8145060                40 41 42 43 44 45

--------------------------   GFA Basic
Code ----------------------------------

Within 11 seconds all 8145060 combinations of 6 of 45
have been written into a table together with a line
identification number at position R(i,7) ,
at a 800 MHz computer with 195 MB memory.



_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to