Quantcast
Viewing latest article 21
Browse Latest Browse All 23

Answer by FryAmTheEggman for All about basic binary

Pyth, 14 13

jbf!-jQTU2tSQ

Thanks to Jakube for pointing out the new S function.

Try it here.

The online version is too slow to do 1234321. This simply converts the input to each base from 2 to itself and discards the results that contain values other than 0 and 1.

Explanation:

                           : Q=eval(input) (implicit)jb                         : join on newlines the list...  f!                       : filter away nonempty values (impliticly named T)    -jQTU2                 : sewtise difference of number converted to base and range(2)     jQT                   : convert Q to base T        U2                 : range(2)          tSQ              : over the range [2 Q+1)

In addition, this is a (not well golfed now well golfed, again thanks to Jakube) bonus version (20 * .75 = 15):

VQI!-JjQK+2NU2pdKjkJ

Try it here


Viewing latest article 21
Browse Latest Browse All 23

Trending Articles