Determine if a string is squeezable: Difference between revisions

mNo edit summary
Line 2,151:
old: <<< --- Harry S Truman >>>, length = 72
new: <<< --- Hary S Truman >>>, length = 71</pre>
 
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>ClearAll[Squeeze]
Squeeze[s_String,sq_String]:=StringReplace[s,x:(sq..):>sq]
s={
"",
"\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln",
"..1111111111111111111111111111111111111111111111111111111111111117777888",
"I never give 'em hell, I just tell the truth, and they think it's hell. ",
" --- Harry S Truman "
};
Squeeze[s[[1]],""]
Squeeze[s[[2]],"-"]
Squeeze[s[[3]],"7"]
Squeeze[s[[4]],"."]
Squeeze[s[[5]]," "]
Squeeze[s[[5]],"-"]
Squeeze[s[[5]],"r"]</lang>
{{out}}
<pre>""
"\"If I were two-faced, would I be wearing this one?\" - Abraham Lincoln "
"..1111111111111111111111111111111111111111111111111111111111111117888"
"I never give 'em hell, I just tell the truth, and they think it's hell. "
" --- Harry S Truman "
" - Harry S Truman "
" --- Hary S Truman "</pre>
 
 
1,111

edits