Skip to content

Instantly share code, notes, and snippets.

@Woodsphreaker
Created May 30, 2017 19:02
Show Gist options
  • Save Woodsphreaker/0aba24c725e442397c8253859ed70172 to your computer and use it in GitHub Desktop.
Save Woodsphreaker/0aba24c725e442397c8253859ed70172 to your computer and use it in GitHub Desktop.
Hacker Rank - Desafio Staircase
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();
});
function readLine() {
return input_stdin_array[input_currentline++];
}
/////////////// ignore above this line ////////////////////
function main() {
var n = parseInt(readLine());
const insertSpace = (max) => Array.from({length:max - 1}).map(char => " ").join("")
const insertHash = (max) => Array.from({length:max + 1}).map(char => "").join("#") + "\n"
const solve = (times) => Array.from({length:times}).map((_, i) => insertSpace(times - i) + insertHash(i + 1)).join("")
console.log(solve(n))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment