Skip to main content
added 286 characters in body
Source Link
Jordan
  • 11.3k
  • 1
  • 33
  • 55

GNU sed, 261 + 1 = 262 bytes

+1 byte for -r flag.

s/000/;/g
s/111/_/g
s/0//g
s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/
:
s/([1_]+);(.*([^1_])\1)/\3\2/
t
y/i/1/
s/;/ /g
s/:.*//g

Try it online!

Explanation

This is a very basic lookup table solution. 

The first three lines transform the input so dashes are _s and dots are 1s. CharactersFirst, 000s are replaced with ;, so characters are separated by ; and words by ;;0. Then 111s are separatedreplaced by ;;_ and all remaining 0s are discarded, leaving 1s for dots.

s/000/;/g
s/111/_/g
s/0//g

The next line appends the lookup table. It takes the form cmcmcm... where c is a character and m is the sequence of _s and 1s representing it. i is substituted for 1 in the table for disambiguation:. Since regular expressions in sed are always greedy, the table is sorted from longest to shortest code (so e.g. 1_ matches A1_ instead of i1____).

s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/

Next, in a loop, each sequence of _s and 1s (and the subsequent ;) is replaced by the corresponding character:

:
s/([1_]+);(.*([^1_])\1)/\3\2/
t

Finally, cleanup: is are replaced with 1s, remaining ;s are spaces, and the lookup table is deleted:

y/i/1/
s/;/ /g
s/:.*//g

GNU sed, 261 + 1 = 262 bytes

+1 byte for -r flag.

s/000/;/g
s/111/_/g
s/0//g
s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/
:
s/([1_]+);(.*([^1_])\1)/\3\2/
t
y/i/1/
s/;/ /g
s/:.*//g

Try it online!

Explanation

This is a very basic lookup table solution. The first three lines transform the input so dashes are _s and dots are 1s. Characters are separated by ; and words are separated by ;;.

s/000/;/g
s/111/_/g
s/0//g

The next line appends the lookup table. It takes the form cmcmcm... where c is a character and m is the sequence of _s and 1s representing it. i is substituted for 1 in the table for disambiguation:

s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/

Next, in a loop, each sequence of _s and 1s (and the subsequent ;) is replaced by the corresponding character:

:
s/([1_]+);(.*([^1_])\1)/\3\2/
t

Finally, cleanup: is are replaced with 1s, remaining ;s are spaces, and the lookup table is deleted:

y/i/1/
s/;/ /g
s/:.*//g

GNU sed, 261 + 1 = 262 bytes

+1 byte for -r flag.

s/000/;/g
s/111/_/g
s/0//g
s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/
:
s/([1_]+);(.*([^1_])\1)/\3\2/
t
y/i/1/
s/;/ /g
s/:.*//g

Try it online!

Explanation

This is a very basic lookup table solution. 

The first three lines transform the input so dashes are _s and dots are 1s. First, 000s are replaced with ;, so characters are separated by ; and words by ;;0. Then 111s are replaced by _ and all remaining 0s are discarded, leaving 1s for dots.

s/000/;/g
s/111/_/g
s/0//g

The next line appends the lookup table. It takes the form cmcmcm... where c is a character and m is the sequence of _s and 1s representing it. i is substituted for 1 in the table for disambiguation. Since regular expressions in sed are always greedy, the table is sorted from longest to shortest code (so e.g. 1_ matches A1_ instead of i1____).

s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/

Next, in a loop, each sequence of _s and 1s (and the subsequent ;) is replaced by the corresponding character:

:
s/([1_]+);(.*([^1_])\1)/\3\2/
t

Finally, cleanup: is are replaced with 1s, remaining ;s are spaces, and the lookup table is deleted:

y/i/1/
s/;/ /g
s/:.*//g
Source Link
Jordan
  • 11.3k
  • 1
  • 33
  • 55

GNU sed, 261 + 1 = 262 bytes

+1 byte for -r flag.

s/000/;/g
s/111/_/g
s/0//g
s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/
:
s/([1_]+);(.*([^1_])\1)/\3\2/
t
y/i/1/
s/;/ /g
s/:.*//g

Try it online!

Explanation

This is a very basic lookup table solution. The first three lines transform the input so dashes are _s and dots are 1s. Characters are separated by ; and words are separated by ;;.

s/000/;/g
s/111/_/g
s/0//g

The next line appends the lookup table. It takes the form cmcmcm... where c is a character and m is the sequence of _s and 1s representing it. i is substituted for 1 in the table for disambiguation:

s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/

Next, in a loop, each sequence of _s and 1s (and the subsequent ;) is replaced by the corresponding character:

:
s/([1_]+);(.*([^1_])\1)/\3\2/
t

Finally, cleanup: is are replaced with 1s, remaining ;s are spaces, and the lookup table is deleted:

y/i/1/
s/;/ /g
s/:.*//g