Skip to main content
The 2024 Developer Survey results are live! See the results
added 2 characters in body
Source Link
Dominic van Essen
  • 35.6k
  • 2
  • 21
  • 57

Completely different approach for same bytes: successively halve the string and take pairwise differences.

Attempt This Online!

A completely different approach for same bytes: successively halve the string and take pairwise differences.

Completely different approach for same bytes: successively halve the string and take pairwise differences.

Attempt This Online!

Attempt This Online!

A completely different approach for same bytes: successively halve the string and take pairwise differences.

Source Link
Dominic van Essen
  • 35.6k
  • 2
  • 21
  • 57

Nibbles, 17 nibbles (8.5 bytes)

| . `,,$ <;^2$ >-$~ _

Attempt This Online!

  .                     # map over
    `,                  # range from zero to
      ,$                # length of input:
         <              #   take the first
           ^2$          #   2^n characters
          ;             #   (and save that number)
                        #   from
               >        #   drop the first
                -$~     #   saved number minus 1
                        #   characters
                        #   from
                    _   #   the input
|                       # and finally filter-out 
                        # any empty strings

Completely different approach for same bytes: successively halve the string and take pairwise differences.

Nibbles, 17 nibbles (8.5 bytes)

\ ! ;`. $ </,$~$ >>@ ~ -

Attempt This Online!

\ ! ;`. $ </,$~$ >>@ ~ -
     `'                     # iterate while unique
        $                   # starting with the input:
          <                 #   select the first
           /,$~             #   half its length
               $            #   characters
    ;                       # and save this list;
  !                         # now, zip this list with
                 >>@        # itself without the first element:
                     ~ -    #   get differences;
\                           # finally, reverse it

This would be 1 nibble shorter if we're allowed to output the divided segments in reverse order.