题目:
提交:
while(line = Number(readline())) {
let arr = new Array(line)
for (let i = 0; i < line; i ++) {
arr[i] = []
if (i === 0) {
arr[0][line - 1] = 1
// console.log(arr[i])
continue
}
for (let j = line - 1; j >= line - 1 - i; j--) {
let num1 = (i - 1 >= 0) ? arr[i - 1][j - 1] || 0 : 0
let num2 = (i - 1 >= 0) ? arr[i - 1][j] || 0 : 0
let num3 = (i - 1 >= 0) ? arr[i - 1][j + 1] || arr[i - 1][2 * (line - 1) - j - 1] || 0 : 0
arr[i][j] = num1 + num2 + num3
}
// console.log(arr[i])
}
let index = arr[line - 1].findIndex(item => item % 2 === 0)
console.log(index >= 0 ? index + 1 : -1)
}