5
\$\begingroup\$

The official release of the Nintendo 64 in North America was on September 29, 1996.[1] I figured that this anniversary deserved an ASCII art challenge. There's one small twist though, you have to output a different ASCII art for each of three different inputs.

If the input is 1, output this ASCII art of an N64 Controller: (source)

                 | |
             _,.-'-'-.,_
      ______|           |______
   ,-'      |  NINTENDO |      `-.
 ,'   _                          `.
/   _| |_                     (^)   \
|  |_   _|                  (<) (>) |
\    |_|         (S)     (B)  (v)   /
|`.              ___       (A)    ,'|
|  `-.______   ,' _ `.   ______,-'  |
|      |    `. | (_) | ,'    |      |
|      |      \`.___,'/      |      |
|      |      |       |      |      |
|      /      |       |      \      |
\     /       |       |       \     /
 `._,'        \       /        `._,'
               \     /
                `._,'

If the input is 2, output this ASCII art of the N64 logo:(source)

                  .-"-.
               .-"     "-.
              /"-.     .-|
             /    "-.-"  |
            /      /     |
   .-"-.   /      /      |       .-"-.
.-"     "-/      /       |    .-"     "-.
|-.     .-"\    /        |   /"-.     .-|
|  '-.-"    \  /         | /'    "-.-"  |
|     \      \/   .-"-.  /'        |    |
|      \      \.-"     "-.         |    |
|       \      |-.     .-"\        |    |
|        \     |  "-.-"    '\      |    |
|         \    |    |        '\    |    |
|    |\    \   |    |          '\  |    |
|    | \    \  |    |            '\|    |
|    |  \    \ |    |    :\.            |
|    |   \    \|    |    |  \.          |
|    |    \         |    |    \.        |
'-.  |  .-"\        |    |    '.\.    .-'
   "-|-"    \       |    |      "-\.-"
             \      |    |
              \     |    |
               "-.  |  .-'
                  "-|-"

Finally, if the input is 3, outout this ASCII art of a console and TV: (source)

              o
     o       /
      \     /
       \   /
        \ /
   ______________
  |.------------.|
  ||            ||
  ||            ||
  ||            ||
  ||            ||
  ||____________||_
  |OO ....... OO | `-.
  '------_.-._---' _.'  
   _____||   ||___/_
  /  _.-|| N ||-._  \      .-._
 / -'_.---------._'- \    ,'___i-i___
/_.-'_  NINTENDO _'-._\  ' /_+  o :::\
|`-i /m\/m\|\|/=,/m\i-'| | || \ O / ||
|  |_\_/\_/___\_/'./|  | | \/  \ /  \/
`-'              '-.`-'  ,      V
                    `---' 

Rules:

  • Input may be either as a number or a string/char.
  • You may have any amount of leading or trailing spaces and trailing or leading newlines. (Output must be aligned correctly though)
  • Your submission may be either a full program or a function.
  • No retrieving the ASCII art from the internet.

This is , so smallest byte count wins.

\$\endgroup\$
  • 2
    \$\begingroup\$ @Emigna I realigned the cord and took the liberty of altering the controller to look better, as nobody has submitted any solutions yet. \$\endgroup\$ – DanTheMan Sep 30 '16 at 6:18
  • 11
    \$\begingroup\$ I'd suggest restricting this to just the N. The others are probably too intricate to do efficiently except with plain string compression which is rather boring. \$\endgroup\$ – Calvin's Hobbies Sep 30 '16 at 7:47
  • \$\begingroup\$ There's a ' or two in the N that I feel should be ". It's bothering me. \$\endgroup\$ – mbomb007 Sep 30 '16 at 14:12
6
\$\begingroup\$

Javascript ES6, 1175 bytes

Using a simple Run Length Encoding to encode just the spaces.

let F=
  
  z=>[(f=d=>d.replace(/\d+/g,e=>' '.repeat(e)))(`17|1|
13_,.-'-'-.,_
6______|11|______
3,-'6|2NINTENDO1|6\`-.
1,'3_26\`.
/3_|1|_21(^)3\\
|2|_3_|18(<)1(>)1|
\\4|_|9(S)5(B)2(v)3/
|\`.14___7(A)4,'|
|2\`-.______3,'1_1\`.3______,-'2|
|6|4\`.1|1(_)1|1,'4|6|
|6|6\\\`.___,'/6|6|
|6|6|7|6|6|
|6/6|7|6\\6|
\\5/7|7|7\\5/
1\`._,'8\\7/8\`._,'
15\\5/
16\`._,'`),f(`18.-"-.
15.-"5"-.
14/"-.5.-|
13/4"-.-"2|
12/6/5|
3.-"-.3/6/6|7.-"-.
.-"5"-/6/7|4.-"5"-.
|-.5.-"\\4/8|3/"-.5.-|
|2'-.-"4\\2/9|1/'4"-.-"2|
|5\\6\\/3.-"-.2/'8|4|
|6\\6\\.-"5"-.9|4|
|7\\6|-.5.-"\\8|4|
|8\\5|2"-.-"4'\\6|4|
|9\\4|4|8'\\4|4|
|4|\\4\\3|4|10'\\2|4|
|4|1\\4\\2|4|12'\\|4|
|4|2\\4\\1|4|4:\\.12|
|4|3\\4\\|4|4|2\\.10|
|4|4\\9|4|4\\.8|
'-.2|2.-"\\8|4|4'.\\.4.-'
3"-|-"4\\7|4|6"-\\.-"
13\\6|4|
14\\5|4|
15"-.2|2.-'
18"-|-"`),f(`14o
5o7/
6\\5/
7\\3/
8\\1/
3______________
2|.------------.|
2||12||
2||12||
2||12||
2||12||
2||____________||_
2|OO1.......1OO1|1\`-.
2'------_.-._---'1_.'2
3_____||3||___/_
2/2_.-||1N1||-._2\\6.-._
1/1-'_.---------._'-1\\4,'___i-i___
/_.-'_2NINTENDO1_'-._\\2'1/_+2o1:::\\
|\`-i1/m\\/m\\|\\|/=,/m\\i-'|1|1||1\\1O1/1||
|2|_\\_/\\_/___\\_/'./|2|1|1\\/2\\1/2\\/
\`-'14'-.\`-'2,6V
20\`---'`)][z-1]

G=_=>h.innerHTML = F(a.value)

h.innerHTML = F(1)
<input id=a onchange="G()" type="number" value="1"></input>
<pre id=h>

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

JavaScript (ES6), 907 904 903 bytes

Implements a compression by successive substitutions of the most frequent sub-strings.

This can be compressed significantly more (down to about 850 bytes) by assuming Windows-125x encoding and using replacement characters in the range 0xA0 - 0xFF. But the result is just ugly. :-)

let f =

n=>[...Array(78)].map((_,i)=>s=~":<=>ABNOSV\\^_`imov|".indexOf((c=String.fromCharCode(125-i)))?s:s.split(c).join(['\\','NINTENDO',`
`][c]||"9|XsD'RE405398T08kU8K0\"-G/'0|W7/;_E/C62G5|557970..-\"6_ /|52F8@04D\"`.-','??7 25\";7|3 3|4 .-662|---. |4|43__4433  ".substr(k+=2,2)),s="c99JE_,zP;,_27fX39fe,PH3197`;2 MG_cwQ2/G_|9_cE(^)G0@F_G_Xw(<) (>)9208_X (S)E(B)3(v)n@Q57ZK(A)4M|@3`;fGM _ QGf,PF@H4Q9 (_)9 M8H@HaQZM/HH@HHbHH@jHbaH20gbbqg2 Q_M50K/5Q_MJqgJ5Q_M~c3DIJKyIJjIED|Jg4I[FJ4/j49eDInjHKDI2yp/jb4yI@;ERT/dnIED|@3';[x3/59Y'4I[F@E0a/GDI3/'dUaayI59UqH;ER0dU5T93I[4lHU5 0885l8rt3uwlFr tF854l|r3tu4:0.5rGt|8830.5F@8x5ux.d2';F3R0d84'.0.4zep|[xb87p0RJE0H8J7TuJKIF3zJwp|[~57o2EoK/2ag2qnJ0YeCCfW.LL?-;k{{{{|CCC||_WOO ]]]. OO9 `;23'L?_.h?P _.'eC_||3}Z/_23/3_D|| N}h307.h2Y P_.LLh'- TMZi-iZ2/_z_31 _'h03'Y_+3o :::0@`-iYm0/m0|0|/=,/m0iP|9} 0 OY}@F_0_/0_/Z0_/'./|F9 0/30Y30/2`P57';`P3,7VJ54`?P",k=-2)&&s.split`~`[n-1]

console.log(f(1));
console.log(f(2));
console.log(f(3));

Making-Of

The above JS was generated with the following PHP script, where "n64.txt" is basically the concatenation of the 3 original pictures separated with ~ characters.

<?php
  $str = file_get_contents("n64.txt");

  // ignore line-breaks between 2 pictures
  $str = str_replace("~\n", "~", $str);

  // replace backslashes with 0's
  $str = str_replace("\\", "0", $str);

  // replace 'NINTENDO' with 1's to have more uppercase letters
  // available as replacement characters
  $str = str_replace("NINTENDO", "1", $str);

  // replace line-breaks with 2's
  $str = str_replace("\n", "2", $str);

  // $skipped is the list of characters that can't be used as replacement
  // characters (backslash + anything existing in the original string)
  $skipped = '';

  // $dic is the replacement dictionary
  $dic = '';

  for($i = 0; $i < 75; $i++) {
    // $r = current replacement character
    $r = chr(51 + $i);

    // can we use it?
    if($r == "\\" || strpos($str, $r) !== false) {
      $skipped .= $r;
      continue;
    }

    // look for the most frequent 2-character sub-string
    $count = array();

    for($n = 0; $n < strlen($str) - 1; $n++) {
      $s = substr($str, $n, 2);
      $count[$s] = isset($count[$s]) ? $count[$s] : 0;
      $count[$s]++;
    }

    asort($count);
    $keys = array_keys($count);
    $s = array_pop($keys);

    // add it to the dictionary
    $dic = $s.$dic;

    // replace all occurences with the replacement character
    $str = str_replace($s, $r, $str);

    printf("'%s' => '%s' %d\n", $s, $r, strlen($str));
  }

  // generate JS
  file_put_contents(
    "n64.js",
    sprintf(
      "n=>[...Array(78)].map((_,i)=>".
      "s=~\"%s\".indexOf((c=String.fromCharCode(125-i)))?s:".
      "s.split(c).join(['\\\\','NINTENDO',`\n`][c]||\"%s\".substr(k+=2,2)),".
      "s=\"%s\",k=-2)".
      "&&s.split`~`[n-1]",
      str_replace("\\", "\\\\", $skipped),
      str_replace('"', '\"', $dic),
      $str
    )
  );
?>
\$\endgroup\$
2
\$\begingroup\$

Racket, 1059 bytes

(require file/gunzip net/base64)(display((λ(o)(gunzip-through-ports(open-input-bytes(base64-decode(list-ref'(#"H4sICMov7lcCAzEAdZExDsMgDEV3TuENkAhcoKrUqh2ypEM7osIpOvnwtTEkgaaOFIvvZ8efAAyBgKoTkvOTpse7VAupBO6bROK6m3QbBMu8vO7L7QGVzZNX4Lie4G9krwITtMgxZd6W3lEhCNFt0piTBXO25CXKfhtjnlbylbL58CEozL4fQG4afym808hfJAvitUjkozSKVKwXqvpnM5RNokXEd7uJniI3mcc6HTp1pBCOjisVDqnYqLiHRqpiQdHKyWno1K1Lqmq47bX351cy/AXpeU7EYwIAAA=="#"H4sICNkv7lcCAzIAbdIxDgQhCAXQfk5BbKzUfs/CUTj8qiACMo2J/xl/cADi11tp/Xs39/pGY24JIR8NObCO+mjYZUf70pgAuUq3g1fMbEPSSgUt3NIVnhu1yVE0cMpRXX/ugpziuJ3ZaY8jlZpikMtDY+1ECiUtNvtjLpmSnaNYKwkP9ZKtk3BolMt6eeiVP+z2wJVCyZa11kjAMECe75V1DZCyAe6SnW1v9dvvQfruEEdV2no3/z/7OUOSpRE/POm9Tzpr/AEE2h7HhgMAAA=="#"H4sICOIv7lcCAzMApVG7DsIwDNzzFd48UNt7JTYYWNoFMUVy1gyIH/DHc0l4tBIb1yjxXf1MiLZ4pHG8qA1Kecc6/RCwbvsOUEJlA40mxbZY/Clt64E1bV1JBwhmUBGFzKMFV1HHyeTKRJ+me/KezloSg6wCcYGIiPf41MITfgv7dzR1luEwMTJUqW16gwcjcrks1/NyWgle6nBjMj+0C57nOacoUsnuGSty2HGCUYUDnaN+phXVMCz6C89uWEiOndWahi9bfwBslgom2wE1uzYNekv0A6XfyBPSqZrcBwIAAA==")(-(read)1))))o)(get-output-string o))(open-output-string)))

Just gzipped data encoded as base64.

Ungolfed

(require file/gunzip net/base64)
(display ((λ (o)
            (gunzip-through-ports
             (open-input-bytes
              (base64-decode
               (list-ref
                '(#"H4sICMov7lcCAzEAdZExDsMgDEV3TuENkAhcoKrUqh2ypEM7osIpOvnwtTEkgaaOFIvvZ8efAAyBgKoTkvOTpse7VAupBO6bROK6m3QbBMu8vO7L7QGVzZNX4Lie4G9krwITtMgxZd6W3lEhCNFt0piTBXO25CXKfhtjnlbylbL58CEozL4fQG4afym808hfJAvitUjkozSKVKwXqvpnM5RNokXEd7uJniI3mcc6HTp1pBCOjisVDqnYqLiHRqpiQdHKyWno1K1Lqmq47bX351cy/AXpeU7EYwIAAA=="
                  #"H4sICNkv7lcCAzIAbdIxDgQhCAXQfk5BbKzUfs/CUTj8qiACMo2J/xl/cADi11tp/Xs39/pGY24JIR8NObCO+mjYZUf70pgAuUq3g1fMbEPSSgUt3NIVnhu1yVE0cMpRXX/ugpziuJ3ZaY8jlZpikMtDY+1ECiUtNvtjLpmSnaNYKwkP9ZKtk3BolMt6eeiVP+z2wJVCyZa11kjAMECe75V1DZCyAe6SnW1v9dvvQfruEEdV2no3/z/7OUOSpRE/POm9Tzpr/AEE2h7HhgMAAA=="
                  #"H4sICOIv7lcCAzMApVG7DsIwDNzzFd48UNt7JTYYWNoFMUVy1gyIH/DHc0l4tBIb1yjxXf1MiLZ4pHG8qA1Kecc6/RCwbvsOUEJlA40mxbZY/Clt64E1bV1JBwhmUBGFzKMFV1HHyeTKRJ+me/KezloSg6wCcYGIiPf41MITfgv7dzR1luEwMTJUqW16gwcjcrks1/NyWgle6nBjMj+0C57nOacoUsnuGSty2HGCUYUDnaN+phXVMCz6C89uWEiOndWahi9bfwBslgom2wE1uzYNekv0A6XfyBPSqZrcBwIAAA==")
                (- (read) 1))))
             o)
            (get-output-string o))
          (open-output-string)))
\$\endgroup\$
1
\$\begingroup\$

PHP, 881 Bytes

<?=json_decode(gzinflate(base64_decode("rVY9rxQxDPwr0Ta5E0lWQHcCJBAUNHcFiCoi217xeBIFDea/M3acr80eFXlPG6094x07TnK/l5fLZTH7QYbiz/hjsCUXvMVfcKn5kgzqqdmkEOdtiWiun69fP10/3ozCNx8E5RiSJg11bAKLK6Mg7Bh5+n7GM0aGksmoQVfBvTmb07tzzi/GrLjhTl/Oef6A+fRLYq4ScwtjIORYOO+F4yzpx5FYLoJYkZpws0kKUoBaGE4R8ylBVq5GKdEE5BQ3ju6sFOSf0JIWPQTuYrRvdFB9KdA91lS/LCbEOWtGV0fO/qm39lF2Q0iLW14d9aoJPi7aSrMjRz3041uwK3Lu96yZIRJmApScdC7+rGb213o1ub2+PTrDpwyoCo5LLlkrLR3mBKv1JQ5TGgGMuNo5y6y0LB721NrlpYwqcWinShmEm4eE1mlTXsf4QqBOMxKsYWaCMqg+OsIOTlrROOGVscebRtjjhTHhG6HhL6hWzxvwldDwEiU8wrc912vqCAK3XG46LrdoD8rAka99jXJT10U7Qu5hWfZ5I02LY478j9zaQtSLmRGsDSfE6+mEeK6U54LuzpijY0ds40EEUzWkYWQjBd+NoFnQ0A/0H629Aryp+XYzIQ9z41u2XLA4AGSkgIsJM66kgE3c5yMfkrhx1XC868GA5woPmG0lOY6AgPE2teRDsl5RziLY3d+1RgiL5UvdrwBAEQVYizDpBa/P5XLRG3zzd1if+OzBg/h/fevk5e4t8Q8U2X03lkBlC6ASEQnIg7/LM1p5JflFoyeZrGU+1pi2eWuGAVlic/n123HL8S3PlVz+/AU=")),1)[$argv[1]];

Making of fill the lines with the graphics use the heredoc syntax in PHP

$a[1]=<<<A

A;
$a[2]=<<<B

B;
$a[3]=<<<C

C;
echo base64_encode(gzdeflate(json_encode($a)));
\$\endgroup\$
0
\$\begingroup\$

PHP, 2113 2112 bytes

If nobody else is going to compete I'll just grab the trophy and leave..

<?php function a($n){if($n<2){?>
                 | |
             _,.-'-'-.,_
      ______|           |______
   ,-'      |  NINTENDO |      `-.
 ,'   _                          `.
/   _| |_                     (^)   \
|  |_   _|                  (<) (>) |
\    |_|         (S)     (B)  (v)   /
|`.              ___       (A)    ,'|
|  `-.______   ,' _ `.   ______,-'  |
|      |    `. | (_) | ,'    |      |
|      |      \`.___,'/      |      |
|      |      |       |      |      |
|      /      |       |      \      |
\     /       |       |       \     /
 `._,'        \       /        `._,'
               \     /
                `._,'<?php }else if($n==2){?>
                  .-"-.
               .-"     "-.
              /"-.     .-|
             /    "-.-"  |
            /      /     |
   .-"-.   /      /      |       .-"-.
.-"     "-/      /       |    .-"     "-.
|-.     .-"\    /        |   /"-.     .-|
|  '-.-"    \  /         | /'    "-.-"  |
|     \      \/   .-"-.  /'        |    |
|      \      \.-"     "-.         |    |
|       \      |-.     .-"\        |    |
|        \     |  "-.-"    '\      |    |
|         \    |    |        '\    |    |
|    |\    \   |    |          '\  |    |
|    | \    \  |    |            '\|    |
|    |  \    \ |    |    :\.            |
|    |   \    \|    |    |  \.          |
|    |    \         |    |    \.        |
'-.  |  .-"\        |    |    '.\.    .-'
   "-|-"    \       |    |      "-\.-"
             \      |    |
              \     |    |
               "-.  |  .-'
                  "-|-"<?php }else{?>
              o
     o       /
      \     /
       \   /
        \ /
   ______________
  |.------------.|
  ||            ||
  ||            ||
  ||            ||
  ||            ||
  ||____________||_
  |OO ....... OO | `-.
  '------_.-._---' _.'
   _____||   ||___/_
  /  _.-|| N ||-._  \      .-._
 / -'_.---------._'- \    ,'___i-i___
/_.-'_  NINTENDO _'-._\  ' /_+  o :::\
|`-i /m\/m\|\|/=,/m\i-'| | || \ O / ||
|  |_\_/\_/___\_/'./|  | | \/  \ /  \/
`-'              '-.`-'  ,      V
                    `---' <?php }}?>

Thanks to @KevinCruijssen for a byte!

\$\endgroup\$
  • 1
    \$\begingroup\$ You can golf $n==1 to $n<2 for -1 byte. ;p \$\endgroup\$ – Kevin Cruijssen Sep 30 '16 at 9:41
  • 2
    \$\begingroup\$ @KevinCruijssen Sweet, only a thousand and some to go! \$\endgroup\$ – BlackCap Sep 30 '16 at 9:46
  • \$\begingroup\$ <?php should be <? surely? And you can nudge right up to the opening php tag, so a whole 16 bytes! \$\endgroup\$ – PaulSkinner Sep 30 '16 at 10:58
  • \$\begingroup\$ This doesn't look like a serious entry to me. \$\endgroup\$ – mbomb007 Sep 30 '16 at 14:10
  • 4
    \$\begingroup\$ @BasicallyAlanTuring First of all, loopholes are disallowed by default unless explictly allowed by the OP. Secondly, answers that don't make a serious golfing attempt are to be deleted. This answer doesn't even attempt to compact the strings. \$\endgroup\$ – mbomb007 Sep 30 '16 at 17:14

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.