News for hackers. Stuff that matters.
Re:Tech Companies Want You to Believe America Has a Skills Gap by pmiller2 on Wednesday August 05, 2020 @05:33PM (#24065867)
If you want to be tricky about it, you can do it in one line in Python. Let d be your original integer. Then

    [(d%10**(n+1) - d%10**n) / 10**n for n in reversed(xrange(int(log10(d)+1)))]
will be a list containing the base 10 digits of d as integers.

Technically, you need to do

    from math import log10
to make this work, but you can fit that on the same line with a little hacking around using __import__, such as this quick and very dirty attempt:

    [ [(d%10**(n+1) - d%10**n) / 10**n for n in reversed(xrange(int(log10(d)+1)))] for log10 in [__import__("math", fromlist=["log10"]).log10]][0]
Edit:

Just to carry this a little further, if we interpret "a new integer that's the result of each of the original integer's digits squared" as doing something like this:

    129 -> 1481
(i.e. 9 gets replaced with 81), then we can do it in one line like this:

     int(''.join([str(x**2) for x in [(d%10**(n+1) - d%10**n) / 10**n for n in reversed(xrange(int(log10(d)+1)))]]))
Re:Tech Companies Want You to Believe America Has a Skills Gap by quacked on Thursday August 06, 2020 @10:02AM (#24070953)
Ooh, nice.