Skip to main content
Golfed 1 byte
Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 144

Pip, 2828 27 bytes

Wa>1&!aRMtaTa=1|aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop whileuntil a>1a=1 andor a is entirelycontains some character(s) besides 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a and checking whether. If there's anything left, the resultcondition is falsey (i.e. empty string)truthy.

Inside the loop, the conversion works as follows:

a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.

A recursive solution is alsoin 28-bytes bytes:

a<2|aRMt?a(f$+(^a)*2**RV,#a)

Pip, 28 bytes

Wa>1&!aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop while a>1 and a is entirely 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a and checking whether the result is falsey (i.e. empty string).

Inside the loop, the conversion works as follows:

a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.

A recursive solution is also 28-bytes:

a<2|aRMt?a(f$+(^a)*2**RV,#a)

Pip, 28 27 bytes

Ta=1|aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop until a=1 or a contains some character(s) besides 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a. If there's anything left, the condition is truthy.

Inside the loop, the conversion works as follows:

a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.

A recursive solution in 28 bytes:

a<2|aRMt?a(f$+(^a)*2**RV,#a)
Added recursive version
Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 144

Pip, 28 bytes

Wa>1&!aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop while a>1 and a is entirely 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a and checking whether the result is falsey (i.e. empty string).

Inside the loop, the conversion works as follows:

a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.

A recursive solution is also 28-bytes:

a<2|aRMt?a(f$+(^a)*2**RV,#a)

Pip, 28 bytes

Wa>1&!aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop while a>1 and a is entirely 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a and checking whether the result is falsey (i.e. empty string).

Inside the loop, the conversion works as follows:

a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.

Pip, 28 bytes

Wa>1&!aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop while a>1 and a is entirely 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a and checking whether the result is falsey (i.e. empty string).

Inside the loop, the conversion works as follows:

a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.

A recursive solution is also 28-bytes:

a<2|aRMt?a(f$+(^a)*2**RV,#a)
Source Link
DLosc
  • 40.7k
  • 6
  • 87
  • 144

Pip, 28 bytes

Wa>1&!aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop while a>1 and a is entirely 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a and checking whether the result is falsey (i.e. empty string).

Inside the loop, the conversion works as follows:

a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.