Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added a commented version
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

Commented

f = ( // f is a recursive function taking:
 y = -1, // y = row, starting at -1
 x, // x = column, initially undefined
 n = 9 + y - x-- // n is negative on the left side,
 // 0 on the diagonal,
 // greater than 0 on the right side
) => //
29 - y ? // if y is not equal to 29:
 ` /_°\n`[ // lookup string
 x ? // if x is not zero:
 n < 0 ? // if this is the left side:
 0 // append a space
 : // else:
 n && // if this is not the diagonal
 x > 3 & // and we're not too far on the right
 y > 3 ? // and this is not the upper part:
 3 // append '°'
 : // else:
 n < 33 ^ // append either '/' or ' ' on the
 // bottom right corner,
 3 * !y // or '_' on the first row
 : // else (end of row):
 4 // append a line feed
 ] + // end of lookup
 f( // recursive call:
 y + !x, // increment y if x = 0
 x || 36 // reset x to 36 if x = 0
 ) // end of recursive call
: // else:
 "" // stop

Commented

f = ( // f is a recursive function taking:
 y = -1, // y = row, starting at -1
 x, // x = column, initially undefined
 n = 9 + y - x-- // n is negative on the left side,
 // 0 on the diagonal,
 // greater than 0 on the right side
) => //
29 - y ? // if y is not equal to 29:
 ` /_°\n`[ // lookup string
 x ? // if x is not zero:
 n < 0 ? // if this is the left side:
 0 // append a space
 : // else:
 n && // if this is not the diagonal
 x > 3 & // and we're not too far on the right
 y > 3 ? // and this is not the upper part:
 3 // append '°'
 : // else:
 n < 33 ^ // append either '/' or ' ' on the
 // bottom right corner,
 3 * !y // or '_' on the first row
 : // else (end of row):
 4 // append a line feed
 ] + // end of lookup
 f( // recursive call:
 y + !x, // increment y if x = 0
 x || 36 // reset x to 36 if x = 0
 ) // end of recursive call
: // else:
 "" // stop
saved 1 byte
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 8786 bytes

f=(y=-1,x,n=9+y-x--)=>29-y?` /_°
`[x?n<0?0:y?n&&x>3&y>3?3:n<33|0:2n<33^3*!y:4]+f(y+!x,x||36):""

Try it online! Try it online!

JavaScript (ES6), 87 bytes

f=(y=-1,x,n=9+y-x--)=>29-y?` /_°
`[x?n<0?0:y?n&&x>3&y>3?3:n<33|0:2:4]+f(y+!x,x||36):""

Try it online!

JavaScript (ES6), 86 bytes

f=(y=-1,x,n=9+y-x--)=>29-y?` /_°
`[x?n<0?0:n&&x>3&y>3?3:n<33^3*!y:4]+f(y+!x,x||36):""

Try it online!

saved 3 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

JavaScript (ES6), 9087 bytes

f=(y=-1,x,n=9+y-x--)=>29-y?` _/°
`[x?n<0?0:y?n?x>3?y>3^2:n<33n&&x>3&y>3?23:0n<33|0:2:1:4]+f(y+!x,x||36):""

Try it online! Try it online!

JavaScript (ES6), 90 bytes

f=(y=-1,x,n=9+y-x--)=>29-y?` _/°
`[x?n<0?0:y?n?x>3?y>3^2:n<33?2:0:2:1:4]+f(y+!x,x||36):""

Try it online!

JavaScript (ES6), 87 bytes

f=(y=-1,x,n=9+y-x--)=>29-y?` /
`[x?n<0?0:y?n&&x>3&y>3?3:n<33|0:2:4]+f(y+!x,x||36):""

Try it online!

saved 1 byte
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading
saved 1 byte
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading
saved 3 bytes
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading

AltStyle によって変換されたページ (->オリジナル) /