CalculatingĀ  sales by Math šŸ©Ā 

Run Settings
LanguageJavaScript
Language Version
Run Command
//also use arr.reverse function processData(input) { let new_arr =[] let res = 0 let string = input.split('\n'); let n = string[0] let ar = string[1].split(" ").map(Number) const arr = new Set(ar); arr.forEach( a => new_arr.push(ar.count(a))) new_arr.forEach( a => res += Math.floor(a/2) ) console.log(res) // console.log(Math.floor(3/2)) } Array.prototype.count = function(value) { let count = 0; this.forEach(item => { if (item === value) { count++; } }); return count; } process.stdin.resume(); process.stdin.setEncoding("ascii"); _input = ""; process.stdin.on("data", function (input) { _input += input; }); process.stdin.on("end", function () { processData(_input); });
Editor Settings
Theme
Key bindings
Full width
Lines