fork download
  1. let count = 0;
  2.  
  3. function printStringIfExactlyTwoChars(str) {
  4. const uniqueChars = new Set(str.split(''));
  5. for (const char of uniqueChars) {
  6. if (str.split(char).length - 1 === 2) {
  7. console.log(str);
  8. return; // Exit the function after logging once
  9. }
  10. }
  11. }
  12.  
  13. while (count < 8) {
  14. const str = readline();
  15. printStringIfExactlyTwoChars(str);
  16. count++;
  17. }
Success #stdin #stdout 0.05s 17116KB
stdin
asdf
fdas
asds
d fm
dfaa
aaaa
aabb
aaabb
stdout
asds
dfaa
aabb
aaabb