fork download
  1. process.stdin.resume();
  2. process.stdin.setEncoding('utf8');
  3.  
  4. // your code goes here
  5. function processLines(input) {
  6. const lines = input.split("\n");
  7. lines.forEach((line) => {
  8. const charCount = {};
  9.  
  10. for (const char of line) {
  11. charCount[char] = (charCount[char] || 0) + 1;
  12. }
  13.  
  14. if (Object.values(charCount).some((count) => count === 2)) {
  15. console.log(line);
  16. }
  17. });
  18. }
  19.  
  20.  
  21. const input = `asdf
  22. fdas
  23. asds
  24. d fm
  25. dfaa
  26. aaaa
  27. aabb
  28. aaabb`;
  29.  
  30. processLines(input);
  31.  
Success #stdin #stdout 0.08s 36144KB
stdin
Standard input is empty
stdout
asds
dfaa
aabb
aaabb