Skip to main content
added 3 characters in body
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135

Retina, 90 bytes

#(..)$
#$1$1$1
#(.)(.)(.)$
#$1$1$2$2$3
#(.)(.)(.(.))$
#$1$4$2$4$3
#$
#0
+`#.{0,4}(.)$
$&$1

Try it online! Includes test cases. 

Explanation: The first translation handles two digits, the second one three, the third one four, and the fourth one zero. However, neither the second and fourth translations repeat the (last) digit, as that is done at the end anyway to cover all the remaining cases.

Retina, 90 bytes

#(..)$
#$1$1$1
#(.)(.)(.)$
#$1$1$2$2$3
#(.)(.)(.(.))$
#$1$4$2$4$3
#$
#0
+`#.{0,4}(.)$
$&$1

Try it online! Includes test cases. Explanation: The first translation handles two digits, the second one three, the third one four, and the fourth one zero. However, neither the second and fourth translations repeat the (last) digit, as that is done at the end anyway to cover all the remaining cases.

Retina, 90 bytes

#(..)$
#$1$1$1
#(.)(.)(.)$
#$1$1$2$2$3
#(.)(.)(.(.))$
#$1$4$2$4$3
#$
#0
+`#.{0,4}(.)$
$&$1

Try it online! Includes test cases. 

Explanation: The first translation handles two digits, the second one three, the third one four, and the fourth one zero. However, neither the second and fourth translations repeat the (last) digit, as that is done at the end anyway to cover all the remaining cases.

Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Retina, 90 bytes

#(..)$
#$1$1$1
#(.)(.)(.)$
#$1$1$2$2$3
#(.)(.)(.(.))$
#$1$4$2$4$3
#$
#0
+`#.{0,4}(.)$
$&$1

Try it online! Includes test cases. Explanation: The first translation handles two digits, the second one three, the third one four, and the fourth one zero. However, neither the second and fourth translations repeat the (last) digit, as that is done at the end anyway to cover all the remaining cases.