• + 0 comments

    I first answered the question with a simple for loop but then I saw your answer and was inspired to try again making use of the methods found in JavaScript!

    const n = parseInt(readLine(), 10);
    
    const arr = readLine().split(' ').map(arrTemp => parseInt(arrTemp, 10));
    
    process.stdout.write(
       (arr.filter(i => i > 0).length / n).toFixed(6) + '\n' +
       (arr.filter(i => i < 0).length / n).toFixed(6) + '\n' +
       (arr.filter(i => i === 0).length / n).toFixed(6));