Replicate "dotnet ef" unicorn

.Net Technology is an incredible framework with marvellous functionalities, and among all of them, the most important one obviously stands out:

Yep, your simple task is create a program that when it takes at input:

dotnet ef


It prints the following ascii art by output:

             /\__
---==/    \\
___  ___   |.    \|\
| __|| __|  |  )   \\\
| _| | _|   \_/ |  //|\\
|___||_|       /   \\\/\\


And you have to do it in the lowest number of bytes of course.

Rules

• If the program doesn't receive dotnet ef by input it doesn't output anything
• The program with the fewest bytes wins so this is a code golf challenge
• is it allowed to print the eye 1 more space to the left? hehe cuz sometimes things dont work out Jan 21 at 23:38

Perl 5 + -p, 100 bytes

1/s/^dotnet ef$/oooo..oo.aJo..z..o8o..3.3.svo!.3.3.q.3.5.4.43oo)q!+./;s/./ord$&/ge;y;0-9;
_\\/|.=)-

Try it online!

Explanation

1/s/^dotnet ef$/... will exit with a division by zero unless the input is dotnet ef, then the data is packed into the 52-byte binary string. Since there were 10 distinct chars, it's possible to convert those original chars to digits 0-9, which were then packed (so 111111111111143 becomes chr(111) + chr(111) + chr(111) + chr(111) + chr(143)), This packed string is replaced into $_ (where the implicit input is stored) via s///ubstitution, then each char is s///ubstituted with its ordinal value and then transliterated (y///) back to the original chars.

Perl 5 + -pF/^(dotnet\x20ef)$/, 94 bytes Same as above, except abusing flags for the early exit. 1/$#F;$_='oooo..oo.aJo..z..o8o..3.3.svo!.3.3.q.3.5.4.43oo)q!+.';s/./ord$&/ge;y;0-9;
_\\/|.=)-

Try it online!

Python 3, 129 bytes

lambda s:(s=='dotnet ef')*b'V"D1PffayWPqfwgqUqqgc3uPvfwgU5P'.hex().translate('-/=\_|).\n '*9)


Try it online!

Explanation

We use bytes.hex() to convert the byte-string to a string of hexadecimal digits, which looks like this:

11111111111113566011111112224431111550166611666111791111575071667716671171181115550716717167111563171133755076667767111111131115553550


From here, we perform a str.translate(), to map the digits '0123456789' to '-/=\_|).\n '. These are the ten characters that make up the entire unicorn drawing.

Special care should be taken to ensure that the compressed string won't contain any values exceeding the ASCII range. The program below finds such strings:

from itertools import *
ART = '             /\\__\n       ---==/    \\\\\n ___  ___   |.    \\|\\\n| __|| __|  |  )   \\\\\\\n| _| | _|   \\_/ |  //|\\\\\n|___||_|       /   \\\\\\/\\\\\n'
L = '\n )-./=\_|'
for p in permutations(range(10)):
compressed = b''.fromhex(''.join('0123456789'[p[L.find(c)]] for c in ART))
if max(compressed) < 128:
trans = [None] * 10
for i in range(10):
trans[(p[i] + 48) % 10] = L[i]
print('translation:', repr(''.join(trans)))
print('compressed:', compressed.decode())
break

• wow what is this my guy using bytes and hex to golf +1 Jan 23 at 0:31

JavaScript (Node.js), 152 bytes

Contains unprintable RS characters.

s=>Buffer(s=="dotnet ef"?'#:u"JP 9&vvn139(v)&o(! 4e&((o sU*90v)o# 4R2':0).map(n=>o+=(c= |\\)-/=
_.)[n/10-3|0]+c[n%10],o='')&&o


Try it online!

JavaScript (ES8), 152 bytes

s=>s=='dotnet ef'?94/0__
7---==/400
1___2___3|.40|0
|1__||1__|2|2)3000
|1_|1|1_|30_/1|2//|00


Try it online!

Charcoal, 79 bytes

¿⁼Ｓdotnet ef”{¶⊟u↗9≧fXj⪪⊙Ｏ|↔d<⭆)⟧ΦÞ‴ζＬＰ≧≦⁸1？_Ｕ~l7(Ｉ℅gºqu⪫ÀF◨Ｙ∧π⦄◧μ×⎚⁶↓sαbＧＡaF


Try it online! Link is to verbose version of code. Explanation: Just Charcoal's default string compression, conditional on the input line (which needs a trailing newline to prevent Charcoal's autosplit on spaces).

Jelly, 82 bytes

⁼“¤fÞ#³ıḄ×»“¡mƁµɼʋ"§ĿỵSėṭƊḲṂ§ÇḋỵL}Ṅnʠṫ2#ap{}fƓ*ƑṇḢ§ƓṾ®[~]sṘÐ/wỊḊ.÷⁹ß’ḣṃ“ \_¶-=|.)/


A full program accepting a string that prints the art when that string is "dotnet ef".

Try it online!

How?

⁼“...»“...’ḣṃ“... - Main Link: string, S
“...»            - dictionary compression of "dotnet ef"
⁼                 - S equals that? (1 if so; 0 otherwise)
“...’       - base 250 integer (say, n) = 1111111111111023341111111555660111122413331133311178111127247133771337117119111222471371713711123017110072247333773711111110111222022
ḣ      - head that (implicitly wrapped in a list) by (1 or 0)
-> [n] or []
“... - the art's characters (¶ is a newline & no closing quote needed)
ṃ     - decompress the integers (in either [n] or []) using the
characters as the digits [1,...,9,0] (as there are ten of them)
- implicit, smashing print

• amazing that you only save one byte off of literal "dotnet ef" via dictionary compression, or at least it seems like Jan 22 at 1:15
• Yeah, I know! The compression is not amazing unless it's all composed of words (including title-cased versions) that are in Jelly's dictionary strung together (with or without spaces). Surprisingly the words used for this are actually do, net, and ef - dot is not in there. In fact, fe tentod is a byte shorter since fe, ten, and tod are all in Jelly's dictionary (but it would take a byte to reverse the input to check against anyway). Jan 22 at 1:27
• ...actually dot is in Jelly's dictionary, but the Optimal String Compressor isn't using it for this string (at least I don't think it is). Jan 22 at 1:37
• Ahh, I see why now - DOT is in there but not dot or Dot (there is a flag used in the compression that swaps the case of the first letter of the word, so DOT is of no use). Jan 22 at 1:48

05AB1E, 85 bytes

’¥¥‡Ò ef’Qi•{Ã∍ûç=®¤[ˆ ôÆ-˜´≠pw:‡©[§∊è$#±8¡žR=α»ιœëā7¬ÄÒU₁ýmOÜÉt×›ʒ•"_ |\/ -=)."ÅвJëõ  Try it online. A compressed string .•1piN∍Ç• instead of dictionary string ’¥¥‡Ò ef’ would be the same byte-count. Explanation: ’¥¥‡Ò ef’ # Push the dictionary string "dotnet ef" Qi # If the (implicit) input is equal to this: •{Ã∍...×›ʒ• # Push compressed integer 1111111111111430051111111666774111133510001100011129111132352100221002112118111333521021210211130412114423352000220211111114111333433 "_ |\/\n-=)." # Push this string Åв # Convert the large integer to base-"_ |\/\n-=)." # which means base-length, and then indexing it into the string J # Join this list of characters together ë # Else: õ # Push an empty string instead # (after which the top is output implicitly as result)  The compressed ASCII-art is generated using the generator program in this 05AB1E tip. See this 05AB1E tip of mine (sections How to use the dictionary?, How to compress strings not part of the dictionary?, and How to compress large integers?) to understand why ’¥¥‡Ò ef’ is "dotnet ef"; .•1piN∍Ç• is "dotnet ef" as well; and •{Ã∍ûç=®¤[ˆ ôÆ-˜´≠pw:‡©[§∊è$#±8¡žR=α»ιœëā7¬ÄÒU₁ýmOÜÉt×›ʒ• is 1111111111111430051111111666774111133510001100011129111132352100221002112118111333521021210211130412114423352000220211111114111333433.

• Fails on empty input. Jan 28 at 3:08
• @Makonede It fails on no input, since it'll implicitly use the pushed string twice for the equals-check, but with an explicit empty input, it works as intended. Jan 28 at 7:26

Python 3, 156 bytes

if"dotnet ef"==input():print(r"""		 /\__
---==/    \\
___	___	|.	\|\
| __|| __|  |  )	 \\\
| _| | _|	\_/ |  //|\\
|___||_|	   /	 \\\/\\""".expandtabs(6))


Try it online!

Credits to @AnttiP

• "A bit hard to golf printing strings" welcome to the kolmogorov complexity tag! Jan 21 at 14:01
• i will golf this further tmr but i have to sleep gn guys! (i will use " "*x) e.g. Jan 21 at 14:01
• Using raw strings r"" you can save some bytes from backslashes: Try it online! Jan 21 at 14:08
• You can also swap the order of the comparsion and then remove a space: if"dotnet ef"==input(): Jan 21 at 14:13
• Feel free to copy my solution since your answer has more upvotes, so we can have one entry for python 3 Jan 22 at 12:36

[C (gcc)], ̶2̶1̶7̶ 212 202 bytes

#define S"\\\\\r"
main(c,v)int**v;{strcmp(v[1],"dotnet ef")||printf("%14c\\__\r%8c--==/%7s ___  ___   |.    \\|\\\r| __|| __|  |  )   \\"S"| _| | _|   \\_/ |  //|"S"|___||_|%8c   \\\\\\/"S,47,45,S,47);}


Try it online!

Previous versions :

char*S="\\\\\r";main(c,v)char**v;{if(!strcmp(v[1],"dotnet ef"))printf("%14s\\__\r%8s--==/%7s ___  ___   |.    \\|\\\r| __|| __|  |  )   \\%s| _| | _|   \\_/ |  //|%s|___||_|%8s   \\\\\\/%s","/","-",S,S,S,"/",S);}


Contributions :

Makonede :

• remove the brace for the if statement
• change the define by a global variable

celingcat :

• replace the if by the OR test
• put the define S inside the string of the printf
• change some characters by theirs ascii values.
• -4 by using char*S="\\\\\r"; instead of #define S "\\\\\r" and getting rid of the braces in the if. Jan 28 at 2:46
• @Makonede : Well done ! I update the answer with your suggestions. Jan 28 at 8:09
• @ceilingcat : Well done ! It is very clever to put the define S inside the string. I did'nt know we could do this. Replace the if by the OR, it is smart. Jan 31 at 8:49
• 201 bytes Feb 1 at 10:05

Julia, 177 163 bytes

f(i)=i=="dotnet ef"&&print(" "^13,"/\\__
"," "^7,raw"---==/    \\
___  ___   |.    \|\
| __|| __|  |  )   \\\
| _| | _|   \_/ |  //|\
|___||_|       /   \\/\\
")


Try it online!

Thanks to MarcMush we can bring it down to 163 bytes by using raw which allows us to use \ without escaping!

• 163 bytes you can use literal line breaks instead of \n, also, the raw"" macro allows to not have to escape \  Feb 15 at 10:40
• @MarcMush cool idea! Feb 15 at 11:40

VyxalO, 82 bytes

«ƛ4-ʀWṪ«=[»|ȮW¼∩r¶‛v←^ǔṠlȯ¦U4;o→₄v₂V⊍cbε×√ẋÞrAĖRṫ⇧ż÷₇Ṗ⌈¨YΠ1ʁ⋎Ẋ8…ṡ@»_ |\/\n-=).τ₴


Try it Online!

Explanation

A port of Kevin Cruijssen's O5AB1E answer

<O flag> (disable implicit output, so anything other than 'dotnet ef' doesnt print anything)
«ƛ4-ʀWṪ«=[                                - If the input equals 'dotnet ef':
»|ȮW¼...8…ṡ@»                   - Push a big compressed integer
_ |\/\n-=).τ₴    - Replace the digits with symbols, and print.


Canvas, 75 bytes

dotnet ef≡？“ｃL⤢43¶h\＾»）√＠ｈ┘S┼N（fＶ／3ＸＶｋ＃６Ｋ}⁰⤢ＫＥ @＠sMｏ↷.(ＲｑｇａＦ╶u┬∑ｚ７F│┘@&k］⁰‟


Try it here!

just canvas's string compression.

C (gcc), 175 169 bytes

-6 bytes by reusing the input variable

i;f(char*p){if(!strcmp(p,"dotnet ef"))for(p="76QI:i7[bQ4Ji1;2;3Aq4IAIiA1:B1:A2A2y3KiA19A1A19A3I9Q1A2RAJiA;B9A7Q3KQJ";i=*p++;)while(i--&7)putchar(" _|\\/-=\n.)"[i/8-6]);}


Try it online!

I used RLE compression, where the lower 3 bits are the length and the high bits encode the character index. By shifting the index by 6 we get an encoding that doesn't require escaping in a string literal. I used this function for encoding:

void encode() {
char chars[] = " _|\\/-=\n.)";
int cur, prev = ' ', count = 0;
while ((cur = getchar()) != EOF) {
if (cur == prev && count < 7) {
count++;
} else {
putchar((strchr(chars, prev) - chars + 6) * 8 + count);
count = 1;
}
prev = cur;
}
}

• Suggest printf(L" _|\\/-=\n.)"+i/8-6) instead of putchar(" _|\\/-=\n.)"[i/8-6]) Feb 14 at 6:35
• @ceilingcat is assuming little endianness allowed? Feb 14 at 12:58
• You may make a note about it. Feb 14 at 16:13

05AB1E, 83 82 bytes

’¥¥‡Ò ef’Q•{Ã∍ûçαÖв₂þ₂ÕµŒHθǝ¤kªγVíαвÒf¾ΘMãwà5ÚX¿Q₆Sì=Ð§òqxheΘ+ãkÛž•"/ \_
-=|.)"Åв×


Try it online! Outputs as a list of characters. Link includes a footer to format the output.

if"dotnet ef"==input():print("             /\__\n       ---==/    \\\\\n ___  ___   |.    \|\ \n| __|| __|  |  )   \\\\\ \n| _| | _|   \_/ |  //|\\\n|___||_|       /   \\\/\\")