18
\$\begingroup\$

Given the battery level L in the range 0-5, your code should draw the following ASCII art.

When L=0:

############
#          ###
#          ###
#          ###
############

When L=1:

############
###        ###
###        ###
###        ###
############

When L=2:

############
#####      ###
#####      ###
#####      ###
############

And etc. You can change the character # to any other (except space), it's up to you. Trailing spaces are allowed.

This is a code-golf challenge so the shortest solution wins.

\$\endgroup\$
4
  • 2
    \$\begingroup\$ I presume I can't change the character # to a space. \$\endgroup\$
    – pxeger
    Feb 24 at 18:33
  • 1
    \$\begingroup\$ @pxeger Yes, you can't now :) \$\endgroup\$
    – sinvec
    Feb 24 at 18:37
  • \$\begingroup\$ you allow trailing whitespace, but what about preceding whitespace? (specifically a preceding newline?) \$\endgroup\$
    – Dave
    Feb 26 at 3:10
  • \$\begingroup\$ @Dave I think it would be fine \$\endgroup\$
    – sinvec
    Feb 26 at 7:30

29 Answers 29

14
\$\begingroup\$

Google Sheets, 124 bytes

=substitute(query({rept("#",12);sort(if({1;1;1},"#"&rept("#",A1*2)&rept("-",10-A1*2)&"###"));rept("#",12)},,9)," ",char(10))

89 bytes if it's okay for the output to be displayed in separate cells

={rept("#",12);sort(if({1;1;1},"#"&rept("#",A1*2)&rept("-",10-A1*2)&"###"));rept("#",12)}

Try it here

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Welcome to Code Golf, and nice first answer! \$\endgroup\$
    – pxeger
    Feb 24 at 20:19
  • \$\begingroup\$ @pxeger, thanks! :) \$\endgroup\$
    – ztiaa
    Feb 24 at 20:33
13
\$\begingroup\$

brainfuck, 266 245 242 bytes

-21 bytes thanks to @emanresu A's suggestion to use ÿ instead of ! (since ÿ's charcode is the same as the glider reference value 255 on an 8 bit bf interpreter like TIO's).

-3 bytes by removing unnecessary code (at the expense of a pretty memory layout).

-[-[-<]>>+<]>->>+++++[<++>-]->++++[<...>-]<<.>+>-[>+<-----]>---<,>[<->-]<[<+>-]<[>->+>->+>->+<<<<<<-]+++++[>+>>+>>+<<<<<-]->>>>>>>-<+[[[-<+]-.>+[->+]-<[+[-<+]-..>+[->+]-<-]>+<-<[+[-<+]-<<..>>>+[->+]-<-]+[-<+]-...<.>>+[->+]<->]<<+]++++[>...<-]

Try it online!

Uses a glider and fancy loop tricks to print the middle 3 rows. Uses ÿ instead of # since that is allowed by the challenge.

Ungolfed:

memory layout
(pni = 5 minus inp)
3   4   5   6   7   8   9   10  11  12
' ' \n  ÿ   pni inp pni inp pni inp ÿ

' ' = 32
-[-[-<]>>+<]>-
\n = 10
>>+++++[<++>-]
ÿ = 255
-

print top row of ÿs
>++++[<...>-]<<.>+

get input
>-[>+<-----]>---<,>[<->-]<[<+>-]<

copy to loop cells
[>->+>->+>->+<<<<<<-]
+++++[>+>>+>>+<<<<<-]
create glider refs
->>>>>>>-<+

main loop
[
  glider collision guard
  exit the loop when all loop variables are exhausted
  [-
    print first ÿ
    +[-<+]-.>
    +[->+]-
    print ÿs in battery
    <[
      +[-<+]-..>
      +[->+]-
      <-
    ]
    move glider back one cell
    >+<-
    print spaces in battery
    <[
      +[-<+]-<<..>>>
      +[->+]-
      <-
    ]
    print last 3 ÿs and \n
    +[-<+]-...<.>>
    +[->+]
    move glider back one cell
    <->
  ]<<+
]

print last row of ÿs
++++[>...<-]
\$\endgroup\$
3
  • 2
    \$\begingroup\$ Would it be cheaper to use ÿ instead? \$\endgroup\$
    – emanresu A
    Feb 25 at 3:01
  • \$\begingroup\$ It could be, actually. Let me try doing that and see. \$\endgroup\$
    – nununoisy
    Feb 25 at 13:27
  • \$\begingroup\$ Finally got around to implementing your golf @emanresu A. Thanks! \$\endgroup\$
    – nununoisy
    Feb 27 at 20:04
10
\$\begingroup\$

Python, 46 bytes

lambda n:[s:="#"*12,*3*[f'#{"##"*n:10}###'],s]

Attempt This Online!

Outputs a list of lines, as allowed by standard I/O rules.

\$ -9 -1 = -10 \$ thanks to @xnor


Python, 76 bytes

lambda n,r=f"#{' '*10}#".replace:[a:=r(" ","#")]+[r(" ","#",2*n)+"##"]*3+[a]

Attempt This Online!

Did you know Python's str.replace method has a third parameter to limit the maximum number of replacements that will be performed? You do now!

\$\endgroup\$
2
  • 2
    \$\begingroup\$ 47 bytes using f-strings: lambda n:[s:="#"*12]+[f"#{'##'*n:10}###"]*3+[s] \$\endgroup\$
    – xnor
    Feb 24 at 19:00
  • 3
    \$\begingroup\$ List unpacking saves a byte: lambda n:[s:="#"*12,*[f'#{"##"*n:10}###']*3,s] \$\endgroup\$
    – xnor
    Feb 24 at 19:40
7
\$\begingroup\$

C (POSIX), 83 bytes

#define s"\n############"
#define r"\n%1$-11s###"
f(i){printf(s r r r s,s+12-i*2);}

I was originally tweaking ErikF's answer but ended up making more substantial changes, so it felt like a new separate answer. Note that this saves some space by printing a newline before the output, which has been approved.

Uses compile-time string concatenation to compress the output template, then uses printf to fill in the correct amount of the bar.

Breakdown:

r template pattern

\n             - print a literal newline
  %     s      - followed by a string
   1$          - from the first argument (POSIX extension)
     -         - padded with trailing spaces
      11       - to at least 11 characters
         ###   - followed by 3 literal hash symbols

printf call

printf(
  s r r r s,     // concatenate define'd strings into full pattern
  s + 12 - i * 2 // first argument: fragment of s (last i * 2 + 1 characters)
);

Expanded

f(i) {
    printf(
        "\n############\n%1$-11s###\n%1$-11s###\n%1$-11s###\n############",
        "\n############" + 12 - i * 2
    );
}

Try it online


As an interesting alternative, this version uses hex values to draw the shape, so it's limited to f characters, but avoids the initial newline. It is the same size (83 bytes):

#define r"%2$-11lxfff\n"
f(i){printf("%lx\n"r r r"%1$lx",(1l<<48)-1,(16l<<i*8)-1);}
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Somehow, the "Expanded" version might be less readable than the golfed version. :-) \$\endgroup\$
    – Cody Gray
    Feb 26 at 12:24
  • \$\begingroup\$ yes the golfed version is quite nice for its clarity, but I expanded it so that it is obvious what's happening for people who may not be familiar with C's macro expansion / compile-time string concatenation \$\endgroup\$
    – Dave
    Feb 26 at 15:36
  • \$\begingroup\$ Very elegant. I was going to take a stab at this one but I don’t think I can outdo this. \$\endgroup\$
    – mreff555
    Mar 18 at 23:46
5
\$\begingroup\$

Charcoal, 18 bytes

UO⊕⊗N³-¹²↘‖O↓UO±³-

Try it online! Link is to verbose version of code. Explanation:

UO⊕⊗N³

Draw the fullness of the top half of the battery.

-¹²↘

Draw the line at the top of the battery and leave the cursor at the top right of the 3×3 square end.

‖O↓

Reflect to complete the fullness and sides of the battery. (This also moves the cursor to the bottom right of the 3×3 square end.)

UO±³-

Draw the 3×3 square end.

\$\endgroup\$
5
\$\begingroup\$

Acc!!, 152 bytes

N-46
Count i while i-2 {
Count l while (l-3)*i {
Count c while c-14 {
Write 32+1/((c+3)/2%7/_+1)
}
Write 10
}
Count h while h-12 {
Write 33
}
Write 10
}

Uses exclamation points. Try it online!

Explanation

This was fun to golf. The verbose syntax of Acc!! drove me to combine as many Count while and Write statements as possible, which required some interesting expressions to encapsulate the logic.

N-46

Read a character from stdin and store its codepoint minus 46 in the accumulator. If the input number is L, the accumulator now holds the value L+2.

Count i while i-2 {
...
}

Do the following twice:

Count l while (l-3)*i {

Do the following (output the middle part of the battery) three times, but only on the second iteration of the i loop:

Count c while c-14 {

Do the following (output a character in the middle part of the battery) fourteen times:

Write 32+1/((c+3)/2%7/_+1)

Write either a space or an exclamation point, based on the loop index c and the accumulator value _.

Observe that we want to output some number of exclamation points, then some number of spaces, then three more exclamation points. This looks like a slice into a periodic function. Since we want to add exclamation points in pairs, let's aim for something like this:

0         1
01234567890123456789
!!!!..........!!!!..

where ! means "definitely maps to !" and . means "might map to either ! or depending on the accumulator value."

We want to run our loop from 3 to 16 in this function; since loop variables in Acc!! always start at zero, we'll just add 3 to the loop variable c.

Next, we combine the pairs of characters that will always be the same by int-dividing by 2:

0123456789
!!.....!!.

We can get the periodic behavior if we take this input mod 7:

0123456
!!.....

Now it's just a matter of adjusting the cutoff depending on the input value. Conceptually, we want exclamation points if this number is less than L+2, and spaces if it is greater than or equal to L+2. Conveniently, L+2 is the value in the accumulator. Inconveniently, Acc!! doesn't have comparison operators, so we'll have to abuse some arithmetic:

With integer division, and assuming b is always positive, a/b is 0 if a<b and some positive number otherwise. To turn 0 vs positive into 1 vs 0, we can add 1 (making it 1 vs greater than 1) and then int-divide 1 by that quantity. End result: 1/(a/b+1) is 1 if a<b and 0 otherwise.

In our case, we have a = (c+3)/2%7 and b = _ (the accumulator). Substituting those into the above expression and adding to 32 gives exclamation point (ASCII 33) or space (ASCII 32) exactly where we want them.

}
Write 10
}

Close the c loop, write a newline, and close the l loop.

Count h while h-12 {
Write 33
}
Write 10

Output the top/bottom of the battery: Loop 12 times and write exclamation point; then write a newline.

\$\endgroup\$
4
+50
\$\begingroup\$

Pari/GP, 82 bytes

n->[print(l)|l<-[s="############",e=Strchr([35-3*(j>n+n&j<11)|j<-[0..13]]),e,e,s]]

Try it online!

This code is most probably not the shortest possible, as this is my first time golfing in Pari/GP.

Thanks @alephalpha for -14 bytes.

\$\endgroup\$
5
  • \$\begingroup\$ You can use list comprehension instead of a for loop. 87 bytes. \$\endgroup\$
    – alephalpha
    Mar 1 at 9:18
  • \$\begingroup\$ Even shorter using Strchr to convert integers to strings: 82 bytes. \$\endgroup\$
    – alephalpha
    Mar 1 at 9:31
  • \$\begingroup\$ @alephalpha Thanks for the tips! I'm sure I'll be using these in the future. I wanted to ask, is there a way to do string multiplication in Pari/GP? Like "#"*12 in python. \$\endgroup\$
    – ophact
    Mar 1 at 9:51
  • \$\begingroup\$ There is no string multiplication. The shortest way I can think of is concat(["#"|i<-[1..12]]), but that is already longer than "############". \$\endgroup\$
    – alephalpha
    Mar 1 at 10:04
  • 1
    \$\begingroup\$ -2 bytes by using exclamation marks instead: Try it online! \$\endgroup\$
    – DLosc
    Mar 1 at 18:59
3
\$\begingroup\$

Vyxal, 18 bytes

d×*₀↲×p14e:"×12*p∞

Try it Online!

d                  # Input * 2
 ×*                # That many asterisks
   ₀↲              # Pad the left to length 10 with spaces
     ×p            # Prepend an asterisk
       14e         # Extend to length 14 by appending the first char
          :"       # Pair with itself
                p  # Prepend to this...
            ×12*   # 12 asterisks
                 ∞ # Palindromise the result
\$\endgroup\$
2
\$\begingroup\$

Retina 0.8.2, 55 bytes

.+
#$&$*_10$* ###¶
+`(_*)_  
##$1
.+¶
12$*#¶$&$&$&12$*#

Try it online! Explanation:

.+
#$&$*_10$* ###¶

Produce a body row of the empty battery but include L _s.

+`(_*)_  
##$1

For each _, delete two spaces and add two #s.

.+¶
12$*#¶$&$&$&12$*#

Triplicate the row and wrap it in lines of 12 #s.

\$\endgroup\$
2
\$\begingroup\$

C (gcc) with -lm, 93 91 bytes

  • -2 thanks to ceilingcat

Uses 9 as the fill character. I make use of 10n-1 producing n nines when n>0.

*s="999999999999";f(i,j){for(puts(s),j=3;j--;printf("%-11.f999\n",exp10(i-~i)-1));puts(s);}

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ you can get down to 90 if you use hex instead of decimal (I expected more but oh well): *s="ffffffffffff";f(i,j){for(puts(s),j=3;j--;printf("%-11lxfff\n",(16l<<i*8)-1));puts(s);} \$\endgroup\$
    – Dave
    Feb 26 at 2:06
  • \$\begingroup\$ or down to 88 if you use strings (and it lets you use any output character): short*s="############";f(i,j){for(puts(s),j=3;j--;printf("#%-10s###\n",s+6-i));puts(s);} \$\endgroup\$
    – Dave
    Feb 26 at 2:06
2
\$\begingroup\$

Python 3.8, 85 72 68 49 46 bytes

lambda l,a="##":[a*6,*3*[f'#{l*a:10}###'],a*6]

Outputs a list of strings, as allowed by standard I/O rules

Try it online!

-13 thx to @Aiden chow

-4 thx to @ovs

-3 thx to @Aiden chow

\$\endgroup\$
5
  • \$\begingroup\$ 72 bytes by converting c into an f-string and some other optimizations. \$\endgroup\$
    – Aiden Chow
    Feb 25 at 7:04
  • \$\begingroup\$ Additional -4 by using the sep argument of print. \$\endgroup\$
    – ovs
    Feb 25 at 7:07
  • 1
    \$\begingroup\$ is this looking too much like pxeger's answer? \$\endgroup\$
    – DialFrost
    Feb 25 at 7:26
  • \$\begingroup\$ @DialFrost yeah it's looking really similar to pxeger's answer, though it's still a little different so i think it's fine. \$\endgroup\$
    – Aiden Chow
    Feb 25 at 7:46
  • 1
    \$\begingroup\$ Also 46 bytes (different from pxeger's answer) \$\endgroup\$
    – Aiden Chow
    Feb 25 at 7:47
2
\$\begingroup\$

Julia 1.0, 57 51 48 bytes

c='#';!n=[c^12,(h=rpad(c*c^2n,11)*c^3;),h,h,c^12]

Try it online!

-3 MarcMush

\$\endgroup\$
1
2
\$\begingroup\$

Excel, 82 74 bytes

It Taylor Rained 8 bytes.

=LET(a,REPT("#",12),b,MID(a&REPT(" ",10),12-2*A1,11)&"###
",a&"
"&b&b&b&a)

Input of L is in the cell A1. Output is wherever the formula is. For best results, make sure the column is wide enough, text wrapping is on, and the font is monospace. The output will be correct regardless but this makes that fact visually apparent.

  • LET(a,REPT("#",12) defines a to be 12 number signs in a row. Combining LET() and REPT() only saves us 1-3 bytes but savings are savings.
  • b,MID(a&REPT(" ",10),12-2*A1,11)&"###\n" has a lot going one but the summary is this:
    • Create a string of 12 # and 10 spaces.
    • Find the right spot (based on the input) in the middle of that string to start pulling characters.
    • Pull 11 characters (1 # + 2*input # + however many spaces).
    • Add ### and a line break.
    • Set the resulting string to the variable b.
  • a&"\n"&b&b&b&a concatenates the pieces into an output.

Screenshot

\$\endgroup\$
1
  • \$\begingroup\$ you can get to 74 bytes with =LET(a,REPT("#",12),b,MID(a&REPT(" ",10),12-2*A1,11)&"###\n",a&"\n"&b&b&b&a) or =LET(a,REPT("#",12),a&"\n"&REPT(MID(a&REPT(" ",10),12-2*A1,11)&"###\n",3)&a) \$\endgroup\$ Feb 26 at 0:46
2
\$\begingroup\$

C++, 267 bytes

#include<iostream>
#define c std::cin
#define o std::cout
#define h()o<<H<<'\n'
#define L 12
#define H 111111111111
#define M 1
typedef int I;
I main(){I l;c>>l;h();for(I i=0;i<3;i++){o<<M;for(I j=0;j<l*2;j++){o<<1;}for(I k=0;k<L-l*2-2;k++){o<<' ';}o<<111<<'\n';}h();}

Try it Online!

First time golfing in C++, not sure if it's good or not.

\$\endgroup\$
1
2
\$\begingroup\$

JavaScript, 76 70 bytes

-6 thanks to Hannesh

_=>(a=`############
`)+`#${'##'.repeat(_).padEnd(10)}###
`.repeat(3)+a

Try it Online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Could save 6 bytes by using .padEnd(10) instead of +' '.repeat(5-_) \$\endgroup\$
    – Hannesh
    Mar 6 at 3:22
2
\$\begingroup\$

brainfuck, 202 bytes

+++++[>++>++++++<<-]>>++>-............<<.>>>>++++[->+++<]>>>>>+++++++[<+++++++>-],<--[>-<-]>[<+<+<+>>>-]<<<[<[-<+<+>>]<[>+<-]>>[<<++<-->>>-]<<-[-<<.>>]<[-<<.>>]<...<<.>>>>>>>[[<+>-]>]<<[<]>>]<[<<<.>>>-]

Try it online!

first, I try to comment this shorter bytes brainfuck to first brainfuck(245 bytes) comment, but i don't have enough reputation. so i decide to comment here and give the link to that first comment. also if I can, I will try to expaining this code later

\$\endgroup\$
1
\$\begingroup\$

Python 3, 86 bytes

a,b="#"*12,int(input())
c="#"+"#"*2*b+" "*(10-2*b)+"###"
print("\n".join([a,c,c,c,a]))

Try it online!

Quick and dirty, but it works.

\$\endgroup\$
0
1
\$\begingroup\$

Charcoal, 49 bytes

P×-¹²P↓×-⁵≔Nα↓→F³«P×-×α²↓»P×-¹¹Fχ«→»P↑×-⁴F³«↑P×-³`

Try It Online! Link is to verbose version of code.

My second Charcoal answer!

Uses "-" instead of "#" because if I change, The Output uses both "-" and "#".

Explanation:

TODO: Understand the code and explain

\$\endgroup\$
3
  • \$\begingroup\$ Trivial golfs: ↓→ can be ; Fχ«→» can be Fχ→ or Mχ→; P×-¹² can be P¹² (but not when using ); ≔Nα can be Nα (but I normally use θ instead of α). \$\endgroup\$
    – Neil
    Feb 24 at 20:22
  • \$\begingroup\$ @Neil Thanks for 8 bytes. \$\endgroup\$
    – Fmbalbuena
    Feb 24 at 21:44
  • \$\begingroup\$ Actually the P×- was just an example; you can do the same simplification to in a couple of other places too. \$\endgroup\$
    – Neil
    Feb 24 at 23:21
1
\$\begingroup\$

05AB1E, 19 18 bytes

X12×$·×Tj7bìĆRD».∊

Outputs 1 instead of #.

Try it online or verify all test cases.

Explanation:

X               # Push 1
 12             # Push 12
   ×            # Repeat the "1" 12 times: 111111111111
$               # Push 1 and the input
 ·              # Double the input
  ×             # Repeat the "1" that many times
   Tj           # Pad it with leading spaces up to length 10
     7bì        # Prepend the binary of 7: 111
        Ć       # Enclose; append its own head
         R      # Reverse it
          D     # Duplicate it
           »    # Join the stack with newline delimiter
            .∊  # Mirror it vertically with overlap
                # (after which the result is output implicitly)
\$\endgroup\$
1
\$\begingroup\$

Noether, 76 bytes

I~l12("#"P!i)?3(0~rl2*1+("#"P!r)0~r11l2*-(r0{>}{" "P}!r)"###"P?!k)12("#"P!y)

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Java (JDK), 98, 95 bytes

L->{System.out.format("%s"+"%2$-11s###\n".repeat(3)+"%1$s","############\n","#".repeat(L-~L));}

Try it online!

\$\endgroup\$
0
1
\$\begingroup\$

Perl 5, 63 bytes

$_=($s='#'x12 .$/).('#'.'#'x($x=2*$_).$"x(10-$x)."###\n")x3 .$s

Try it online!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ 57 bytes \$\endgroup\$
    – Neil
    Feb 27 at 0:57
  • \$\begingroup\$ Nice, no need for $x here. \$\endgroup\$
    – Kjetil S
    Feb 28 at 9:19
  • 1
    \$\begingroup\$ Nice, I came up with pretty much the same approach for 44 bytes, but it does necessitate resetting $\ in your test suite (works as a single run without a problem though!) \$\endgroup\$ Mar 1 at 9:36
  • \$\begingroup\$ Gosh, nice too. I missed the fine print about allowing other chars than #. \$\endgroup\$
    – Kjetil S
    Mar 1 at 17:13
1
\$\begingroup\$

J, 50 46 44 bytes

(a,3 1#(a=:12#'#'),:~'# #'#~(>:,10&-,3:)@+:)

Found that building row by row can be shorter.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Lua, 87 bytes

x,b=...,"\n"d=b.rep a=d("#",12)print(a..b..d(b.format("%-11s###\n",d("#",1+2*x)),3)..a)

Attempt This Online!

enter image description here

My alternate approach before the format string was 6 bytes longer at 93 bytes:

x,b=...,"\n"d,f=b.rep,''a=d("#",12)print(a..b..d(d("#",1+2*x)..d(" ",10-2*x).."###"..b,3)..a)
\$\endgroup\$
0
\$\begingroup\$

Pip, 29 bytes

i:00YPiX6L3P[iJiXa.sXt-2*ai]y

Attempt This Online!

\$\endgroup\$
0
\$\begingroup\$

APL+WIN, 51 bytes

Prompts for n

t←14↑12⍴'#'⋄v←3 14⍴' '⋄v[;(⍳1+2×⎕),11+⍳3]←'#'⋄t⍪v⍪t

Try it online! Thanks to Dyalog Classic

\$\endgroup\$
0
\$\begingroup\$

PowerShell, 45 bytes

%{'#'*12;"#{0,-10}###`n"-f('##'*$_)*3+'#'*12}

Try it online!

Try it in a PS console (Windows or Core):

 0..5|%{'#'*12;"#{0,-10}###`n"-f('##'*$_)*3+'#'*12}

Explanation

% is an Alias for the Cmdlet "ForEach-Object", which accepts input from the pipeline and processes each incoming object inside the ScriptBlock {...}
'#'*12; First line, PowerShell can "multiply" strings; the ; terminates the command, output is implicit.
"#{0,-10}###`n" The level row; {0,-10} is a placeholder where the first argument of the following -f format operator will be inserted. -10 will print the string inserted left-aligned, and padded to a length of 10. The `n is a newline.
-f('##'*$_) Inserts the actual level into the row using the -f format operator; $_ is the current input value.
*3 Multiplies the level row created by "#{0,-10}###`n"-f('##'*$_) three times
+'#'*12 Adds the last line to the level rows created above.
Output is implicit.

\$\endgroup\$
9
  • \$\begingroup\$ The code %{...} is a code sinppet, not a program or function. \$\endgroup\$
    – mazzy
    Feb 25 at 10:58
  • \$\begingroup\$ We had that discussion before at Return all letter counts as an integer, and I stand by what I said there. ForEach-Object (aka %) is a built-in function/cmdlet which takes input from stdin, which is a perfectly allowed method. What exactly is your issue with that? \$\endgroup\$
    – user314159
    Feb 25 at 11:22
  • \$\begingroup\$ 1. I remember. I have written for other readers. 2. You are not using a stdin in your code, you are using a piece of pipe - code snippet. 3. please use TIO field input if you want use stdin. Thanks. \$\endgroup\$
    – mazzy
    Feb 25 at 18:06
  • \$\begingroup\$ This is most definitely not a snippet, this is a fully functional PowerShell command. You can paste the code as shown into a PS shell, and it will run as it is. And using stdin as input means input through the pipeline, ever since the concept of input and output streams was invented; you're splitting hairs here, and I have no idea why. \$\endgroup\$
    – user314159
    Feb 26 at 16:10
  • \$\begingroup\$ The pipeline is not stdin. The pipeline is a PowerShell expression and should be included in the counted code. \$\endgroup\$
    – mazzy
    Feb 26 at 17:07
0
\$\begingroup\$

Canvas, 23 bytes

2×╵#×α⁵∔ ×#3×)∑3*#⁶×q;O

Try it here!

Explanation:

2×╵                         push input*2+1 (called n)
    #×                       repeat '#' n times
      α⁵∔ ×                  repeat ' ' 11-n times
           #3×               repeat '#' 3 times
               )∑            join
                  3*         repeat 3 times vertically
                     #⁶×       repeat '#' 12 times
                        q;O  print without popping, reverse stack, print stack
\$\endgroup\$
0
\$\begingroup\$

CJam, 38 bytes

li2*:I;'#:OC*N+_O_I*+AI-S*+O3*+N+3*\++

Try it online!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.