Skip to main content
1 of 2
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384

05AB1E, 4 bytes

3Fgì

Similar as my answer for the related challenge, but with a prepend instead of append. Will therefore also always use the smallest (9 instead of 10) if more than one option is available.

Try it online or verify all test cases.

Explanation:

3F    # Loop 3 times:
  g   #  Pop the current string, and push its length
      #  (which will use the implicit input-string in the first iteration)
   «  #  Prepend this length to the (implicit) input-string
      # (after which the result is output implicitly)
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384