Quantcast
Viewing latest article 18
Browse Latest Browse All 23

Answer by nimi for All about basic binary

Haskell 109*0.75 = 81.75 bytes

0#x=[]n#x=n`mod`x:div n x#x f n=[show x++'':(n#x>>=show)|x<-[2..n+1],all(<2)$n#x]p=interact$unlines.f.read

Usage example (note: binary values are lsb first):

p 820002 000010100000001013 100111110114 0011000115 0001110181999 1182000 01

Without input/output restrictions, i.e input via function argument, output in native format via REPL):

Haskell, 67*0.75 = 50.25 bytes

0#x=[]n#x=n`mod`x:div n x#xf n=[(x,n#x)|x<-[2..n+1],all(<2)$n#x]

Returns a list of (base,value) pairs. The values are lsb first, e.g. (newlines/spaces added for better display):

 f 82000 [ (2,[0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1]),   (3,[1,0,0,1,1,1,1,1,0,1,1]),   (4,[0,0,1,1,0,0,0,1,1]),   (5,[0,0,0,1,1,1,0,1]),   (81999,[1,1]),   (82000,[0,1]) ] 

Viewing latest article 18
Browse Latest Browse All 23

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>