fork download
  1. import std.stdio;
  2. import std.range;
  3. import std.algorithm : endsWith;
  4.  
  5. void main()
  6. {
  7. foreach(string line; stdin.lines)
  8. {
  9. auto words = line.split(" ");
  10. foreach(i; 0 .. words.length - 1)
  11. {
  12. string curr = words[i];
  13. string next = words[i + 1];
  14.  
  15. ulong k = 0;
  16. foreach(j; 0 .. next.length)
  17. if(curr.endsWith(next[0 .. j]))
  18. k = j;
  19.  
  20. write(curr[0 .. $ - k]);
  21. if(k == 0)
  22. write(' ');
  23. }
  24. write(words.back);
  25. }
  26. }
Success #stdin #stdout 0s 14872KB
stdin
I heard the pastor sing liverses easily.
Deep episodes of Deep Space Nine came on the television only after the news.
Digital alarm clocks scare area children.
stdout
I heard the pastor sing liverses easily.
Deepisodes of Deep Space Nine came on the televisionly after the news.
Digitalarm clockscarea children.