fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. // your code goes here
  5. var readline = require("readline");
  6.  
  7. function filterWord(callback) {
  8. return function (line) {
  9. var words = line.match(/\S+/g) || [];
  10. words.forEach(callback);
  11. };
  12. }
  13.  
  14. function main() {
  15. var rl = readline.createInterface(process.stdin, process.stdout);
  16.  
  17. var seen = {};
  18. rl.on('line', filterWord(function(word) {
  19. if (word in seen) return;
  20. seen[word] = true;
  21. console.log(word);
  22. }));
  23. }
  24. main()
Success #stdin #stdout 0.06s 11008KB
stdin
aaa bbb ccc bbb aaa
ddd ccc eee aaa fff
fff ccc aaa ggg eee
stdout
aaa
bbb
ccc
ddd
eee
fff