fork download
  1. function mirror(...) --it should be a full program, but then I can't test it many times
  2. --the ... in full program is the same as here
  3.  
  4. s=...for i=#s,1,-1 do for j=1,#s-i do m=j+i/2-i%2/2t=s:sub(j,m).."|"..s:sub(m+1,i+j)if t==t.reverse(t)then print(t)return end end end
  5. end
  6.  
  7. mirror("Hello World") --> "l|l"
  8. mirror("Programming Puzzles and Code-Golf") --> Either "m|m" or "z|z"
  9. mirror("abcba") --> ""
  10. mirror("Hulluh") --> "ul|lu"
  11. mirror("abcdefggfedcba") --> "abcdefg|gfedcba"
  12. mirror("abcdefggfabc") --> "fg|gf"
  13. mirror("AbbA") --> "Ab|bA"
  14. mirror("This input is a lot like the last one, but with more characters that don't change the output. AbbA") --> "Ab|bA"
Success #stdin #stdout 0.01s 2788KB
stdin
Standard input is empty
stdout
l|l
m|m
ul|lu
abcdefg|gfedcba
fg|gf
Ab|bA
Ab|bA