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