I just noticed that some of the fastest solutions to INUMBER (http://www.spoj.pl/problems/INUMBER) are in Python. I solved this one quite a while back, and I remember that I had to do a bit of optimizing just to get my C++ solution to pass. Can someone please share their fast code secrets for this problem?
Thanks in advance.
It's just machine code (possibly compiled from low-level C or Assembly), encoded in a variable, and hooked in to run through the Python interpreter .
Thanks for the clarification. I guess it is the only way to get a 'python' submission run that fast.
OTOH, I noticed that the third fastest Python solution is by Tim Peters (http://www.spoj.pl/ranks/INUMBER/lang=PYTH). I'd be surprised if even he had used something like that.
Tim Peters' solution is indeed perfectly valid Python code (only highly optimized ). I'm afraid I don't know Python well enough to explain the general idea.
BTW, in the overall ranks you will find that there exist faster solutions in other languages (spoj.pl/ranks/INUMBER/).
I knew Tim Peters must have used some really masterful techniques. I guess I'll just have to figure them out myself.
Thanks for all your help.