Created
November 16, 2015 21:58
-
-
Save ernestlv/57308c5cb194b1c11e9a to your computer and use it in GitHub Desktop.
Stair-case Problem
This file contains hidden or 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 = ""; | |
process.stdin.on("data", function (chunk) { | |
input += chunk; | |
}); | |
process.stdin.on("end", function () { | |
// now we can read/parse input | |
var n = parseInt(input, 10); | |
var str = []; | |
for(var i=0; i<n; i++){ | |
var col = n-i-1; | |
for(var j=0; j<n; j++){ | |
if (j>=col){ | |
str.push('#'); | |
}else{ | |
str.push(' '); | |
} | |
} | |
str.push('\n'); | |
} | |
process.stdout.write(str.join('')); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment