Skip to main content
added explanation
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Perl 6, 38 bytes

{1 xx$_,*.rotor(2,:partial)>>.sum...1}

Try it online!

There's some shortcut to partial rotoring that I'm not remembering right now...

Explanation:

{                                    }  # Anonymous code block
                                 ...    # Return a sequence
 1 xx$_,            # Starting with a list of 1s with input length
        *           # Where each element is
         .rotor(2,:partial)        # The previous list split into chunks of 2 or less
                           >>.sum  # And each chunk summed
                                    1  # Until the list is length 1

Perl 6, 38 bytes

{1 xx$_,*.rotor(2,:partial)>>.sum...1}

Try it online!

There's some shortcut to partial rotoring that I'm not remembering right now...

Perl 6, 38 bytes

{1 xx$_,*.rotor(2,:partial)>>.sum...1}

Try it online!

There's some shortcut to partial rotoring that I'm not remembering right now...

Explanation:

{                                    }  # Anonymous code block
                                 ...    # Return a sequence
 1 xx$_,            # Starting with a list of 1s with input length
        *           # Where each element is
         .rotor(2,:partial)        # The previous list split into chunks of 2 or less
                           >>.sum  # And each chunk summed
                                    1  # Until the list is length 1
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Perl 6, 38 bytes

{1 xx$_,*.rotor(2,:partial)>>.sum...1}

Try it online!

There's some shortcut to partial rotoring that I'm not remembering right now...