Skip to main content
Commonmark migration
Source Link

##JavaScript (ES6), 156115 114 bytes

JavaScript (ES6), 156115 114 bytes

###Formatted and commented

Formatted and commented

##JavaScript (ES6), 156115 114 bytes

###Formatted and commented

JavaScript (ES6), 156115 114 bytes

Formatted and commented

minor update
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
f = (                         // given:
  x =                         //   - x = current column
  y =                         //   - y = current row
  k = 1                       //   - k = current ASCII character code, minus 31
) =>                          //
  k < 96 ?                    // if we havent't reached character #127 (96 + 31):
    String.fromCharCode(      //   let's compute the next character
      x - 22 ?                //   if x is not equal to 22 (end of line):
        y / 2 ^ 5 && (        //     if y doesn't equal 910 or 1011 (horizontal bar):
          y > 9 ?             //       and either y is greater than 9:
            x - y + 1 >> 1 && //         and we are not located on one of the
            22 - y - x >> 1   //         bottom diagonals
          :                   //       or y is less or equal to 9:
            x / 2 ^ 5         //         and x doesn't equal 910 or 1011 (vertical bar)
        ) ?                   //     then:
          32                  //       outputappend a space
        :                     //     else:
          31 + k++            //       outputappend the next ASCII character
      :                       //   else:
        (x = !++y, 10)        //     increment y, reset x and outputappend a LineFeed
    ) + f(x + 1)              //   do a recursive call with x + 1
  :                           // else:
    ''                        //   stop recursion
f = (                         // given:
  x =                         //   - x = current column
  y =                         //   - y = current row
  k = 1                       //   - k = current character
) =>                          //
  k < 96 ?                    // if we havent't reached character #127 (96 + 31):
    String.fromCharCode(      //   let's compute the next character
      x - 22 ?                //   if x is not equal to 22 (end of line):
        y / 2 ^ 5 && (        //     if y doesn't equal 9 or 10:
          y > 9 ?             //       and either y is greater than 9:
            x - y + 1 >> 1 && //         and we are not located on one of the
            22 - y - x >> 1   //         bottom diagonals
          :                   //       or y is less or equal to 9:
            x / 2 ^ 5         //         and x doesn't equal 9 or 10
        ) ?                   //     then:
          32                  //       output a space
        :                     //     else:
          31 + k++            //       output the next ASCII character
      :                       //   else:
        (x = !++y, 10)        //     increment y, reset x and output a LineFeed
    ) + f(x + 1)              //   do a recursive call with x + 1
  :                           // else:
    ''                        //   stop recursion
f = (                         // given:
  x =                         //   - x = current column
  y =                         //   - y = current row
  k = 1                       //   - k = current ASCII character code, minus 31
) =>                          //
  k < 96 ?                    // if we havent't reached character #127 (96 + 31):
    String.fromCharCode(      //   let's compute the next character
      x - 22 ?                //   if x is not equal to 22 (end of line):
        y / 2 ^ 5 && (        //     if y doesn't equal 10 or 11 (horizontal bar):
          y > 9 ?             //       and either y is greater than 9:
            x - y + 1 >> 1 && //         and we are not located on one of the
            22 - y - x >> 1   //         bottom diagonals
          :                   //       or y is less or equal to 9:
            x / 2 ^ 5         //         and x doesn't equal 10 or 11 (vertical bar)
        ) ?                   //     then:
          32                  //       append a space
        :                     //     else:
          31 + k++            //       append the next ASCII character
      :                       //   else:
        (x = !++y, 10)        //     increment y, reset x and append a LineFeed
    ) + f(x + 1)              //   do a recursive call with x + 1
  :                           // else:
    ''                        //   stop recursion
added the commented version
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

###Formatted and commented

f = (                         // given:
  x =                         //   - x = current column
  y =                         //   - y = current row
  k = 1                       //   - k = current character
) =>                          //
  k < 96 ?                    // if we havent't reached character #127 (96 + 31):
    String.fromCharCode(      //   let's compute the next character
      x - 22 ?                //   if x is not equal to 22 (end of line):
        y / 2 ^ 5 && (        //     if y doesn't equal 9 or 10:
          y > 9 ?             //       and either y is greater than 9:
            x - y + 1 >> 1 && //         and we are not located on one of the
            22 - y - x >> 1   //         bottom diagonals
          :                   //       or y is less or equal to 9:
            x / 2 ^ 5         //         and x doesn't equal 9 or 10
        ) ?                   //     then:
          32                  //       output a space
        :                     //     else:
          31 + k++            //       output the next ASCII character
      :                       //   else:
        (x = !++y, 10)        //     increment y, reset x and output a LineFeed
    ) + f(x + 1)              //   do a recursive call with x + 1
  :                           // else:
    ''                        //   stop recursion

###Formatted and commented

f = (                         // given:
  x =                         //   - x = current column
  y =                         //   - y = current row
  k = 1                       //   - k = current character
) =>                          //
  k < 96 ?                    // if we havent't reached character #127 (96 + 31):
    String.fromCharCode(      //   let's compute the next character
      x - 22 ?                //   if x is not equal to 22 (end of line):
        y / 2 ^ 5 && (        //     if y doesn't equal 9 or 10:
          y > 9 ?             //       and either y is greater than 9:
            x - y + 1 >> 1 && //         and we are not located on one of the
            22 - y - x >> 1   //         bottom diagonals
          :                   //       or y is less or equal to 9:
            x / 2 ^ 5         //         and x doesn't equal 9 or 10
        ) ?                   //     then:
          32                  //       output a space
        :                     //     else:
          31 + k++            //       output the next ASCII character
      :                       //   else:
        (x = !++y, 10)        //     increment y, reset x and output a LineFeed
    ) + f(x + 1)              //   do a recursive call with x + 1
  :                           // else:
    ''                        //   stop recursion
saved 1 byte
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 2 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 4 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
deleted 1 character in body
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 12 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 2 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 8 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 12 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading