Skip to content

Instantly share code, notes, and snippets.

@naxmefy
Created May 24, 2021 17:49
Show Gist options
  • Save naxmefy/65b5dd81186245a2885dda755f7a41f6 to your computer and use it in GitHub Desktop.
Save naxmefy/65b5dd81186245a2885dda755f7a41f6 to your computer and use it in GitHub Desktop.
print a diamond with n size
const N = parseInt(readline());
console.log("#".repeat(N));
for(var i = 1; i < (N * 2); i+=2){
console.log(" ".repeat((N*2 - i) / 2) + "#".repeat(i));
}
for(var i = N * 2 - 1; i > 0; i-=2){
console.log(" ".repeat((N*2 - i) / 2) + "#".repeat(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment