26
\$\begingroup\$

The Xerox Alto, originally released in 1973, was the first computer to feature the now-familiar angled mouse pointer. The Alto's bitmapped pointer looked like this (redrawn from Fig. 2 here):

enter image description here

Your task in this challenge is to write a program/function that generates an ASCII art representation of the mouse pointer pictured above. Rules:

  1. Input is a positive integer \$n\$, which is a scaling factor for the output.
  2. Represent each black pixel as an \$n\times{}n\$ block of any single printable character. (The test cases use @, which vaguely resembles a mouse viewed from above.)
  3. Similarly, represent each empty pixel to the bottom/left of the pointer as an \$n\times{}n\$ block of a second printable character. (Spaces are used in the test cases.)
  4. Optionally, your output may also include the empty pixels to the top/right of the pointer, represented by the same character chosen under Rule 3.
  5. Any sensible output format (e.g. multi-line string, array of strings, matrix of characters) is acceptable.
  6. A single trailing newline at the end of the output is permitted.

Test cases

\$n = 1\$

@
@@
@@@
@@@@
@@@@@
@@@@@@
@@@@@@@
@@@@
@@ @@
@  @@
    @@
    @@
     @@
     @@
      @@
      @@

\$n = 2\$

@@
@@
@@@@
@@@@
@@@@@@
@@@@@@
@@@@@@@@
@@@@@@@@
@@@@@@@@@@
@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@@@@@@@@@@@
@@@@@@@@
@@@@@@@@
@@@@  @@@@
@@@@  @@@@
@@    @@@@
@@    @@@@
        @@@@
        @@@@
        @@@@
        @@@@
          @@@@
          @@@@
          @@@@
          @@@@
            @@@@
            @@@@
            @@@@
            @@@@

\$n = 3\$

@@@
@@@
@@@
@@@@@@
@@@@@@
@@@@@@
@@@@@@@@@
@@@@@@@@@
@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@@@@@@@
@@@@@@   @@@@@@
@@@@@@   @@@@@@
@@@@@@   @@@@@@
@@@      @@@@@@
@@@      @@@@@@
@@@      @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
            @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
               @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@
                  @@@@@@
\$\endgroup\$
5
  • 1
    \$\begingroup\$ Is a matrix of zeros and ones (numeric) allowed as output? When printed, it will have a space between them, e.g. 1 0 0 0 0 0 0 0\n1 1 0 0 0 0 0 0\n.... \$\endgroup\$
    – Bubbler
    Commented Sep 25, 2020 at 8:40
  • \$\begingroup\$ @Bubbler As long as you can demonstrate that the matrix elements are in the right place, that's fine. \$\endgroup\$
    – Dingus
    Commented Sep 25, 2020 at 9:13
  • \$\begingroup\$ Related \$\endgroup\$
    – 640KB
    Commented Sep 25, 2020 at 18:13
  • \$\begingroup\$ In Mathematica, matrices are generally represented as nested lists (e.g., {{1, 0}, {0, 1}}). They can also be represented as SparseArray objects, which are interchangable with such matrices in most cases. Are either of these two forms acceptable output? \$\endgroup\$ Commented Sep 26, 2020 at 20:09
  • 2
    \$\begingroup\$ @LegionMammal978 The matrix/nested list format is OK. SparseArray pushes the boundaries a little too far for my liking. \$\endgroup\$
    – Dingus
    Commented Sep 27, 2020 at 1:13

20 Answers 20

10
\$\begingroup\$

JavaScript (ES6),  92 91  90 bytes

Saved 1 byte thanks to @Neil

Returns a string with \$0\$'s for transparent pixels and \$1\$'s for black pixels.

n=>(g=k=>--k?(x=k/n%8,y=k/n/n/8,(~1<<(y>9?y-9:13-y)|3<<y/2)>>x&1)+[`
`[x]]+g(k):1)(n*n<<7)

Try it online!

or Try it with the characters used in the challenge for easier comparison

How?

Given the scaling factor \$n\$ as input, we output the bit \$\lfloor x\rfloor\bmod 8\$ of the bitmask corresponding to the row \$\lfloor y\rfloor\$ for each \$k\$, \$0\le k <128\times n^2\$, with \$x=k/n\$ and \$y=k/(8\times n^2)\$.

To generate the bitmask of a given row, we use two small expressions whose results are OR'd together. Only the 8 least significant bits are shown below. The other ones are ignored anyway.

floor(y) -> A(y)  OR  B(y)   =  result
   15     10000000  10000000   10000000    with:
   14     11000000  10000000   11000000
   13     11100000  11000000   11100000    A(y) = ~1 << (y > 9 ? y - 9 : 13 - y)
   12     11110000  11000000   11110000    B(y) = 3 << y / 2
   11     11111000  01100000   11111000
   10     11111100  01100000   11111100
    9     11111110  00110000   11111110
    8     11100000  00110000   11110000
    7     11000000  00011000   11011000
    6     10000000  00011000   10011000
    5     00000000  00001100   00001100
    4     00000000  00001100   00001100
    3     00000000  00000110   00000110
    2     00000000  00000110   00000110
    1     00000000  00000011   00000011
    0     00000000  00000011   00000011

A linefeed is appended to the output whenever \$k/n\$ is a multiple of \$8\$.

\$\endgroup\$
3
  • \$\begingroup\$ I think you can use -2 instead of 254. \$\endgroup\$
    – Neil
    Commented Sep 25, 2020 at 18:35
  • \$\begingroup\$ @Neil Of course, thank you! (~1 is a bit more readable, IMO.) \$\endgroup\$
    – Arnauld
    Commented Sep 25, 2020 at 18:41
  • 1
    \$\begingroup\$ I actually tested with ~1 but I chickened out and used -2 in my comment... \$\endgroup\$
    – Neil
    Commented Sep 25, 2020 at 18:49
5
\$\begingroup\$

05AB1E, 33 31 bytes

•4CîιZ›ÚAôçè~]ß4ÿ•Ƶāвε2в¦I×JIF=

Outputs with 1 for @ and 0 for spaces.

-1 byte by not outputting trailing 0/spaces.

Try it online or verify all test cases.

Explanation:

•4CîιZ›ÚAôçè~]ß4ÿ• # Push compressed integer 5077310163681960509504474007720499199
 Ƶā                # Push compressed integer 260
   в               # Convert the larger integer to base-260 as list:
                   #  [3,7,15,31,63,127,255,31,59,51,67,67,131,131,259,259]
    ε              # Foreach over the integers in this list:
     2в            #  Convert it to a binary-list
       ¦           #  Remove the leading 1
        I×         #  Repeat each character the input amount of times
          J        #  Join it together to a single string
           IF      #  Inner loop the input amount of times:
             =     #   Print the line with trailing newline (without popping the string)

See this 05AB1E tip of mine (sections How to compress large integers? and How to compress integer lists?) to understand why •4CîιZ›ÚAôçè~]ß4ÿ• is 5077310163681960509504474007720499199; Ƶā is 260; and •4CîιZ›ÚAôçè~]ß4ÿ•Ƶāв is [3,7,15,31,63,127,255,31,59,51,67,67,131,131,259,259].

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

APL (Dyalog Extended), 31 bytes

{⍵/⍵⌿⌽⍉⊤⎕AV⍳'⍞§):┼|¨:┴│⍫⍫⍀⍀¢¢'}

Try it online!

I guess this is the best APLers can do for now. Outputs a numeric matrix of zeros and ones, as per the clarification.

Basically the same approach as Razetime's answer, using ⎕IO←0 to avoid unprintables.

Hey, it tied with Jelly AND 05AB1E! Almost...

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

APL (Dyalog Extended), 41 bytes

{⎕A[1+⍵/⍵⌿⍉⊤(⎕AV⍳'⌷⊤└¶⍝ ⎕¶"í'),2/12 6 3]}

Try it online!

Letter B for colored pixels, A for transparent pixels.

Uses an APL tip from Andriy Makukha to compress integers.

Explanation

{⎕A[1+⍵/⍵⌿⍉⊤(⎕AV⍳'⌷⊤└¶⍝ ⎕¶"í'),2/12 6 3]} ⍵ → n
                               2/12 6 3   12, 6 and 3 repeated in place
                 '⌷⊤└¶⍝ ⎕¶"í'             String of compressed values
            (⎕AV⍳            )            The SBCS codepoints of the string
                              ,           Join them
          ⍉⊤                              convert to binary & transpose
      ⍵/⍵⌿                                replicate each element n times along both axes
    1+                                    Add 1 to each for getting 1-based indices
 ⎕A[                                   ]  Index the grid into the alphabet
\$\endgroup\$
4
\$\begingroup\$

05AB1E, 29 bytes

White pixels are represented by 0, black pixels by 1.

•ˆ‰₃%ʒ„úVð“£Xfóó”•b8ôεSI×JIF=

Try it online!

Commented:

The IF= part is taken from Kevin's answer.

•ˆ‰₃%ʒ„úVð“£Xfóó”•              # long compressed integer, encodes the 16x8 cursor
                  b             # convert to binary
                   8ô           # split into chunks of 8 digits (rows)
                     ε          # map over the rows ...
                      S         #   split into characters
                       I×       #   multiply each with the input
                         J      #   join into a single string
                          I     #   push the input
                           F    #   for loop in the range [0, input)
                            =   #   print row without popping

05AB1E, 27 bytes

This generates the first seven lines more manually but has some inconsistent spacing. If X7L× is replace by ₁7LRo-b, the spacing is consistent again at 30 bytes.

X7LוùΛh‡Wgÿ™Œ•b8ô«εSI×JIF=

Try it online!


05AB1E, 31 bytes

Same output format, uses run length encoding.

TÞ•€¶àĆαL0šDž¬тq•8вÅΓ8ôεSI×JIF=

Try it online!

Commented:

T                        # push 10
 Þ                       # cycle indefinitely
                         # produces 10101..., the characters used for RLE
  •€...q•8в              # compressed list of lengths [1,7,2,6,3,5,4,4,5,3,6,2,7,1,4,4,2,1,2,3,1,2,2,7,2,6,2,7,2,6,2,7,2,6,2]
           ÅΓ            # run length decode
             8ô          # split into chunks of 8
               εSI×JIF=  # the same as above
\$\endgroup\$
3
\$\begingroup\$

Perl 5 + -a -M5.10.0, 66 bytes

Outputs 1 for black and 0 for empty pixels.

Note: This script utilises unprintables, which are represented using escapes below. Verification for 66 bytes.

s/./$&x"@F"/ge,eval"say;"x"@F"for unpack"(B8)*","................"

Try it online!

Explanation

Using -a the input number is stored (as the only index) in @F, which can be interpolated into a string ("@F") saving one byte over using $F[0] notation, to control the repetition of characters and lines, as using -n would only store the number in $_, which is overwritten in the body of the for. The string at the end represents the binary data for black or empty pixels which is unpacked in lengths of 8. In the body of the postfix for loop, each block of 8 bits, represented as a string of 0s and 1s, is stored in $_. First each char in the string is replicated "@F" times (s/./$&x"@F"/ge) then eval is called on a string that contains "@F" repetitions of "say;" outputting $_ the number of desired times.

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

J, 55 50 49 bytes

-1 byte thanks to xash!

##"1&(16 8$#:96x#._32+3 u:'#dppv6SI=Hz`rW~|%1rc')

Try it online!

Ouptus a matrix of 1's and 0s.

\$\endgroup\$
2
  • \$\begingroup\$ @xash Oh yes, thank you! \$\endgroup\$ Commented Sep 25, 2020 at 10:33
  • 1
    \$\begingroup\$ ##"1 is nice. it would be nice if there was a way to do compression with unicode characters, but i don't know of one. \$\endgroup\$
    – Jonah
    Commented Sep 27, 2020 at 5:41
3
\$\begingroup\$

Jelly, 25 bytes

7Żx2r‘$Ṭ
3Ėr7,1FRoÇṠz0xɗ⁺

A monadic Link accepting the scaling factor which yields a list of lists of pixel bits (1s are the arrow, 0s are the background)

Try it online! (footer calls the link, joins with newlines and prints a smashed version of the resulting list)

How?

3Ėr7,1FRoÇṠz0xɗ⁺ - Link: positive integer, n
3                - three
 Ė               - enumerate -> [1,3]
   7,1           - [7,1]
  r              - inclusive range (vectorises) -> [[1,2,3,4,5,6,7],[3,2,1]]
      F          - flatten -> [1,2,3,4,5,6,7,3,2,1]
       R         - range -> [[1],[1,2],...,[1,2,3,4,5,6,7],[3,2,1],[2,1],[1]]
         Ç       - call Link 1 as a monad - f(n)
        o        - logical OR (vectorises)
          Ṡ      - sign (i.e. convert all the positive integers to 1s)
               ⁺ - do this twice:
              ɗ  -   last three links as a dyad - f(matrix, n)
            0    -     zero
           z     -     transpose (matirix) with filler (0)
             x   -     repeat elements (n) times

7Żx2r‘$Ṭ - Link 1: positive integer, n
7        - seven
 Ż       - zero-range -> [0,1,2,3,4,5,6,7]
   2     - two
  x      - repeat elements -> [0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
      $  - last two links as a monad - f(that):
     ‘   -   increment     -> [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8]
    r    - inclusive range -> [[0,1],[0,1],[1,2],[1,2],[2,3],[2,3]...,[7,8]]
       Ṭ - un-truth        -> [[1],[1],[1,1],[1,1],[0,1,1],[0,1,1],...,[0,0,0,0,0,0,1,1]

Also 25 bytes:

“ṚẒỴġị!=gEḃĖT⁴ċṪ ’Bs8Zx¥⁺ - Link: positive integer, n
“ṚẒỴġị!=gEḃĖT⁴ċṪ ’        - base 250 number = 171142666808876275700130073576311489283
                  B       - to binary
                   s8     - split into slices of length (8)
                        ⁺ - do this twice:
                       ¥  -   last two links as a dyad - f(matrix, n)
                     Z    -     transpose
                      x   -     repeat element (n) times

Try it online!

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

Charcoal, 35 bytes

NθF⪪“∨:[¿θ≡↥χ№pTξ⟧M~▶§×¬‴↥”¶Eθ⭆ι×θμ

Try it online! Link is to verbose version of code. Outputs using .s and spaces (newlines, spaces and .s are the golfiest characters for Charcoal compression). Explanation:

Nθ

Input n.

F⪪“∨:[¿θ≡↥χ№pTξ⟧M~▶§×¬‴↥”¶

Split a compressed representation of the arrow into lines and loop over each line.

Eθ⭆ι×θμ

Expand each line n times vertically and horizontally.

Alternative approach, also 35 bytes:

NθFχEθ×.×⎇‹ι⁷⊕ι⁻χιθJ⁰⊗θF⁷«UO⊗θ.Mθ⊗θ

Try it online! Link is to verbose version of code. Outputs using . and spaces although any non-space printable ASCII could be used. Explanation:

Nθ

Input n.

Fχ

Start by printing the first 10 rows of the arrow.

Eθ×.×⎇‹ι⁷⊕ι⁻χιθ

Print a staircase from 1 to 7, then down from 3 to 1, all expanded n times.

J⁰⊗θ

Jump to the beginning of the second row.

F⁷«

Loop 7 times.

UO⊗θ.

Draw a square of size 2n.

Mθ⊗θ

Move n across and 2n down.

\$\endgroup\$
3
  • \$\begingroup\$ An awfully oblong approach \$\endgroup\$
    – Razetime
    Commented Sep 25, 2020 at 9:52
  • \$\begingroup\$ @Razetime My best "primitive" answer was 39 bytes. \$\endgroup\$
    – Neil
    Commented Sep 25, 2020 at 10:22
  • 1
    \$\begingroup\$ @Razetime After a bit of inspiration from Arnauld's answer, I realised that I could draw two useless extra squares, which reduced my byte count down to 35, thus enabling me to add it as an alternative answer. \$\endgroup\$
    – Neil
    Commented Sep 25, 2020 at 18:47
2
\$\begingroup\$

Octave, 69 bytes

@(n)kron([1:8<=(1:7)';dec2bin(['pX'+128 156 ',,&&##'-32])-48],e(n))>0

Anonymous function that inputs a positive integer and outputs a zero-one matrix.

Try it online!

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

C# (Visual C# Interactive Compiler), 97 chars, 107 bytes

n=>{for(int i=0,j;i<n*16;Write("\n"),i++)for(j=n*8;j>0;)Write("€Ààðøüþðؘ"[i/n]>>--j/n&1);}

Try it online!

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

Python 2, 167 145 bytes

i=input()
m='@'*i*2
s=' '*i
for z in[c*i*'@'for c in range(1,8)]+[m*2,m+s+m,m[:i]+s*2+m]+sum([[s*d+m]*2for d in(4,5,6)],[]):print'\n'.join([z]*i)

Try it online!

Down to 145 with some great help from @ovs. Many thanks!

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

brainfuck, 1892 bytes

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

Try it online!

Not a short answer by any means - it could probably be shortened by a good bit.

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

Python 3, 124 145 136 bytes

+21 bytes because I didn't realise we had to scale it vertically as well

-9 bytes by using . for padding

lambda n,s='@\n.X'*27,J=''.join:J(n*(l+'\n')for l in J(n*s[m>>4]+n*s[m>>2]+n*s[m]for m in b'DDA@D@D@A@@D@P`R`ZhFjAjhFj`Zj`Zj`').split())

Try it online!

Explanation of the b'DDA@D@D@A@@D@PRZhFjAjhFjZjZj`' string

(the code does this in reverse)

take the string, and:

  • replace "on" pixel with 0
  • replace new-line with 1
  • replace space ("off" pixel) with 2
010010001000010000010000001000000010000100200102200122220012222001222220012222200122222200122222200

convert to binary, two bits per decimal digit:

000100000100000001000000000100000000000100000000000001000000000000000100000000010000100000010010100000011010101000000110101010000001101010101000000110101010100000011010101010100000011010101010100000

split into groups of 6:

000100 000100 000001 000000 000100 000000 000100 000000 000001 000000 000000 000100 000000 010000 100000 010010 100000 011010 101000 000110 101010 000001 101010 101000 000110 101010 100000 011010 101010 100000 011010 101010 100000

logical-OR each group with 01000000 (so it's all printable ASCII, to avoid escape characters):

01000100 01000100 01000001 01000000 01000100 01000000 01000100 01000000 01000001 01000000 01000000 01000100 01000000 01010000 01100000 01010010 01100000 01011010 01101000 01000110 01101010 01000001 01101010 01101000 01000110 01101010 01100000 01011010 01101010 01100000 01011010 01101010 01100000

convert to ASCII for a Python bytestring:

b'DDA@D@D@A@@D@P`R`ZhFjAjhFj`Zj`Zj`'
\$\endgroup\$
0
2
\$\begingroup\$

Python 2, 102 bytes

n=input()
for k in range(16*n):print''.join(n*' @'[j<=k/n<max(7,10-j)or-1<k/n/2-j<2]for j in range(8))

Try it online!

Computes whether the given coordinate is on of off by a formula that bounds the arrow shape via linear inequalities. To check if the cell is in the tail, which is made of 2*2 blocks (unscaled), we floor-divide the row index by 2 and check whether it either equals the column index or is one greater than it.

As a function outputting a list of lines:

97 bytes

lambda n:[''.join(n*' @'[j<=k/n<max(7,10-j)or-1<k/n/2-j<2]for j in range(8))for k in range(16*n)]

Try it online!

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

C (gcc),  106 105 103  102 bytes

Saved 1 byte thanks to @Neil

Prints the pointer with spaces and exclamation points. Essentially the same method as in my JS answer.

x,y;f(n){for(y=n*16;y--;)for(x=n*8;~x;)putchar(x--?32^(~1<<(y/n>8?y/n-9:12-y/n)|3<<y/n/2)>>x/n&1:13);}

Try it online!

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

Jelly, 31 30 bytes

5r8ṬƝż`Ẏ
1ẋⱮ7;“ÐñŒ‘B;¢xẎ¥€z0ɗ⁺

Try it online!

-1 from Jonathan Allan's answer reminding me of . Now to figure out why his z0xɗ won't work for me...

Outputs a 2D array of 1 for for on and 0 for off. Integers, rather than characters, though, so +2 for a full program (µY) if that's a problem.

          Dyadic helper link:
   €      Map
x         repeat left right times
 Ẏ¥       and dump internal lists.
    z0    Zip with filler 0.

                             Main link:
1ẋ                           Repeat 1
  Ɱ7                         1, 2, 3, 4, 5, 6, and 7 times.
    ;                        Concatenate with
     “ÐñŒ‘                   [15, 27, 19].
          B                  Vectorized convert to binary
                             (applies to first bit too, but leaves it unharmed).
           ;                 Concatenate with
                Ṭ    ¤       a list with 1s at the given indices
                 Ɲ           for each pair of adjacent numbers in
            5r8¤             the range from 5 to 8 inclusive,
                  ż`         zipped with itself
                    Ẏ        and with each zipped pair dumped.
                      ç      Apply the helper link with input as right argument.
                       ç     Apply the helper link with input as right argument.
\$\endgroup\$
1
\$\begingroup\$

C (gcc), 162 \$\cdots\$ 126 104 bytes

Saved a whopping 26 bytes thanks to ceilingcat!!!
Saved another whopping 22 bytes thanks to AZTECCO!!!

Note: code contains unprintables.

j;i;f(n){for(i=16*n;i--;puts(""))
for(j=8*n;j--;)putchar(32|L"˜ØðþüøðàÀ€"[i/n]>>j/n&1);}

Try it online!

Uses ! for black pixels (since it's the ascii for space plus \$1\$) and spaces for empty pixels (only if preceded by a black pixel, otherwise nothing).

\$\endgroup\$
4
  • 1
    \$\begingroup\$ @AZTECCO That's awesome - thanks muchly! : D \$\endgroup\$
    – Noodle9
    Commented Sep 26, 2020 at 7:23
  • 1
    \$\begingroup\$ @Dingus TIO has a bug if you switch to Bash it'll show the correct byte count. Good point on mentioning that the string contains unprintables - done. \$\endgroup\$
    – Noodle9
    Commented Sep 26, 2020 at 8:01
  • \$\begingroup\$ @AZTECCO TIO has a bug if you switch to Bash it'll show the correct byte count. \$\endgroup\$
    – Noodle9
    Commented Sep 26, 2020 at 9:09
  • \$\begingroup\$ Ah! Maybe it escapes unprintable characters for you? I guess.. \$\endgroup\$
    – AZTECCO
    Commented Sep 26, 2020 at 10:12
1
\$\begingroup\$

Wolfram Language (Mathematica), 90 bytes

Normal@SparseArray[a_:>36^^4iam2h6stciyoj9kt5169kwfgn4~BitGet~Tr[{8,1}⌈a/#⌉],{16,8}#]&

Try it online! Pure function. Takes an integer as input and returns a matrix with 0 and 1 entries.

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

Canvas, 32 bytes

“┌Wwz‼GZE⁸↘4BUH<U„2┬8n{{⁴+c]]╶╶*

Try it here!

A better compression method would reduce this by a lot.

\$\endgroup\$

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.