Problem: 2050C - Uninteresting Number
Language: Node.js

Previous submission (verdict: Wrong answer on test 2):
const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

let countInput = 0
let numberTest = 0
let testCase = 0

let inputContainer = []
let outputs = []



const inputProcess = (input) => {
    if (input.length == 1 ) {
        return
    } else {
        testCase++
        inputContainer.push(input)
    }
}


const computeOutput = () => {    
    
    for (const stringNumber of inputContainer) {
        // I can only turn squares on : 1, 2, 3
        // i need to go through the string, look for either 1, 2, or 3 and replace them with possible strings
        let sum = 0
        let twoCounter = 0
        let threeCounter = 0
        let output = "NO"
        for (let i = 0; i < stringNumber.length; i++) {
            const number = stringNumber[i]
            if (number == "2") 
                twoCounter++
            else if (number == "3")
                threeCounter++
            sum += parseInt(number)
        }

        // console.log(`Sum : ${sum}`)
        minCounterTwo = Math.min(10, twoCounter + 1)
        minCounterThree = Math.min(10, threeCounter + 1)

        let sumGen = 0
        // console.log(`twoCounter : ${twoCounter}, threeCounter : ${threeCounter}`)
        for (let j = 0; j < minCounterTwo; j++) {
            for (let k = 0; k < minCounterThree; k++) {
                    sumGen = sum + 2*j + 6*k
                //  console.log(`j : ${j}, k : ${k}, sumGen: ${sumGen}`)
                    if (sumGen % 9 === 0 ) {
                    output = "YES"
                    break
                }
            }
        }
        outputs.push(output)
    }
}

const printOutput = () => {
    for (const output of outputs) {
        console.log(output)
    }
}


rl.on('line', (input) => {
    if (countInput === 0) {
        testNumber = parseInt(input)
        countInput++
        return
    }
    inputProcess(input)
    if (testCase === testNumber) {
        computeOutput()
        printOutput()
        
        rl.close()
    }
    // console.log(inputContainer)
})

Submission (verdict: Accepted):
const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})

let countInput = 0
let numberTest = 0
let testCase = 0

let inputContainer = []
let outputs = []



const inputProcess = (input) => {
    testCase++
    inputContainer.push(input)
}


const computeOutput = () => {    
    
    for (const stringNumber of inputContainer) {
        // I can only turn squares on : 1, 2, 3
        // i need to go through the string, look for either 1, 2, or 3 and replace them with possible strings
        let sum = 0
        let twoCounter = 0
        let threeCounter = 0
        let output = "NO"
        for (let i = 0; i < stringNumber.length; i++) {
            const number = stringNumber[i]
            if (number == "2") 
                twoCounter++
            else if (number == "3")
                threeCounter++
            sum += parseInt(number)
        }

        // console.log(`Sum : ${sum}`)
        minCounterTwo = Math.min(10, twoCounter + 1)
        minCounterThree = Math.min(10, threeCounter + 1)

        let sumGen = 0
        // console.log(`twoCounter : ${twoCounter}, threeCounter : ${threeCounter}`)
        for (let j = 0; j < minCounterTwo; j++) {
            for (let k = 0; k < minCounterThree; k++) {
                    sumGen = sum + 2*j + 6*k
                //  console.log(`j : ${j}, k : ${k}, sumGen: ${sumGen}`)
                    if (sumGen % 9 === 0 ) {
                    output = "YES"
                    break
                }
            }
        }
        outputs.push(output)
    }
}

const printOutput = () => {
    for (const output of outputs) {
        console.log(output)
    }
}


rl.on('line', (input) => {
    if (countInput === 0) {
        testNumber = parseInt(input)
        countInput++
        return
    }
    inputProcess(input)
    if (testCase === testNumber) {
        computeOutput()
        printOutput()
        
        rl.close()
    }
    // console.log(inputContainer)
})