-
-
Save LeeDDHH/a65f956825f7a78997d51746ae3415e0 to your computer and use it in GitHub Desktop.
atcoder(AtCoder Beginners Selection)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Main(input) { | |
const splitedInput = input.split('\n'); | |
const numSum = splitedInput.reduce((prev, cur) => { | |
const isNumberCastedFromString = typeof cur === 'string' && !Number.isNaN(parseInt(cur)); | |
if (isNumberCastedFromString && !cur.indexOf(' ')) { | |
return prev + parseInt(cur); | |
} | |
if (isNumberCastedFromString && cur.indexOf(' ')) { | |
const sumResult = cur.split(' ').reduce((p,c) => { | |
return p + parseInt(c); | |
}, 0) | |
return prev + sumResult; | |
} | |
return prev; | |
}, 0); | |
const stringResult = splitedInput[splitedInput.length -1]; | |
console.log(`${numSum} ${stringResult}`); | |
} | |
Main(require("fs").readFileSync("/dev/stdin", "utf8")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Main(input) { | |
var inputSplited = input.split(' '); | |
var result = parseInt(inputSplited[0], 10) * parseInt(inputSplited[1], 10); | |
var EvenOrOdd = result % 2 === 0 ? 'Even' : 'Odd'; | |
console.log(EvenOrOdd); | |
} | |
Main(require("fs").readFileSync("/dev/stdin", "utf8")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const input = require( "fs" ).readFileSync( "/dev/stdin", "utf8" ) | |
const [ a, b ] = input.split( " " ).map( v => parseInt( v, 10 ) ) | |
const answer = ( a & b & 1 ) ? "Odd" : "Even" | |
console.log( answer ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment