Last active
August 11, 2019 04:55
-
-
Save tomtheisen/8742420db07783e8a1f021943dd0abcc to your computer and use it in GitHub Desktop.
This program will produce a stax program that outputs its input.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ld_X store input in X | |
c"Initial size: `%"P | |
{ | |
xx2B | |
xVp:SY{{Vpxaz:r-f}M keep only substrings that leave an unused ascii char after their removal | |
|=h#~ | |
%RD{d find the length of the longest substring that occurs the most times | |
xx_B | |
y{{Vpxaz:r-f}M keep only substrings that leave an unused ascii char after their removal | |
|=h# | |
;= | |
}hH,d | |
xsB | |
y{{Vpxaz:r-f}M keep only substrings that leave an unused ascii char after their removal | |
|=h | |
xn#vn%v*2- | |
2l build [excerpt, estimated savings] | |
cH0<C stop looping when estimated savings of best option is < 0 | |
xnhz:rG | |
c'~=HlC | |
"Replacing "p nhA].\n:r:}p " with "p c]:}p. p | |
c~]+ | |
xnh,:rX | |
c"Current size: `%"P | |
Wd | |
zP'-80*P | |
L{:Er$mY | |
c$Gc~* | |
xs | |
2l{ build literal | |
A]_G:r | |
"([```"])""``$1"R | |
'"|S | |
_A#{_"`1'`GA]:r"+}M | |
m | |
z~ | |
Es,s+A+~ | |
c%2>{ are any replacements? | |
y%1= | |
{ only one replacement | |
,s+A+~ | |
"1%:r",s+A+~ | |
} | |
{ | |
yM%3= | |
{ all replacements are 2 chars | |
y$G-,s+A+~ | |
"3/F1%:r",s+A+~ | |
} | |
{ general replacements | |
,s+A+~ | |
ss~~ | |
"'` /F1%:r",s+A+~ | |
} | |
? | |
} | |
? | |
}M | |
,q | |
'-80*P | |
A-"Total golfed size: `%"P | |
} get next substition char | |
"etaoinsrhldcumfpgwybvkxjqz"c^+" !',-.:?"+Vp+"`"``\.*+()[^$"-Vp+s-h] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment