11
\$\begingroup\$

Challenge

Display to the screen or write to stdout this exactly:

    **
    **
   ****
   ****
   ****
   ****
   ****
   ****
   ****
**********
**********
**********

Winning

This is , so the shortest submission (in bytes) wins.

\$\endgroup\$
3
  • 7
    \$\begingroup\$ I assume from your answer that it's fine to have trailing spaces after the lines, at least to pad to a rectangle? \$\endgroup\$
    – xnor
    Commented Nov 14, 2023 at 20:21
  • \$\begingroup\$ My answer will be in PETSCII, which may therefore be non-competing. But I'll add it for fun anyway. \$\endgroup\$ Commented Nov 16, 2023 at 9:50
  • 1
    \$\begingroup\$ xnor, yes you may have trailing spaces after lines \$\endgroup\$
    – lame-lexem
    Commented Nov 17, 2023 at 1:38

36 Answers 36

13
\$\begingroup\$

Python 3, 47 bytes

for n in b"":print(f"{'**'*n:^10}")

Try it online!

Yawn, bytestrings. I got close with a few other approaches:

48 bytes

for n in[2]*2+[4]*7+[10]*3:print(f"{'*'*n:^10}")

Try it online!

48 bytes

for n in[1]*2+[2]*7+[5]*3:print(-n%5*' '+'**'*n)

Try it online!

This code is 46 bytes in Python 2 where print doesn't need parens. Thanks to dingledooper for -1 byte with -n%5.

49 bytes

print("    **\n"*2+"   ****\n"*7+('*'*10+'\n')*3)

Try it online!

50 bytes

n=15
while n-3:print(f"{(5>>n//7)*'**':^10}");n-=1

Try it online!

\$\endgroup\$
3
  • 2
    \$\begingroup\$ ' '*(5-n) can be -n%5*' ' \$\endgroup\$ Commented Nov 14, 2023 at 21:11
  • \$\begingroup\$ Also, b-strings seem to win again for c in b'':print(f"{'**'*c:^10}") :P (if the unprintables would format correctly) \$\endgroup\$ Commented Nov 14, 2023 at 21:13
  • \$\begingroup\$ @dingledooper I was just checking that... why they always gotta be so short? \$\endgroup\$
    – xnor
    Commented Nov 14, 2023 at 21:15
10
\$\begingroup\$

CP-1610 machine code, 47 DECLEs1 = 58.75 bytes

1. CP-1610 instructions are encoded with 10-bit values (0x000 to 0x3FF), known as DECLEs. Although the Intellivision is also able to work on 16-bit, programs were really stored in 10-bit ROM back then.

A full program in 10-bit ROM format, mapped at $4800. This includes an initialization of the video chip so that the display is correct.

                            ROMW    10          ; use 10-bit ROM
                            ORG     $4800       ; map our program at $4800
                      
4800  0002                  EIS                 ; enable interrupts
                      
4801  0001                  SDBD                ; R4 = data pointer
4802  02BC 002B 0048        MVII    #data,  R4
4805  02BD 0200             MVII    #$200,  R5  ; R5 = BACKTAB pointer
                      
4807  02A0            loop  MVI@    R4,     R0  ; load data word into R0
4808  0080                  TSTR    R0          ; if it's zero ...
4809  0204 001A             BEQ     done        ; ... exit
                      
480B  0081                  MOVR    R0,     R1  ; copy R0 to R1
480C  03B9 0007             ANDI    #7,     R1  ; isolate the 3 least significant bits
                      
480E  0275            line  PSHR    R5          ; save R5 on the stack
480F  0082                  MOVR    R0,     R2  ; copy R0 to R2
4810  0066                  SLR     R2,     2   ; right-shift R2 by 3 positions
4811  0062                  SLR     R2
4812  03BA 0007             ANDI    #7,     R2  ; isolate the 3 least significant bits
4814  00D5                  ADDR    R2,     R5  ; add that to R5
4815  0083                  MOVR    R0,     R3  ; copy R0 to R3
4816  02BA 0057             MVII    #$0057, R2  ; load the value of a white '*' in R2
                      
4818  026A            char  MVO@    R2,     R5  ; write the character
4819  033B 0040             SUBI    #$40,   R3  ; subtract 64 from R3
481B  0223 0004             BPL     char        ; keep drawing while it's positive
                      
481D  02B5                  PULR    R5          ; restore R5
481E  02FD 0014             ADDI    #20,    R5  ; advance to the next line
                      
4820  0011                  DECR    R1          ; decrement R1
4821  022C 0014             BNEQ    line        ; draw another line if it's not zero
4823  0220 001D             B       loop        ; or process the next value
                      
4825  02BD 0030       done  MVII    #$30,   R5  ; R5 = pointer into STIC registers
4827  0268                  MVO@    R0,     R5  ; no horizontal delay
4828  0268                  MVO@    R0,     R5  ; no vertical delay
4829  0268                  MVO@    R0,     R5  ; no border extension
                      
482A  0017            spin  DECR    R7          ; loop forever
                      
482B  0062            data  DECLE   $062        ; data format: WWWWPPPNNN
482C  00DF                  DECLE   $0DF        ; W = width - 1
482D  0243                  DECLE   $243        ; P = left padding
482E  0000                  DECLE   0           ; N = number of lines

Output

screenshot

made with jzIntv

\$\endgroup\$
7
\$\begingroup\$

Haskell, 81 72 60 bytes

unlines[(' '<$['1'..a])++("**"<*[a..'9'])|a<-"998888888555"]

Attempt This Online!

-9 bytes thanks to Unrelated String

-9 byte thanks to ovs

Uses the range syntax [a..'9'] to do substraction.

\$\endgroup\$
6
  • \$\begingroup\$ Funny how using the do block to bind ('\n':) only ties! In any case you can go down to 79 with init$unlines instead--or drop the init, since OP's own "canonical" answer has a trailing newline too. \$\endgroup\$ Commented Nov 15, 2023 at 1:50
  • 1
    \$\begingroup\$ ...you can also kill the f=, for that matter \$\endgroup\$ Commented Nov 15, 2023 at 1:52
  • 1
    \$\begingroup\$ Haha, I was so busy golfing intercalate (see my tips answer) that I totally forgot about unlines. Thanks! \$\endgroup\$
    – corvus_192
    Commented Nov 15, 2023 at 8:38
  • 1
    \$\begingroup\$ You can save one byte with the (more boring) unlines[...|a<-[9,9,8,8,...]]. Then using <$ and <* instead of replicate can save a few more, which also allows switching from a list of integers to a string \$\endgroup\$
    – ovs
    Commented Nov 15, 2023 at 15:09
  • \$\begingroup\$ @ovs Can you show me the code? When using <$, I have to add any parentheses to fix operator precedence with ++. \$\endgroup\$
    – corvus_192
    Commented Nov 15, 2023 at 19:35
6
\$\begingroup\$

Perl 5, 42 bytes

say$"x(5-$_/2),'*'x$_ for 2,2,(4)x7,(10)x3

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Nice answer! Can't beat it, but here's a slightly more naiive approach for the same bytecount: Try it online! \$\endgroup\$ Commented Nov 20, 2023 at 9:23
  • 1
    \$\begingroup\$ @DomHastings Yeah, I had tried that, too, and came up with the same count, so I went with the slightly fancier one. \$\endgroup\$
    – Xcali
    Commented Nov 28, 2023 at 22:20
6
\$\begingroup\$

Zsh, 65 bytes

repeat 2 <<<'    **'
repeat 7 <<<'   ****'
repeat 3 <<<**********

Try it online!

It's pretty basic, clever tricks like left-padding l:expr::string1: didn't help.

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

sed, 45 bytes

Quite straight forward, with some optimisations:

  • starting with 3 trailing spaces, which can later be turned into *
  • of course using the p flag for saving one byte
  • s/ /**/4 to simply replace one space by two *
  • h;H;G to produce three identical lines
s/^/    **   /p;p
s/ /**/4p;h;H;G;p;p
s/ /*/g

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ This is really nice \$\endgroup\$
    – Jonah
    Commented Nov 15, 2023 at 15:34
5
\$\begingroup\$

///, 60 54 51 48 47 46 bytes

/a/**//s/   a//w/
aaaaa//b/
sa/ s
 sbbbbbbbwww

Try it online!

-1 byte thanks to @Philippos

\$\endgroup\$
1
  • \$\begingroup\$ 47 bytes \$\endgroup\$
    – Philippos
    Commented Nov 15, 2023 at 10:19
4
\$\begingroup\$

Vyxal, 97 bitsv2, 12.125 bytes

»ƛ⁼c»yøḊ×v*øm

Try it Online!

Bitstring:

0000111111001110001100010001100001000110001001001010100111011011101111010100110110101111000100100

Explanation:

»ƛ⁼c»yøḊ×v*øm
»ƛ⁼c»          Decompresses integer => 122753
     yøḊ       Interleave, Run-length decoding => [1,1,2,2,2,2,2,2,2,5,5,5]
        ×v*    Map repeat asterisk n times
           øm  Palindromise, center and join by newlines

The more trivial answer »ɽβ≬ǓG»f×v*øm has a higher vyncode score (probably because the compressed part is longer).

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

Charcoal, 14 bytes

↑E333ac×*⍘ιφ‖C

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

↑E333ac×*⍘ιφ

Output the first five columns of the figure, whose heights are the hexadecimal digits 333ac, starting at the bottom working up.

‖C

Make a mirror copy to complete the figure.

\$\endgroup\$
2
  • \$\begingroup\$ This outputs the wrong building, it's not tall enough \$\endgroup\$
    – ATaco
    Commented Nov 15, 2023 at 3:08
  • \$\begingroup\$ @ATaco You're right, I miscounted. That's a shame, it's going to cost me at least one byte to fix... \$\endgroup\$
    – Neil
    Commented Nov 15, 2023 at 7:04
4
\$\begingroup\$

JavaScript (V8), 59 bytes

-5 thanks to @l4m2

for(n of"443333333000")print("".padEnd(n).padEnd(10-n,"*"))

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ 59 \$\endgroup\$
    – l4m2
    Commented Nov 15, 2023 at 9:00
4
\$\begingroup\$

Japt -R, 17 bytes

#p#Þ#Þ555ì Ëç*²Ãû

Test it

#p#Þ#Þ555ì Ëç*²Ãû
#p#Þ#Þ555             :Compressed integer 112222222555
         ì            :To digit array
           Ë          :Map
            ç         :  Repeat
             *²       :    "*" duplicated
               Ã      :End map
                û     :Centre pad with spaces to the length of the longest
                      :Implicit output joined with newlines
\$\endgroup\$
4
\$\begingroup\$

MathGolf, 13 bytes

2_4··♂∙]⌂*♂Ωn

Try it online.

Explanation:

2             # Push 2
 _            # Duplicate it
  4           # Push 4
   ··         # Quadruplicate it twice
     ♂        # Push 10
      ∙       # Triplicate it
       ]      # Wrap all values on the stack into a list: [2,2,4,4,4,4,4,4,4,10,10,10]
        ⌂*    # Convert each to strings with that many "*"
          ♂Ω  # Centralize the strings to length 10
            n # Join the list of padded strings by newlines
              # (after which the entire stack is output implicitly as result)
\$\endgroup\$
4
\$\begingroup\$

6510-Assembler for C64, 42 bytes

*=$c000
  ldy #23
  lda #32
w ldx data,y
q jsr $ffd2
  dex
  bpl q
  eor #10
  dey
  bpl w
  rts

data
!byte 9,29,9,29,9,32,3,35,3,35,3,35,3,35,3,35,3,35,3,36,1,37,1,3
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice answer! I've updated the formatting a bit, feel free to make any changes if I messed something up. \$\endgroup\$ Commented Nov 16, 2023 at 20:32
  • 1
    \$\begingroup\$ That is 42 bytes assembles, isn't it? Excellent answer. \$\endgroup\$ Commented Nov 17, 2023 at 7:20
4
\$\begingroup\$

Python 3.11 (69 67 bytes nice)

print(''.join(map(lambda a,c:f"{'*'*a:^10}\n"*c,(2,4,10),(2,7,3))))

removed parentheses around fstring thanks to @corvus_192

\$\endgroup\$
7
  • 1
    \$\begingroup\$ -2 bytes by removing the parentheses around the f-string. \$\endgroup\$
    – corvus_192
    Commented Nov 14, 2023 at 20:05
  • 3
    \$\begingroup\$ Welcome to code golf! Not a big deal, but it's considered good form to wait a week or more before answering your own question. \$\endgroup\$
    – Jonah
    Commented Nov 14, 2023 at 21:07
  • 2
    \$\begingroup\$ @Jonah I disagree, this helps to add a "Canonical" solution, which can remove ambiguity from the question, and I can't see how it could harm it. \$\endgroup\$
    – ATaco
    Commented Nov 14, 2023 at 21:25
  • 4
    \$\begingroup\$ @ATaco There is discussion about this on Code Golf Meta. \$\endgroup\$
    – chunes
    Commented Nov 14, 2023 at 21:29
  • 6
    \$\begingroup\$ @ATaco: Also note the meta consensus against this does not prohibit a canonical reference. Those can be included in the OP, and should be focused on clarity rather than golfiness. What is discouraged is immediately posting a competitive golf solution. \$\endgroup\$
    – Jonah
    Commented Nov 14, 2023 at 21:45
3
\$\begingroup\$

ARBLE, 47 bytes

explode"112222222555"|rep(" ",5-x)..rep("**",x)

Relatively self explanatory, explodes the string 112222222555 into a list of single characters, each of which represents half the width of the building as it goes down. Then, maps over that list, replacing each entry with a string of 5-x spaces, and 2*x asterisks, which effectively rebuilds it.

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Scratch, 134 bytes

NOTE: This code assumes that x is already displayed. To see the full *STDOUT* as it is, you should drag the list to the full screen.

Direct solution. Had to add some spaces so it would align up nicely because when Scratch displays lists, line numbers are displayed and modify the position of their corresponding item.

Alternatively, 0 bytes

enter image description here

enter image description here

define
delete[all v]of[x v
add[       **]to[x v
add[       **]to[x v
repeat(7
add[      ****]to[x v
end
repeat(3
add[**********]to[x v

A joke about line lengths

\$\endgroup\$
3
\$\begingroup\$

APL+WIN, 52 33, 31 bytes

19 bytes saved thanks to Jonah. 2 bytes more by switching from index origin 1 to 0

'* '[2 7 3⌿⊃(⊂10⍴2)⊤¨975 903 0]

Try it online! Thanks to Dyalog Classic

Original code:

m←12 5⍴' '⋄((∊10 35 15⍴¨(⊂5⍴2)⊤¨1 3 31)/,m)←'#'⋄m,⌽m
\$\endgroup\$
2
  • \$\begingroup\$ This translation of my J answer seems to work as a snippet for 32: '* '[1+2 7 3⌿↑(2⊥⍣¯1¨975 903 0)]. Perhaps you can convert it to a fn / improve it? \$\endgroup\$
    – Jonah
    Commented Nov 15, 2023 at 18:34
  • 1
    \$\begingroup\$ @Jonah Thanks. 33 is the best I can get in APL+WIN. Still a vast improvement. \$\endgroup\$
    – Graham
    Commented Nov 15, 2023 at 19:48
3
\$\begingroup\$

Commodore BASIC V2 or compatible interpreter (Most notably the Commodore C64 or C128) - non-competing/just for fun - 106 tokenised BASIC bytes

0reada,b,c:s=1:on-(a<.)goto2:forx=1toc:ifsthen?spc(a);:s=.
1fory=1tob:?"**";:next:?:s=1:next:goto
2data4,1,2,3,2,7,0,5,3,-1,,

Here it is in action:

Commodore C64 PETSCII building

I will add a better explanation later, but for those who maybe are unfamiliar with Commodore BASIC, here is a more readable listing of broadly the same outcome that I made in order to work out the logic before I minimised and crunched the BASIC listing into the three lines in this entry:

Commodore C64 PETSCII building, but non-minimised and non-crunched

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Out of curiosity, why is this marked as non-competing? It seems like a perfectly valid solution to me... \$\endgroup\$ Commented Nov 17, 2023 at 4:35
  • \$\begingroup\$ Because PETSCII !== ASCII - the challenge states ASCII, which I assume is 8-bit ASCII and the original 7-bit ASCII standard. \$\endgroup\$ Commented Nov 17, 2023 at 7:14
  • \$\begingroup\$ The character code for '*' is the same in ASCII and PETSCII. \$\endgroup\$
    – ceilingcat
    Commented Nov 17, 2023 at 17:57
  • \$\begingroup\$ That still doesn't mean that ASCII and PETSCII are the same \$\endgroup\$ Commented Nov 17, 2023 at 18:03
3
\$\begingroup\$

C# (.NET 4.7.2), 92 90 87 88 bytes

foreach(var x in "443333333000")Console.WriteLine("".PadRight(x-48).PadRight(58-x,'*'));

Edit: @corvus_192 pointed out that using 48 instead of '0' would save a few chars. Thanks!

Implementation of Arnauld's JS version: https://codegolf.stackexchange.com/a/266751/120291

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Welcome to Code Golf, and nice answer! \$\endgroup\$ Commented Nov 15, 2023 at 15:07
  • 1
    \$\begingroup\$ '0' is 48 in ascii, so you can use "".PadRight(x-48).PadRight(58-x,'*') \$\endgroup\$
    – corvus_192
    Commented Nov 15, 2023 at 19:46
  • \$\begingroup\$ I had thought of that, but thought it was a wash. The reduction of 10-x+'0' to 58-x is a serious saver though lol Thanks! \$\endgroup\$ Commented Nov 15, 2023 at 19:51
  • \$\begingroup\$ Why is your string and @Arnauld's different? \$\endgroup\$
    – Neil
    Commented Nov 16, 2023 at 0:57
  • \$\begingroup\$ Incorrect copy from testing. I've corrected the text and bytesize for the right sequence now. \$\endgroup\$ Commented Nov 16, 2023 at 13:10
3
\$\begingroup\$

brainfuck, 107 bytes

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

Try it online!

\$\endgroup\$
3
\$\begingroup\$

PowerShell, 64 bytes (Thanks Julian!)

4,4,(,3*7),0,0,0|%{$_}|%{""|% *ht($_-'0')|% *ht(10-($_-'0'))'*'}

Try it online!

# PowerShell, 85 bytes

foreach($n in 4,4,3,3,3,3,3,3,3,0,0,0){"".PadRight($n-'0').PadRight(10-($n-'0'),'*')}

Try it online!

# PowerShell, 64 bytes

foreach($n in $c){"".PadRight($n-'0').PadRight(10-($n-'0'),'*')}

Try it online!

Thanks to @lost_in_a_musical_note's answer for laying the groundwork!

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Sorry, I do not think your solution is valid, you need to include the declaration of $c in your byte count, e.g. Try it online! \$\endgroup\$
    – Julian
    Commented Nov 16, 2023 at 22:19
  • 1
    \$\begingroup\$ @Julian You're right, wanted to test the waters but it probably is a bit unfair. I'll update soon! \$\endgroup\$ Commented Nov 17, 2023 at 9:53
  • 1
    \$\begingroup\$ :) here is a 64 bytes version of your solution: I replaced the foreach with a pipe, PadRight with |% *ht, and combined the seven threes into (,3*7) \$\endgroup\$
    – Julian
    Commented Nov 20, 2023 at 19:54
  • 1
    \$\begingroup\$ Awesome @Julian! Updated the answer :-) \$\endgroup\$ Commented Nov 21, 2023 at 9:20
2
\$\begingroup\$

RProgN 2, 22 bytes

00079){3+`**}rT{.]i.};

Explanation

00079){3+`**}rT{.]i.};
00079)                 # A Stack of the numbers 0, 0, 0, 7, 9 (Each 3 less than the height of half the columns)
      {     }r         # Replace each number with
       3+              # +3
         `**           # Multiply by "*" (Which repeats "*" x times)
              T        # Transpose
               {    }; # For each row
                .]     # Concatenate back into a string and duplicate
                  i.   # Inverse the duplicate and concatenate, palindromizing
                       # Implicit output the contents of the stack.

Try it online!

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

J, 25 bytes

'* '{~2 7 3#:@#975,903,0:

Try it online!

This just encodes the full rows as binary numbers, then duplicates them according to the 2 7 3 frequency. This results in a 12 by 10 binary matrix, which is converted to ascii.

I didn't find a way to exploit the symmetry in a way that beats this.

\$\endgroup\$
2
  • \$\begingroup\$ I imagine you came across something like this in your investigation, but the best I could come up with for exploiting symmetry is 27b: (,.~|."1)'*'#~"+2 7 3#1 2 5 \$\endgroup\$ Commented Nov 21, 2023 at 1:10
  • \$\begingroup\$ @ConorO'Brien, Yeah, I tried a few approaches like that but couldn't get the byte count down. \$\endgroup\$
    – Jonah
    Commented Nov 21, 2023 at 23:21
2
\$\begingroup\$

Retina 0.8.2, 48 bytes


42¶423333333111
3
¶34
1
¶010
(.)(.+)
$1$* $2$**

Try it online! Explanation:


42¶4233333111

Start with the encoding for the first two lines plus an encoded encoding for the remaining lines.

3
¶34
1
¶010

Decode the encoding for the remaining lines. All lines are now singly encoded.

(.)(.+)
$1$* $2$**

Decode the encoding for each line (first digit is number of spaces, other digit(s) is number of asterisks).

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

05AB1E, 16 14 bytes

2Dx7.DTÐ)'*×.c

Try it online.

Explanation:

2              # Push 2
               #  Stack: 2
 D             # Duplicate it
               #  Stack: 2,2
  x            # Double it (without popping)
               #  Stack: 2,2,4
   7           # Push 7
               #  Stack: 2,2,4,7
    .D         # Duplicate the 4 7 times
               #  Stack: 2,2,4,4,4,4,4,4,4
      T        # Push 10
               #  Stack: 2,2,4,4,4,4,4,4,4,10
       Ð       # Triplicate it
               #  Stack: 2,2,4,4,4,4,4,4,4,10,10,10
        )      # Wrap everything on the stack into a list
               #  Stack: [2,2,4,4,4,4,4,4,4,10,10,10]
         '*×  '# Convert each to a string of that many "*"
               #  Stack: ["**","**","****","****",...,"**********"]
            .c # Join by newlines and pad leading spaces to centralize the lines
               #  Stack: "    **\n    **\n   ****\n...\n**********"
               # (after which the result is output implicitly)
\$\endgroup\$
2
\$\begingroup\$

Acc!!, 85 bytes

Count i while i-132 {
Write 32+10*0^((i%11*2-9)^2/(((i/11+5)/7)^2*20+2))-i%11/10*22
}

Try it online!

Explanation

Let's start with this 99-byte version:

Count r while r-12 {
Count c while c-10 {
Write 32+10*0^((c*2-9)^2/(((r+5)/7)^2*20+2))
}
Write 10
}

We have a straightforward nested loop over 12 rows r and 10 columns c, with a newline written at the end of each row. The math to determine space or asterisk runs as follows:

We want to transform the column numbers such that inner columns map to a smaller value than outer columns; then, for each row, we can apply a cutoff so the inner columns become one character and the outer columns become a different character. Acc!! doesn't have an absolute value operator, so we'll use squaring. To preserve symmetry, we double the column number and subtract an odd constant: (c*2-9)^2

c  c*2-9  (c*2-9)^2
0  -9     81
1  -7     49
2  -5     25
3  -3     9
4  -1     1
5   1     1
6   3     9
9   9     81

The column cutoff is also dependent on the row number:

  • Rows 0-1: cutoff between 1 and 9
  • Rows 2-8: cutoff between 9 and 25
  • Rows 9-11: cutoff above 81

First, we shift and int-divide the row numbers to quantize them into the correct chunks:

r     (r+5)/7
0-1   0
2-8   1
9-11  2

Now a linear function doesn't put the cutoffs in the right range, but a quadratic function does:

(r+5)/7  ((r+5)/7)^2*20+2
0        2
1        22
2        82

Next, we need to check whether the modified column value is greater than or less than the cutoff. We can do this using int division. But that results in different non-zero values, which isn't good for the ASCII-code math we're going to do. We can convert them to 0 and 1 by exploiting the fact that 0^0 = 1 and 0^x = 0 for any positive x in Acc!!.

col  cutoff  col/cutoff  0^(col/cutoff)
1    2       0           1
9    2       4           0
25   2       12          0
1    22      0           1
9    22      0           1
25   22      1           0
1    82      0           1
9    82      0           1
25   82      0           1

We then multiply that quantity by 10 and add 32, turning 0 into 32 (space) and 1 into 42 (asterisk), and write out the appropriate character.


To get from the 99-byte version to the 85-byte version, we first move the newline-printing into the nested loop. We add an 11th column, which according to the existing math would always be a space (ASCII 32); then we subtract 22 if the column index is >= 10, turning that space into a newline (ASCII 10).

... while c-11 {
Write ... - c/10*22

Now we can combine the two loops into a single loop whose index i runs from 0 to 131. The row number r is simply i/11, and the column number c is i%11.

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

K (ngn/k), 28 bytes

" #"@+&'(12-)\'10\9992002999

Try it online!

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

Google Sheets, 88 80 79 75 bytes

=let(c,"**",n,"**
",e,"    "&n,f,"   "&c&n,g,c&c&c&c&n,e&e&rept(f,7)&g&g&g)

Put the formula in cell A1. It uses simple string concatenation. The whole output is displayed in that one cell.

The text string in n is two asterisks followed by a newline. A literal newline can be specified this way in Google Sheets, saving nine bytes over "&char(10)&".

Structured version (80 bytes):

=map({2;7;3},{4;3;0},{2;4;10},lambda(n,s,a,rept(rept(" ",s)&rept("*",a)&"
",n)))

The output is shown in A1:A3, with newlines in cells. The text string between &" and ",n" is a newline.

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

PowerShell Core, 36 bytes

,"    **"*2
,"   ****"*7
,("*"*10)*3

Try it online!

,"    **"*2    # Creates an array ("   **", "   **") print it on stdout
,"   ****"*7   # Same as above
,("*"*10)*3    # Builds and string of 10 stars, then same as above
\$\endgroup\$
2
\$\begingroup\$

Uiua 0.2.0, 28 bytes, 22 characters

+@ ×10⋯▽2_7_3-@\0"0xϿ"

See it in action

\$\endgroup\$
1
  • 1
    \$\begingroup\$ -1 \$\endgroup\$
    – chunes
    Commented Mar 30 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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