Skip to main content
added 28 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 3, 5756 bytes

lambda n:inteval((bin(n).rstrip("0")+"01"*n)[:len(bin(n))],2)

Try it online!Try it online!

Not really happy with this yet, but I really didn't want to use the formula... -2 thanks to Rod. -1 thanks to Jonathan Frech.

Python 3, 57 bytes

lambda n:int((bin(n).rstrip("0")+"01"*n)[:len(bin(n))],2)

Try it online!

Not really happy with this yet, but I really didn't want to use the formula... -2 thanks to Rod.

Python 3, 56 bytes

lambda n:eval((bin(n).rstrip("0")+"01"*n)[:len(bin(n))])

Try it online!

Not really happy with this yet, but I really didn't want to use the formula... -2 thanks to Rod. -1 thanks to Jonathan Frech.

added 45 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 3, 57 bytes

lambda n:int((bin(n).rstrip("0")+"01"*n)[:len(bin(n))],2)

Try it online!

Not really happy with this yet, but I really didn't want to use the formula... -2 thanks to Rod.

Python 3, 57 bytes

lambda n:int((bin(n).rstrip("0")+"01"*n)[:len(bin(n))],2)

Try it online!

Not really happy with this yet... -2 thanks to Rod.

Python 3, 57 bytes

lambda n:int((bin(n).rstrip("0")+"01"*n)[:len(bin(n))],2)

Try it online!

Not really happy with this yet, but I really didn't want to use the formula... -2 thanks to Rod.

added 69 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 3, 5957 bytes

lambda n:int((bin(n).striprstrip("0")+"01"*n)[1[:len(bin(n))-1]],2)

Try it online!Try it online!

Not really happy with this yet... -2 thanks to Rod.

Python 3, 59 bytes

lambda n:int((bin(n).strip("0")+"01"*n)[1:len(bin(n))-1],2)

Try it online!

Not really happy with this yet...

Python 3, 57 bytes

lambda n:int((bin(n).rstrip("0")+"01"*n)[:len(bin(n))],2)

Try it online!

Not really happy with this yet... -2 thanks to Rod.

Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading