17
\$\begingroup\$

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

Console comand dotnet ef

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
\$\endgroup\$
1
  • \$\begingroup\$ is it allowed to print the eye 1 more space to the left? hehe cuz sometimes things dont work out \$\endgroup\$
    – DialFrost
    Jan 21 at 23:38

14 Answers 14

7
\$\begingroup\$

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!

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

Python 3, 129 bytes

lambda s:(s=='dotnet ef')*b'V`"D1PffayWPqfwgqUqqgc3uPvfwgU5P'.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
\$\endgroup\$
1
  • \$\begingroup\$ wow what is this my guy using bytes and hex to golf +1 \$\endgroup\$
    – DialFrost
    Jan 23 at 0:31
4
\$\begingroup\$

JavaScript (Node.js), 152 bytes

Contains unprintable RS characters.

s=>Buffer(s=="dotnet ef"?'#:u"J`P 9&vvn139(v)&o(! 4e&((o sU*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
|___||_|7/3000/00`.replace(/\d/g,n=>''.padEnd(n)||'\\'):''

Try it online!

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

Charcoal, 79 bytes

¿⁼Sdotnet ef”{¶⊟u↗9≧fXj⪪⊙O|↔d<⭆)⟧ΦÞ‴ζLP≧≦⁸1?_U~l7(I℅gºqu⪫ÀF◨Y∧π⦄◧μ×⎚⁶↓sαbGAaF

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).

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

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
\$\endgroup\$
4
  • \$\begingroup\$ amazing that you only save one byte off of literal "dotnet ef" via dictionary compression, or at least it seems like \$\endgroup\$ Jan 22 at 1:15
  • 3
    \$\begingroup\$ 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). \$\endgroup\$ Jan 22 at 1:27
  • 3
    \$\begingroup\$ ...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). \$\endgroup\$ Jan 22 at 1:37
  • 3
    \$\begingroup\$ 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). \$\endgroup\$ Jan 22 at 1:48
3
\$\begingroup\$

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.

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

Python 3, 156 bytes

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

Try it online!

Credits to @AnttiP

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

[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.
\$\endgroup\$
4
  • 1
    \$\begingroup\$ -4 by using char*S="\\\\\r"; instead of #define S "\\\\\r" and getting rid of the braces in the if. \$\endgroup\$
    – Makonede
    Jan 28 at 2:46
  • \$\begingroup\$ @Makonede : Well done ! I update the answer with your suggestions. \$\endgroup\$ Jan 28 at 8:09
  • \$\begingroup\$ @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. \$\endgroup\$ Jan 31 at 8:49
  • \$\begingroup\$ 201 bytes \$\endgroup\$
    – ceilingcat
    Feb 1 at 10:05
3
\$\begingroup\$

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!

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

Canvas, 75 bytes

dotnet ef≡?“cL⤢43¶h\^»)√@h┘S┼N(fV/3XVk#6K}⁰⤢KE @@sMo↷.(RqgaF╶u┬∑z7F│┘@&k]⁰‟

Try it here!

just canvas's string compression.

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

Vyxal O, 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.
\$\endgroup\$
1
\$\begingroup\$

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;
    }
}
\$\endgroup\$
3
  • \$\begingroup\$ Suggest printf(L" _|\\/-=\n.)"+i/8-6) instead of putchar(" _|\\/-=\n.)"[i/8-6]) \$\endgroup\$
    – ceilingcat
    Feb 14 at 6:35
  • \$\begingroup\$ @ceilingcat is assuming little endianness allowed? \$\endgroup\$
    – veqtrus
    Feb 14 at 12:58
  • \$\begingroup\$ You may make a note about it. \$\endgroup\$
    – ceilingcat
    Feb 14 at 16:13
1
\$\begingroup\$

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.

Kevin Cruijssen, why so bad?

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

Python3, 177 bytes

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

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.