in reply to The 10**21 Problem (Part 4)
I'm afraid you didn't pick a very stable "magic function" to optimize for.
Mike
It doesn't work with the first Python 2.x I tested it on (which turns out to be 2.7.2):
It fails the same way with Python 2.6.7 on my Mac, but succeeds with Python 2.5.6:$ python Python 2.7.2 (default, Oct 27 2011, 17:53:49) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> /bb/build/Linux-x86_64-32/release/robolibs/big2014.21-611907-20140 +519105223/lib/dpkgroot KeyboardInterrupt >>> magic = chr(17)+chr(11)+chr(119)+chr(60)+chr(47)+chr(44)+chr(78)+c +hr(103)+chr(125)+chr(48) >>> for r in ["M", "D", "C", "L", "X", "V", "I"]: ... n = hash(r + magic) % 1001 ... print r, n ... M 338 D 602 C 93 L 733 X 555 V 933 I 402
$ python2.5 Python 2.5.6 (r256:88840, Oct 11 2012, 20:14:10) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on +darwin Type "help", "copyright", "credits" or "license" for more information. >>> magic = chr(17)+chr(11)+chr(119)+chr(60)+chr(47)+chr(44)+chr(78)+c +hr(103)+chr(125)+chr(48) >>> for r in ["M", "D", "C", "L", "X", "V", "I"]: ... n = hash(r + magic) % 1001 ... print r, n ... M 1000 D 500 C 100 L 50 X 10 V 5 I 1
Mike
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: The 10**21 Problem (Part 4)
by eyepopslikeamosquito (Archbishop) on May 19, 2014 at 22:04 UTC | |
by RMGir (Prior) on May 19, 2014 at 23:19 UTC | |
by eyepopslikeamosquito (Archbishop) on May 20, 2014 at 13:12 UTC | |
Re^2: The 10**21 Problem (Part 4)
by mr_mischief (Monsignor) on May 19, 2014 at 20:15 UTC |
In Section
Meditations