Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
4 replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
source | link

Retina, 33 bytes

.+
$*
^11
a¶b
+`¶(.+?)1
¶$1¶$%`$1

Try it online!

Saved 10 (!) bytes thanks to @MartinEnderMartinEnder!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

Retina, 33 bytes

.+
$*
^11
a¶b
+`¶(.+?)1
¶$1¶$%`$1

Try it online!

Saved 10 (!) bytes thanks to @MartinEnder!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

Retina, 33 bytes

.+
$*
^11
a¶b
+`¶(.+?)1
¶$1¶$%`$1

Try it online!

Saved 10 (!) bytes thanks to @MartinEnder!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

3 added 98 characters in body
source | link

Retina, 4333 bytes

.+
$*
11(1*)^11
a¶b$1a¶b
+`(.+)¶+`¶(.+?)1
$1¶$2¶$1$2¶$1¶$%`$1

Try it online!Try it online!

Saved 10 (!) bytes thanks to @MartinEnder!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

Retina, 43 bytes

.+
$*
11(1*)
a¶b$1
+`(.+)¶(.+?)1
$1¶$2¶$1$2

Try it online!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

Retina, 33 bytes

.+
$*
^11
a¶b
+`¶(.+?)1
¶$1¶$%`$1

Try it online!

Saved 10 (!) bytes thanks to @MartinEnder!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

2 -2 bytes using ungreedy modifier
source | link

Retina, 4543 bytes

.+
$*
11(1*)
a¶b¶$1a¶b$1
+`(.+)¶(.+)¶1
$1¶$2¶$1$2¶

Try it online!

or

.+
$*
11(1*)
a¶b$1
+`(.+)¶([ab]+?)1
$1¶$2¶$1$2

Try it online!Try it online!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous lines strings.

Retina, 45 bytes

.+
$*
11(1*)
a¶b¶$1
+`(.+)¶(.+)¶1
$1¶$2¶$1$2¶

Try it online!

or

.+
$*
11(1*)
a¶b$1
+`(.+)¶([ab]+)1
$1¶$2¶$1$2

Try it online!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous lines strings.

Retina, 43 bytes

.+
$*
11(1*)
a¶b$1
+`(.+)¶(.+?)1
$1¶$2¶$1$2

Try it online!

Explanation

Converts the input to unary, subtracts 2 and adds the a and the b, then recursively replaces the remaining 1s with the concatenation of the two previous strings.

1
source | link