const lines = require('fs') .readFileSync('/dev/stdin', 'utf-8') .trim().split('\n').values(); const A = lines.next().value.split(' '); // let count = new Map(); A.forEach(x => { if (!count.has(x)) { count.set(x, 0); } count.set(x, count.get(x) + 1); }); count = Array.from(count.values()); const three = count.filter(x => x === 3).length; const pair = count.filter(x => x === 2).length; // if (three === 1 && pair === 1) { console.log('FULL HOUSE'); return; } if (three === 1) { console.log('THREE CARD'); return; } if (pair === 2) { console.log('TWO PAIR'); return; } if (pair === 1) { console.log('ONE PAIR'); return; } console.log('NO HAND');