News for hackers. Stuff that matters.
Re:Python coding interview challenges by soVeryTired on Monday April 03, 2017 @10:17AM (#14022896)
log(exp(5)*exp(6))?

Guess that won't work too well with larger numbers...

Re:Python coding interview challenges by dr_zoidberg on Monday April 03, 2017 @11:17AM (#14023374)
It breaks quite early:

    In [8]: math.log(math.exp(5000) * math.exp(6000))
    ---------------------------------------------------------------------------
    OverflowError                             Traceback (most recent call last)
    <ipython-input-8-3d6e46c58c45> in <module>()
    ----> 1 math.log(math.exp(5000) * math.exp(6000))

    OverflowError: math range error

    In [9]: math.log(math.exp(500) * math.exp(600))
    Out[9]: inf
Re:Python coding interview challenges by brianwawok on Monday April 03, 2017 @11:35AM (#14023547)
Hey let's not be a quitter

    >>> (Decimal(5000).exp() * Decimal(6000).exp()).ln()
    Decimal('11000.00000000000000000000000')
Re:Python coding interview challenges by dr_zoidberg on Monday April 03, 2017 @12:06PM (#14023936)
Nice catch, but then:

    In [13]: Decimal(5000000).exp() * Decimal(5000000).exp()
    ---------------------------------------------------------------------------
    Overflow                                  Traceback (most recent call last)
    <ipython-input-13-8333724ae893> in <module>()
    ----> 1 Decimal(5000000).exp() * Decimal(5000000).exp()

    Overflow: [<class 'decimal.Overflow'>]
The problem is that the multiplication blows the precision of the used format (either double for math.log(...) or the one the decimal module uses).

I had also thought about the intention of the question trying to get you to express the sum as bit operations (thought I admit that sounds like going for a very low-level profile), or maybe just "thinking outside the box".

Re:Python coding interview challenges by brianwawok on Monday April 03, 2017 @12:21PM (#14024120)
Hey don't be a quitter, we can make Decimal support way bigger numbers via context
Re:Python coding interview challenges by dr_zoidberg on Monday April 03, 2017 @02:09PM (#14025416)
Alternative, buzzwordy approach: let's train a convolutional neural network to do addition!
Re:Python coding interview challenges by brianwawok on Monday April 03, 2017 @05:07PM (#14027149)
Can it run the MEAN stack?
Re:Python coding interview challenges by dr_zoidberg on Tuesday April 04, 2017 @02:25PM (#14035778)
Yes, and we'll deploy it on The Cloud.