[Shootout-list] Another version of harmonic.python

Tim Rowe digitig at gmail.com
Sun Apr 23 22:57:16 UTC 2006


This uses the same algorithm but different language features. I can't
tell whether this is faster or slower than my previous submission, but
it scores well on line count!

#!/usr/bin/python
# http://shootout.alioth.debian.org/
#
# Contributed by Tim Rowe

import sys

print reduce(lambda x, y: x + 1.0 / y, range(1, int(sys.argv[1]) + 1), 0.0)


-- 
Tim Rowe



More information about the Shootout-list mailing list