Hi Ed,

I transformed the programm 1:1 to Python
without to use special Numeric-Extensions.
My K6-2 with 400 MHz show this result:

starting time
Tue Apr 09 12:27:33 2002
finished time
Tue Apr 09 12:30:13 2002
i = 8145060
8145060 40 41 42 43 44 45


import time

print "starting time    "
print time.ctime()

R = [[0]*(7+1)]*(8145060+1)
i = 0

for a in xrange(1, 40+1):
  for b in xrange(a+1, 41+1):
    for c in xrange(b+1, 42+1):
      for d in xrange(c+1, 43+1):
        for e in xrange(d+1, 44+1):
          for f in xrange(e+1, 45+1):

            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

print "finished time   ";
print time.ctime()
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]


----- Original Message ----- 
From: "Ed Hopkins" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 09, 2002 5:39 AM
Subject: Conversion from GFA Basic to Python for SpeedTest


> 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
> 



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

Reply via email to