Created
June 8, 2019 09:28
-
-
Save watilde/b5d8a6f859d5f6649b9e41d018f35ae8 to your computer and use it in GitHub Desktop.
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
process.stdin.resume(); | |
process.stdin.setEncoding('ascii'); | |
var input_stdin = ""; | |
var input_stdin_array = ""; | |
var input_currentline = 0; | |
process.stdin.on('data', function (data) { | |
input_stdin += data; | |
}); | |
process.stdin.on('end', function () { | |
input_stdin_array = input_stdin.split("\n"); | |
main(); | |
}); | |
// Reads complete line from STDIN | |
function readLine() { | |
return input_stdin_array[input_currentline++]; | |
} | |
function main() { | |
var i = 4 | |
var d = 4.0 | |
var s = "HackerRank " | |
// Declare second integer, double, and String variables. | |
console.log(i + Number(input_stdin_array[0])) | |
console.log((d + Number(input_stdin_array[1])).toFixed(1)) | |
console.log(s + input_stdin_array[2]) | |
} |
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 splitString(input) { | |
const m = ['', ''] | |
for (let i = 0; input.length > i; i++) { | |
if (i % 2 === 0) { | |
m[0] += input[i] | |
} else { | |
m[1] += input[i] | |
} | |
} | |
return m.join(' ') | |
} | |
function processData(input) { | |
const len = input.splice(0, 1) | |
const m = [] | |
for (let i = 0; len > i; i++) { | |
m[i] = splitString(input[i]) | |
} | |
console.log(m.join('\n')) | |
} | |
process.stdin.resume(); | |
process.stdin.setEncoding("ascii"); | |
_input = ""; | |
process.stdin.on("data", function (input) { | |
_input += input; | |
}); | |
process.stdin.on("end", function () { | |
processData(_input.split('\n')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment