News for hackers. Stuff that matters.
Re:Ruby is too slow for programming competitions by jdotjdot on Sunday April 21, 2013 @02:22PM (#5585759)
I've has decent experiences with Python in Google Code Jam, with two exceptions. (1) Python can't handle large numbers, so the mere existence of huge integer inputs for the large prime number problem blew up my code since Python could not convert numbers that large. (2) Python is fine with math, but at a certain point of data accumulation, performance just plummets, no matter how good your algorithm is. Overall, though, I haven't had the experience the parent comment did. Either Python works beautifully or it literally just doesn't work, rather than take an hour.

I treat it as a challenge, though, as it forces me to be smarter about my implementation.

Re:Ruby is too slow for programming competitions by Luyt on Sunday April 21, 2013 @02:56PM (#5585904)
Python can't handle large numbers

Are you sure? Can you post a number of which you think Python can't handle?

    >>> int("983728338427643876432784367834678326438763278463276543675324675327867498274982787463273647235347652673547623548628347892374982374862384676235478632894790238409382984782768347683274983274964826487264826482264862384628648723643874268426482634826438742648276487264823764873627463252642654")

    983728338427643876432784367834678326438763278463276543675324675327867498274982787463273647235347652673547623548628347892374982374862384676235478632894790238409382984782768347683274983274964826487264826482264862384628648723643874268426482634826438742648276487264823764873627463252642654L
    >>>
Re:Ruby is too slow for programming competitions by minopret on Sunday April 21, 2013 @02:49PM (#5585872)
(1) In what sense do you mean "Python can't handle large numbers"?

    time python -c 'print (5**(5**5))*(3**(3**3))' \
    | python -c 'import sys; print hex(int(sys.stdin.read()))'  \
    | wc -c
        1829

    real	0m0.091s
    user	0m0.149s
    sys	0m0.027s
Re:Ruby is too slow for programming competitions by omaranto on Sunday April 21, 2013 @03:00PM (#5585930)
What do you mean Python cannot handle large numbers? It has an arbitrary precision integer data type built in:

    >>> 3**1000     132207081948080663689045525975214436596542203275214816767783138506080619639097776968725823559509545821006189118620803878014774228964841274390400117588618041128947815623617812548034440554705439703889581746536825491613622083028969185564040848989376093732421718463599386955167650189414350385648747165832010614366132173102768902855220001
Re:Ruby is too slow for programming competitions by masklinn on Sunday April 21, 2013 @03:03PM (#5585944)
> Python can't handle large numbers, so the mere existence of huge integer inputs for the large prime number problem blew up my code since Python could not convert numbers that large.

Beg pardon?

    >>> 2**2**2**2**2
    [snipped because HN does not allow 20k comments)