A puzzle for Pythonistas
Anton Vredegoor
anton at vredegoor.doge.nl
Sat Feb 1 11:55:38 EST 2003
On Sat, 1 Feb 2003 08:20:44 -0500, Jack Diederich
<jack at performancedrivers.com> wrote:
>It is also written in C so it is much faster than a pure-python equiv.
>A few hundred people have used it, so it is at least relatively bug free :)
C is harder to diagnose and download figures can be deceptive. Please
rename my script to anton1 before running this test script. Also
there's a slight cosmetic fix possible for my script in replacing
"cum,tresh,rest = 0,0,val" into "tresh,rest = 0,val" since the extra
variable is not used.
Regards,
Anton.
from probstat import Combination
from anton1 import combinations
def test():
ac = combinations(33,16)
pc = Combination(range(33),16)
print ac[ac.count-1]
print pc[-1]
ac = combinations(34,16)
pc = Combination(range(34),16)
print ac[ac.count-1]
print pc[-1]
if __name__=='__main__':
test()
output is:
[17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
[17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
[18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
Traceback (most recent call last):
File "pstest.py", line 15, in ?
test()
File "pstest.py", line 12, in test
print pc[-1]
SystemError: error return without exception set
More information about the Python-list
mailing list