Skip to content

Instantly share code, notes, and snippets.

@LeeDDHH

LeeDDHH/00000.js Secret

Last active December 25, 2022 04:13
Show Gist options
  • Save LeeDDHH/a65f956825f7a78997d51746ae3415e0 to your computer and use it in GitHub Desktop.
Save LeeDDHH/a65f956825f7a78997d51746ae3415e0 to your computer and use it in GitHub Desktop.
atcoder(AtCoder Beginners Selection)
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"));
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"));
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