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

Commonmark migration
Source Link

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

###Explanation

Explanation

The approach is similar to that used in this other answer. The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

###Explanation

The approach is similar to that used in this other answer. The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

Explanation

The approach is similar to that used in this other answer. The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

###Explanation

The approach is similar to that used in this other answer this other answer. The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

###Explanation

The approach is similar to that used in this other answer. The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

###Explanation

The approach is similar to that used in this other answer. The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string
added 499 characters in body
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

###Explanation

The approach is similar to that used in this other answer . The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

The approach is similar to that used in this other answer.

MATL, 19 bytes

'|-| '2:"iqWQB]E!+)

Try it online!

###Explanation

The approach is similar to that used in this other answer . The code builds a numerical array of the form

3 2 2 2 3
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
3 2 2 2 3

and then its values are used as (1-based, modular) indices into the string '|-| ' to produce the desired result.

'|-| ' % Push this string
 2:" ] % Do this twice
 i % Take input
 q % Subtract 1
 W % 2 raised to that
 Q % Add 1
 B % Convert to binary
 E % Multiply by 2
 ! % Transpose
 + % Add with broadcast
 ) % Index (modular, 1-based) into the string
Source Link
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382
Loading

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