Skip to content

Instantly share code, notes, and snippets.

@hetoro
Created August 22, 2021 16:06
Show Gist options
  • Save hetoro/dce3cc0ab8544edeffeb947fb231340e to your computer and use it in GitHub Desktop.
Save hetoro/dce3cc0ab8544edeffeb947fb231340e to your computer and use it in GitHub Desktop.
const rows = 5
const symbol = "*"
const frame = " "
const space = " "
const hat = "-"
/*
-
---
-----
-------
---------
*/
for (let i = 1; i <= rows; i++) {
for (let j = 1; j <= (rows * 2) - i; j++) {
process.stdout.write(`${frame}`)
}
for (let j = 1; j < i * 2; j++) {
process.stdout.write(`${hat}`)
}
for (let j = 1; j <= (rows * 2) - i; j++) {
process.stdout.write(`${frame}`)
}
console.log()
}
/*
-----*-----
----*****----
---*********---
--*************--
-*****************-
*/
for (let i = 1; i <= rows; i++) {
for (let j = 1; j <= rows - i; j++) {
process.stdout.write(`${frame}`)
}
for (let j = rows - i; j >= 0; j--) {
process.stdout.write(`${hat}`)
}
for (let j = 1; j < (i * 4) - 2; j++) {
process.stdout.write(`${symbol}`)
}
for (let j = rows - i; j >= 0; j--) {
process.stdout.write(`${hat}`)
}
for (let j = 1; j <= rows - i; j++) {
process.stdout.write(`${frame}`)
}
console.log()
}
/*
*************
- ********* -
-- ***** --
--- * ---
*/
for (let i = 1; i < rows; i++) {
for (let j = 1; j <= i; j++) {
process.stdout.write(`${frame}`)
}
for (let j = 1; j <= i - 1; j++) {
process.stdout.write(`${hat}`)
}
process.stdout.write(` `)
for (let j = 1; j < (rows * 4) - (i * 4) - 2; j++) {
process.stdout.write(`${symbol}`)
}
process.stdout.write(` `)
for (let j = 1; j <= i - 1; j++) {
process.stdout.write(`${hat}`)
}
for (let j = 1; j <= i; j++) {
process.stdout.write(`${frame}`)
}
console.log()
}
/*
---------
-------
-----
---
-
*/
for (let i = 1; i <= rows; i++) {
for (let j = 1; j < rows + i; j++) {
process.stdout.write(`${frame}`)
}
for (let j = (rows * 2) - i; j >= i; j--) {
process.stdout.write(`${hat}`)
}
for (let j = 1; j < rows + i; j++) {
process.stdout.write(`${frame}`)
}
console.log()
}
/*
-
---
-----
-------
---------
-----*-----
----*****----
---*********---
--*************--
-*****************-
*************
- ********* -
-- ***** --
--- * ---
---------
-------
-----
---
-
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment