Immagine di un vecchio amico nell'arte ASCII


36

Spero che questa immagine ti sembri familiare.

enter image description here

È uno dei fantasmi di Pacman nel suo stato "vulnerabile" , dopo che Pacman ha mangiato una pillola di potere.

La sfida

Immagina il nostro fantasma in una piccola cornice, usando l'arte ASCII. A scala normale (ne parleremo più avanti), ogni quadrato nell'immagine sopra dovrebbe corrispondere a un carattere, e la cornice dovrebbe avere una separazione di un carattere su e giù e una separazione di due caratteri a sinistra e a destra del fantasma :

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

Ma questo non sembra molto carino. #potrebbe non essere la scelta migliore per i pixel attivi. Inoltre, le celle dei personaggi non sono quadrate, il che rende il nostro amico più spettrale di quanto non sia già.

Quindi, per avere maggiore flessibilità, l'immagine cambierà in base a tre parametri di input:

  • Carattere da utilizzare per i pixel attivi;
  • Fattore di scala orizzontale;
  • Fattore di scala verticale.

Ad esempio, con %, 4, 2l'output potrebbe essere l'immagine più bello

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%                                                                        %%%%
%%%%                                                                        %%%%
%%%%                            %%%%%%%%%%%%%%%%                            %%%%
%%%%                            %%%%%%%%%%%%%%%%                            %%%%
%%%%                    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                    %%%%
%%%%                    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                    %%%%
%%%%                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                %%%%
%%%%                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                %%%%
%%%%            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%            %%%%
%%%%            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%            %%%%
%%%%            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%            %%%%
%%%%            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%            %%%%
%%%%            %%%%%%%%%%%%        %%%%%%%%        %%%%%%%%%%%%            %%%%
%%%%            %%%%%%%%%%%%        %%%%%%%%        %%%%%%%%%%%%            %%%%
%%%%        %%%%%%%%%%%%%%%%        %%%%%%%%        %%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%%%%%%%%%        %%%%%%%%        %%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%        %%%%%%%%        %%%%%%%%        %%%%%%%%        %%%%
%%%%        %%%%%%%%        %%%%%%%%        %%%%%%%%        %%%%%%%%        %%%%
%%%%        %%%%    %%%%%%%%        %%%%%%%%        %%%%%%%%    %%%%        %%%%
%%%%        %%%%    %%%%%%%%        %%%%%%%%        %%%%%%%%    %%%%        %%%%
%%%%        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        %%%%
%%%%        %%%%%%%%    %%%%%%%%%%%%        %%%%%%%%%%%%    %%%%%%%%        %%%%
%%%%        %%%%%%%%    %%%%%%%%%%%%        %%%%%%%%%%%%    %%%%%%%%        %%%%
%%%%        %%%%            %%%%%%%%        %%%%%%%%            %%%%        %%%%
%%%%        %%%%            %%%%%%%%        %%%%%%%%            %%%%        %%%%
%%%%                                                                        %%%%
%%%%                                                                        %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Regole

Sono ammessi tutti i builtin.

Gli input sono presi in qualsiasi formato ragionevole e in qualsiasi ordine. Il primo input sopra (carattere per pixel attivi) è garantito per essere un carattere ASCII stampabile (codici da 32 a 126).

Spazio accettabile dopo ogni riga o trascinamento di nuove righe dopo l'ultima riga sono accettabili.

Codice golf, vince il minor numero di byte.


Guarda attentamente l'immagine per alcuni secondi. Allora vedi cosa succede! ...
sergiol

Non riesco a credere che finora non ci siano osservazioni sul carbone.
Weijun Zhou,

Risposte:


34

CJam, 53 51 49 byte

q~"ǟ #/?Y__Fy_Nf ǟ"f{'Ƞ^2b_W%+S@+f=}fe*e*N*

Si noti che tre dei personaggi non sono stampabili. Provalo online!

sfondo

La metà destra dell'output non scalato è identica a quella sinistra, quindi è sufficiente codificarne uno. Se sostituiamo gli spazi con zero e i non spazi con uno, otteniamo

1111111111
1000000000
1000000011
1000001111
1000011111
1000111111
1000111111
1000111001
1001111001
1001111111
1001111111
1001100110
1001011001
1001111111
1001101110
1001000110
1000000000
1111111111

dove ogni riga può essere interpretata come un numero binario. Questo cede

1023 512 515 527 543 575 575 569 633 639 639 614 601 639 622 582 512 1023

Il modo più semplice per codificare queste informazioni è sostituire ogni intero con il carattere Unicode in quel punto di codice, ma richiederebbero tutti due byte per essere codificati con UTF-8.

XORing gli interi con 544, manteniamo tutti tranne due interi al di sotto di 128 ed evitiamo byte nulli.

Il risultato è

479 32 35 47 63 31 31 25 89 95 95 70 121 95 78 102 32 479

come numeri interi o

ǟ #/?\x1f\x1f\x19Y__Fy_Nf ǟ

come una stringa di escape.

Come funziona

q~                e# Read and evaluate all input. This pushes the vscale factor V,
                  e# the hscale factor H, and the character C.
"ǟ #/?Y__Fy_Nf ǟ" e# Push that string.
f{                e# For each character, push C and the character; then:
'Ƞ^               e#   XOR the character with '\u0220' (544), casting to integer.
 2b               e#   Convert from integer to base 2.
 _W%              e#   Push a reversed copy of the binary digits.
 +                e#   Concatenate.
 S@+              e#   Append C to " ".
 f=               e#   Replace each binary digit with ' ' or C.
}                 e#
fe*               e# Repeat each character in each string H times.
e*                e# Repeat each string V times.
N                 e# Join the strings, separating by linefeeds.

7
How quick, and short code! Impressive!
Luis Mendo

10

Perl, 113 105 104 100 97 96

Added +2 for -ap

Suggestions by dev-null save 9 bytes Fixed wrong count as noticed by Dennis

Run using echo "2 4 %" | perl -ap pacman.pl

pacman.pl:

}for(map+(unpack(aXBXB8Xb8XBXa),$/)x"@F","\xff\x00\x03\x0f\x1f\x3f\x3f\x39\x79\x7f\x7f\x66\x59\x7f\x6e\x46\x00\xff"=~/./g){s%%($&?$F[2]:$")x$F[1]%ge

except that the string "\xff\x00\x03\x0f\x1f\x3f\x3f\x39\x79\x7f\x7f\x66\x59\x7f\x6e\x46\x00\xff" should be written in binary form with single quotes

Space as replacement character becomes the empty string and leads to short lines. But it will all look blank anyways


9

Dyalog APL, 64 bytes

{/∘⍉/⍺,⊂' '⍵[1+,∘⌽⍨1⍪⍨1⍪1,0⍪⍨0⍪0,0,⍉(7/2)⊤⎕AV⍳'Äâ\⊥⊥∘)⍞⍞┬#⍞`⍒']}

This takes the scale factor as its left argument and the character as its right argument, i.e:

      2 1{/∘⍉/⍺,⊂' '⍵[1+,∘⌽⍨1⍪⍨1⍪1,0⍪⍨0⍪0,0,⍉(7/2)⊤⎕AV⍳'Äâ\⊥⊥∘)⍞⍞┬#⍞`⍒']}'%'
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 %%                                    %% 
 %%              %%%%%%%%              %% 
 %%          %%%%%%%%%%%%%%%%          %% 
 %%        %%%%%%%%%%%%%%%%%%%%        %% 
 %%      %%%%%%%%%%%%%%%%%%%%%%%%      %% 
 %%      %%%%%%%%%%%%%%%%%%%%%%%%      %% 
 %%      %%%%%%    %%%%    %%%%%%      %% 
 %%    %%%%%%%%    %%%%    %%%%%%%%    %% 
 %%    %%%%%%%%%%%%%%%%%%%%%%%%%%%%    %% 
 %%    %%%%%%%%%%%%%%%%%%%%%%%%%%%%    %% 
 %%    %%%%    %%%%    %%%%    %%%%    %% 
 %%    %%  %%%%    %%%%    %%%%  %%    %% 
 %%    %%%%%%%%%%%%%%%%%%%%%%%%%%%%    %% 
 %%    %%%%  %%%%%%    %%%%%%  %%%%    %% 
 %%    %%      %%%%    %%%%      %%    %% 
 %%                                    %% 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

Explanation:

  • ⍉(7/2)⊤⎕AV⍳'Äâ\⊥⊥∘)⍞⍞┬#⍞`⍒': The left half of the ghost, without the border. (It is symmetric.) Each character has its high bit set, to prevent selecting non-printing characters from ⎕AV, but only the first 7 bytes are used.

  • 0,⍪⍨0⍪0,0,: add a border of blanks on the left, top, and bottom

  • 1⍪⍨1⍪1,: add the frame on the left, top, and bottom
  • ,∘⌽⍨: join it with its vertical mirror
  • 1+: add 1, because arrays are 1-indexed by default
  • ' '⍵[...]: use that matrix as an index into the string ' '⍵, so each 0 gets mapped to a blank and each 1 gets mapped to .
  • ⍺,⊂: enclose the matrix and join it to the scale factors
  • /: right fold with the following function:
  • /∘⍉: transpose and scale horizontally

7

MATL, 71 bytes

32hO511-3-12-16-32O6-64-6O25 13-38 17 40 70-511Nq$hYs10H$Bt!P!hi1$lX*Q)

Try it online!

Explanation

The image is horizontally symmetric, so only the left half needs to be coded. Each 10-pixel row is binary coded as a number between 0 and 1023. Active pixels are coded as 0 rather than 1, so the first row is number 0 rather than 1023.

Since consecutive rows differ by a few pixels only, the numbers are further encoded differentially. So each row will be decoded as the cumulative sum of all numbers up to that row, followed by conversion to binary.

The needed numbers are then

0 511 -3 -12 -16 -32 0 6 -64 -6 0 25 13 -38 17 40 70 -511

0 is introduced in MATL using the O function, which avoids a separator with neighbouring numbers. Also, negative signs do not imply extra bytes as they serve as separators.

Once the array has been created, it is cumulatively summed, binary-decoded, and horizontally mirrored. The resulting 2D array is used to index a two-char string to produce the result. This string is of the form '% ', where '%' is an input char.

As noted by @Conor, the code also works with two chars as input. In this case the final string indexed into will be of the form '%_ ', where the input is a two-char string '%_'. The space will simply be ignored, because the indexing array only addresses the first two chars.

32                                             % space (ASCII)
h                                              % concat horizontally with 1st input: char
O511-3-12-16-32O6-64-6O25 13-38 17 40 70-511   % push these numbers
Nq$h                                           % concat all those numbers
Ys                                             % cumulative sum
10H$B                                          % convert to 10-digit binary numbers
                                               % gives 2D array, each number in one row
t                                              % duplicate
!P!                                            % flip horizontally
h                                              % concat horizontally
i                                              % take 2nd input: array [V H]
1$l                                            % matrix oh V×H ones  
X*                                             % Kronecker product to increase vertical
                                               % and horizontal scales by V and H resp.
Q                                              % add 1. Converts array of 0,1 into 1,2
)                                              % uses those 1,2 as indices into string


1
As of version 16.0.0 of the language, replace commas by spaces
Luis Mendo

3

C (gcc), 199 197 bytes

-2 bytes thanks to @JonathanFrech

n,j;f(c,h,v){for(char t[20],i=18;i--;){for(n=10;n--;)t[n]=t[19-n]=((("\xff\0""1;\x7fM3\x7f\x7fON~~|x`\0\xff"[i]<<3)|(i&&i^17?1:7))>>n)&1?c:32;for(j=v;j--;puts(""))for(n=20*h;n--;)putchar(t[n/h]);}}

Try it online!

188 bytes (unprintables)

Courtesy of @JonathanFrech.

n,j;f(c,h,v){for(char t[20],i=18;i--;){for(n=10;n--;)t[n]=t[19-n]=((("\xff\0001;M3ON~~|x`\0\xff"[i]<<3)|(i&&i^17?1:7))>>n)&1?c:32;for(j=v;j--;puts(""))for(n=20*h;n--;)putchar(t[n/h]);}}

Try it online!

Nothing spectacular going on. Like others noticed, the ghost is highly symmetrical. The image itself is 20 units wide, but except for the top and bottom rows, the three right-most columns are identical. This allows us to store half of the image as characters instead of having to use integers:

#######  127     \x7f
           0     \0
##        96     `
####     120     x
#####    124     |
######   126     ~
######   126     ~
#  ###    78     N
#  ####   79     O
#######  127     \x7f
#######  127     \x7f
 ##  ##   51     3
#  ## #   77     M
#######  127     \x7f
 ### ##   59     ;
 ##   #   49     1
           0     \0
#######  127     \x7f

The resulting string was reversed to eke out a few bytes on having a descending for loop (also solving an annoying issue with hexadecimal escapes). Other loops could be flipped without issue thanks to symmetry.

Each character is shifted left and given a border (with special care on first and last rows). Then it's just a matter of outputting the string correctly scaled.

All the for loops makes me feel there is a better way.



@JonathanFrech Ah, thanks!
gastropner


@JonathanFrech Neat one, but not too keen on the unprintables.
gastropner

Do you have any idea why \xff cannot be replaced by ÿ (TIO)?
Jonathan Frech

2

Seriously, 116 bytes

╩' "3ff 200 203 20f 21f 23f 23f 239 279 27f 27f 266 259 27f 26e 246 200 3ff"s`24╙(¿¡╜'1(Æ' '0(Æ"╛*"£M;R@+εj2└@n`M'
j

That newline is important. Hexdump:

00000000: ca27 2022 3366 6620 3230 3020 3230 3320  .' "3ff 200 203
00000010: 3230 6620 3231 6620 3233 6620 3233 6620  20f 21f 23f 23f
00000020: 3233 3920 3237 3920 3237 6620 3237 6620  239 279 27f 27f
00000030: 3236 3620 3235 3920 3237 6620 3236 6520  266 259 27f 26e
00000040: 3234 3620 3230 3020 3366 6622 7360 3234  246 200 3ff"s`24
00000050: d328 a8ad bd27 3128 9227 2027 3028 9222  .(...'1(.' '0(."
00000060: be2a 229c 4d3b 5240 2bee 6a32 c040 6e60  .*".M;R@+.j2.@n`
00000070: 4d27 0d0a 6a                             M'..j

Same strategy as Dennis's CJam answer, but the values are encoded in hex, rather than XORed with 544, and string manipulation is a lot harder in Seriously.

Try it online!


2

BBC BASIC, 239 236 232 214 bytes

0DEFPROCM(A,B,C)C=C-32:FORU=0TO18*A-1:FORV=0TO20*B-1:Y=U DIVA:X=V DIVB:V.32-C*FNC((X<10)*-X-(X>9)*(19-X),Y):N.:P.:N.:E.
1DEFFNC(X,Y)Z=Y*10+X:=((ASCMI."#Cb^2aC*[#1CF<;)C$;I9I$;EYLb&#",Z/6+1)-35)AND(2^(Z MOD6)))=0

Calling PROCM(1,1,35) produces the ghost made of # symbols. The arguments to PROCM are: horizontal scale, vertical scale, ASCII value of character.

This program will work both for Brandy Basic, and BASIC 2 on an original Model B.


2

Batch, 740 722 720 bytes

@echo off
setlocal enabledelayedexpansion
set h=%3
set w=
set s=
for /l %%a in (1,1,%2)do set w=%1!w!&set s= !s!
call:l ####################
call:l #                  #
call:l #       ####       #
call:l #     ########     #
call:l #    ##########    #
call:l #   ############   #
call:l #   ############   #
call:l #   ###  ##  ###   #
call:l #  ####  ##  ####  #
call:l #  ##############  #
call:l #  ##############  #
call:l #  ##  ##  ##  ##  #
call:l #  # ##  ##  ## #  #
call:l #  ##############  #
call:l #  ## ###  ### ##  #
call:l #  #   ##  ##   #  #
call:l #                  #
call:l ####################
exit/b
:l
set l=%*
set l=!l: =%s%!
for /l %%a in (1,1,%h%)do echo !l:#=%w%!

Edit: Saved 18 20 bytes by removing unnecessary spaces.


2

Stax, 45 bytes

àÄÅ╣>u°↨2ö|dτÅbn╦─▀:ΣFúÇz?⌂É\!n▄§V0Ncó╤½8|δò_

Run and debug it

Explanation:

"<long string>"!E' x+:BA/s|*mn|*:m Full program, implicit input.
"<long string>"!E                  Push 1531747987795407832964332490922049710271411270772589567
                 ' x+              Push a space plus the given character
                     :B            Interpret the number in binary, replacing 0 with ' ' and 1 with the given char
                       A/          Group into pieces of length 10.
                                   Gives the first half of each line.
                         s|*       Repeat each line <vertical scale factor> times
                            m      For each line:
                             n|*     Repeat each character <horizontal scale factor> times
                                :m   Mirror
                                     Implicit output with newline

The third one shows with some colours on my screen. Very nice :-)
Luis Mendo

1

JavaScript (ES6), 167 bytes

(s,w,h)=>[...`NJ56:*

\fLJJSlJ[s5NJ`].map(c=>`${t=(c.charCodeAt()^565).toString(2)}${[...t].reverse().join``}
`.replace(/./g,b=>` ${s}`[b].repeat(w)).repeat(h)).join``

Based on @Dennis's answer. I guess you could shave off another byte by using a literal FF instead of \f, but I doubt I can paste one in here. When trying this out you may also want to use \u01CA instead of the NJ character.

Sadly prepending a space to the character argument costs a whole 6 bytes.


1

Python 2, 838 828 618 bytes

Saved 210 bytes by using a string instead of an array, thanks to Dennis for that suggestion, I know I can make even better, but for now its a good improvement.

This is the best I can do, I'm not very good with graphics in command line.

I took the small ghost as base.

I'm using the ascii 219 by default, because with that char, the ghost looks pretty awesome!!!

Golfed

def g(c,s,w,h,l=""):
 x="c-20,c-1,s-18,c-1,c-1,s-7,c-4,s-7,c-1,c-1,s-5,c-8,s-5,c-1,c-1,s-4,c-10,s-4,c-1,c-1,s-3,c-12,s-3,c-1,c-1,s-3,c-12,s-3,c-1,c-1,s-3,c-3,s-2,c-2,s-2,c-3,s-3,c-1,c-1,s-2,c-4,s-2,c-2,s-2,c-4,s-2,c-1,c-1,s-2,c-14,s-2,c-1,c-1,s-2,c-14,s-2,c-1,c-1,s-2,c-2,s-2,c-2,s-2,c-2,s-2,c-2,s-2,c-1,c-1,s-2,c-1,s-1,c-2,s-2,c-2,s-2,c-2,s-1,c-1,s-2,c-1,c-1,s-2,c-14,s-2,c-1,c-1,s-2,c-2,s-1,c-3,s-2,c-3,s-1,c-2,s-2,c-1,c-1,s-2,c-1,s-3,c-2,s-2,c-2,s-3,c-1,s-2,c-1,c-1,s-18,c-1,c-20"
 for r in x.split(","):
  d=r.split("-");l+=d[0].replace("s",s).replace("c",c)*int(d[1])*w
  if len(l)==20*w:print(l+"\n")*h,;l=""

Try it on repl.it

Ungolfed

def pacmanGhost(char = "█", sep = " ", width = 1, height = 1):
    coords = [[[char, 20]], [[char, 1], [sep, 18], [char, 1]],[[char, 1], [sep, 7], [char, 4], [sep, 7], [char, 1]], [[char, 1], [sep, 5], [char, 8], [sep, 5],
         [char, 1]], [[char, 1], [sep, 4], [char, 10], [sep, 4], [char, 1]], [[char, 1], [sep, 3], [char, 12], [sep, 3], [char, 1]], [[char, 1], [sep, 3],
         [char, 12], [sep, 3], [char, 1]], [[char, 1], [sep, 3], [char, 3], [sep, 2], [char, 2], [sep, 2], [char, 3], [sep, 3], [char, 1]], [[char, 1],
         [sep, 2], [char, 4], [sep, 2], [char, 2], [sep, 2], [char, 4], [sep, 2], [char, 1]], [[char, 1], [sep, 2], [char, 14], [sep, 2], [char, 1]],
         [[char, 1], [sep, 2], [char, 14], [sep, 2], [char, 1]], [[char, 1], [sep, 2], [char, 2], [sep, 2], [char, 2], [sep, 2], [char, 2], [sep, 2],
         [char, 2], [sep, 2], [char, 1]], [[char, 1], [sep, 2], [char, 1], [sep, 1], [char, 2], [sep, 2], [char, 2], [sep, 2], [char, 2], [sep, 1], [char, 1],
         [sep, 2], [char, 1]], [[char, 1], [sep, 2], [char, 14], [sep, 2], [char, 1]], [[char, 1], [sep, 2], [char, 2], [sep, 1], [char, 3], [sep, 2],
         [char, 3], [sep, 1], [char, 2], [sep, 2], [char, 1]], [[char, 1], [sep, 2], [char, 1], [sep, 3], [char, 2], [sep, 2], [char, 2], [sep, 3],
         [char, 1], [sep, 2], [char, 1]], [[char, 1], [sep, 18], [char, 1]], [[char, 20]]]
    for coord in coords:
        line = ""
        for element in coord:
            line = "{}{}".format(line, element[0] * element[1] * width)
        for i in range(height):
            print(line)
    return

Test

enter image description here


You would achieve a much better score if you simply saved the uncompressed, unscaled image in a string. Also, you are wasting bytes on default arguments and the return statement.
Dennis

There is no such thing as ASCII code 219.
mbomb007

1

Python 2, 244 bytes

p,w,h=raw_input().split()
for i in range(18): mystr=''.join([(p if i=='1'else' ')*int(w)for i in str(10+(i%17==0))+format(ord('\xff\x00\x03\x0f\x1f??9y\x7f\x7ffY\x7fnF\x00\xff'[i]),'08b')]);print'\n'.join([mystr+mystr[::-1]for j in[1]*int(h)])

1

Python 2, 169 bytes

def a(s,x,y):
    z=[]
    for c in u'\u01df #/?\x1f\x1f\x19Y__Fy_Nf \u01df':
        b="".join((s if d=="1"else" ")*x for d in bin(ord(c)^544)[2:]);z+=[b+b[::-1]]*y
    print"\n".join(z)

Try it online!

Explanation:

u'\u01df #/?\x1f\x1f\x19Y__Fy_Nf \u01df'

As in Dennis's answer, each character in this string represents the binary representation of one line of the left half of the "image", XOR 544.

for c in <unicode string>:

For each character in the string, do the following:

    bin(ord(c)^544)

Transform the character into its integer representation, then perform a binary XOR with 544. Then transform this integer into a character string of its binary representation, like '0xb1111111111'.

    for d in <string>[2:]

For each character in the sting, starting at position 2 (which skips the 0b at the beginning), do the following:

    (s if d=="1"else" ")*x

If the character == "1", replace it with the supplied character, otherwise replace it with a space. Then copy this character x times. (x=0 will result in an empty string.)

    b="".join(<previously generated list of strings>)

Concatenate all strings into one long string, separated by an empty string "".

    z+=[b+b[::-1]]*y

make a string of b + the reverse of b, then create an array containing y instances of this string (y=0 will produce an empty list []), then append this list to the list z.

print"\n".join(z)

Finally, print to screen each of the produced strings, separated by line breaks.

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.