Skip to content

Instantly share code, notes, and snippets.

@kharioki
Created January 2, 2019 12:51
Show Gist options
  • Save kharioki/9adfe229c5c3b6bfe709e0535aa532e6 to your computer and use it in GitHub Desktop.
Save kharioki/9adfe229c5c3b6bfe709e0535aa532e6 to your computer and use it in GitHub Desktop.
'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});
process.stdin.on('end', _ => {
inputString = inputString.replace(/\s*$/, '')
.split('\n')
.map(str => str.replace(/\s*$/, ''));
main();
});
function readLine() {
return inputString[currentLine++];
}
// Complete the staircase function below.
function staircase(n) {
let stair, space, hash;
for (let i = 0; i < n; i++) {
space = n - 1 - i;
hash = i + 1;
stair = ' '.repeat(space) + '#'.repeat(hash);
console.log(stair);
}
}
function main() {
const n = parseInt(readLine(), 10);
staircase(n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment