Try to make a cube!

16

0

Based on this: Make me a square!

You need to output this:

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

Where "#" is replaced with the input.

If you input "A", you should get

  AAAA
 A A A
AAA  A
A A A
AAAA

If you input "&", you should get

  &&&&
 & & &
&&&  &
& & &
&&&&

Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

/* Configuration */

var QUESTION_ID = 121651; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });  
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];
  
  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });
    
    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });
    
  });
  
  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;
    
    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();
    
    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>

user69538

Posted 2017-05-19T17:07:02.143

Reputation:

5Well, this is somewhat similar, although at least it's not a 3-byte answer in Charcoal this time... – Neil – 2017-05-19T17:08:46.910

@Neil it will probably be 4 bytes. Formula: b=d+1 where b is the number of bytes and d is the number of dimensions used. – programmer5000 – 2017-05-19T17:11:00.853

1Can the last two lines have leading spaces and can the result have leading newlines? – dzaima – 2017-05-19T17:15:28.743

@dzaima yes, they can. – None – 2017-05-19T17:16:12.060

3B³S‖O↗ it may very well be close to a 10 byte answer in charcoal though... I just don't know the language well enough to do it, there really needs to be a page like this but for charcoal. – Magic Octopus Urn – 2017-05-19T17:39:14.720

Wishing that I understood charcoal inputs – Magic Octopus Urn – 2017-05-19T18:07:47.807

Leading space in each row aligned? That would give the pattern shifted 1 unit right – Luis Mendo – 2017-05-19T18:10:13.153

It would have helped a lot if a bigger cube was used so that hardcoding wasn't so darn hard to beat. – xnor – 2017-05-19T19:12:28.797

@xnor i will make a better one. what is the sandbox – None – 2017-05-19T19:13:03.500

5

@AAlex Sandbox

– xnor – 2017-05-19T19:15:16.990

6I don't see how this is a dupe of the square one – Luis Mendo – 2017-05-19T19:15:30.710

1@LuisMendo this definitely not a dupe. There isn't a single answer that you could port from that question to this one. – caird coinheringaahing – 2017-05-19T20:20:21.883

@Satan'sSon I'm not voting to reopen because I would (un)hammer it. Feel free to vote yourself – Luis Mendo – 2017-05-19T20:30:28.440

"Hammer it"? What's that? @LuisMendo – caird coinheringaahing – 2017-05-19T20:31:05.900

1When you have a gold badge in one of the challenge's tags, you can single-handedly close it as a dupe, and I think you can undo a dupe-close too; no other people's votes needed – Luis Mendo – 2017-05-19T20:47:52.010

@carusocomputing Here, and here

– ASCII-only – 2017-05-20T00:06:50.900

Related – None – 2017-05-20T12:41:26.377

Answers

19

Carrot, 31 bytes

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

#s are replaced by the input.

Basically a port of this answer, to this problem.

Stephen

Posted 2017-05-19T17:07:02.143

Reputation: 12 293

40that looks like it took hours to golf... – Cyoce – 2017-05-19T22:36:33.750

@KritixiLithos 200 rep because you made a cool language, this doesn't seem fair xD – Stephen – 2017-05-24T15:03:11.853

13

05AB1E, 16 15 bytes

ð‚•nxвΛ•2вèJ6ô»

Try it online!

Explanation

ð‚                # push the list [<input>,<space>]
  •nxвΛ•          # push the number 816342339
        2в        # convert to list of base 2 digits
          è       # index into the the 2-char string with this list
           J      # join to string
            6ô    # split into pieces of length 6
              »   # join on newlines

Emigna

Posted 2017-05-19T17:07:02.143

Reputation: 50 798

1Can you encode the newline within the list/number to save the last 3 bytes? – Rod – 2017-05-19T17:48:57.743

@Rod That'd be a much larger number, 6 bytes at the very least, plus an extra byte or two to include the newline in the list... – ETHproductions – 2017-05-19T17:50:59.327

@Rod: You could do something like this. Unfortunately that turns out a bit longer. Good idea though.

– Emigna – 2017-05-19T17:56:18.247

1•nxвΛ•bTRð¹ì‡6ô»... yours beats transliterate slightly, only due to the ordering requirements; if I could figure out a way to implicitly take input and generate the string 01 in 1-byte, this would be a 13/14 byte solution. – Magic Octopus Urn – 2017-05-19T18:17:12.157

1@carusocomputing •nxвΛ•bT𹫇6ô» or ð«T•nxвΛ•br‡6ô» is same length. – Emigna – 2017-05-19T18:20:14.320

@Emigna I meant if I could reorder to be c.replace(b -> a), but that's not really possible. Heh. Smart organization of that reverse though. – Magic Octopus Urn – 2017-05-19T18:23:26.747

10

Cubix, 62 bytes

./v<.o;.@?/;w.w;i:::::NrSs::SrSuUS::sN::rS:r:srNr:SrSsNs:::SSv

Try it online! and Watch the interpreter!

This fits onto a 4-cube:

        . / v <
        . o ; .
        @ ? / ;
        . . w ;
i : : : : : N r S s : : S r S u
U S : : s N : : r S : r : s r N
r : S r S s N s : : : S S v . .
. . . . . . . . . . . . . . . .
        . . . .
        . . . .
        . . . .
        . . . .

I'm not very good at manipulating the direction of the instruction pointer, so I will continue to try and golf this. Both this and my answer here are based on the "Hello, World!' example program using ./v.o;@?/ (on a 3-cube) to recursively print and pop the characters on the stack, so the rest of the code is just pushing the characters onto the stack in the right order.

I have now made a cube on a cube, so I can rest easy (and do my actual work).

Giuseppe

Posted 2017-05-19T17:07:02.143

Reputation: 21 077

9

SOGL, 13 10 bytes

Βū&⁵'r⁹‘6n

Explanation:

Βū&⁵'r⁹‘    push "  ŗŗŗŗ ŗ ŗ ŗŗŗŗ  ŗŗ ŗ ŗ ŗŗŗŗ", where "ŗ" is replaced with input
        6n  split into lines of length 6

dzaima

Posted 2017-05-19T17:07:02.143

Reputation: 19 048

1How is this sitting at 0? Probably due to lack of a TIO ._. +1 – Magic Octopus Urn – 2017-05-19T18:21:07.797

I think that there's gonna be at (hopefully) most 1 more update breaking stuff and then I'll think about some online running thing – dzaima – 2017-05-19T18:33:10.900

6Son Of a Golfing Language? – ETHproductions – 2017-05-19T21:59:25.437

@ETHproductions lol – dzaima – 2017-05-19T21:59:50.773

String Oriented Golfing Language – None – 2020-01-23T02:12:41.300

9

MATL, 13 10 bytes

Thanks to Conor O'Brien for removing 3 bytes, and for showing me that unprintables can be used in Octave.

The code contains unprintable characters. Try it online!

Explanation

'....'   % Push 5-char string (contains unprintables). Each char encodes a row
         % of the desired pattern
B        % Convert to binary. Gives a 5×6 binary matrix with the pattern
*        % Implicit input. Multiply element-wise (converts input to ASCII code)
c        % Convert to char. Implicitly display. Char 0 is shown as space

Luis Mendo

Posted 2017-05-19T17:07:02.143

Reputation: 87 464

You can make this 10 bytes if you're okay with unprintables. Try it online!

– Conor O'Brien – 2017-05-19T18:24:16.283

@ConorO'Brien Hey, thanks! I wasn't sure Octave was okay with those... how did you even type them? – Luis Mendo – 2017-05-19T18:25:12.423

Well, I honestly I took the numbers, converted them to hex, then did echo 0f15392a3c|xxd -r -p|clip. On windows, clip is the clipboard. Then I just pasted them :P (If you're on a command line, it's ^O^U as well) – Conor O'Brien – 2017-05-19T18:26:57.337

@ConorO'Brien That's way over my head. You should really post that as your answer – Luis Mendo – 2017-05-19T18:31:45.220

It uses the same tactic as yours does, just removing the need for modulo 64 by using the values directly. – Conor O'Brien – 2017-05-19T18:33:17.780

6

PHP, 52 Bytes

<?=strtr("  0000
 0 0 0
000  0
0 0 0
0000",0,$argn);

Try it online!

Jörg Hülsermann

Posted 2017-05-19T17:07:02.143

Reputation: 13 026

6

Japt, 20 bytes

"OUyj|"®c ¤Åd0S1U +R

Test it online!

Not too bad for a language with no built-in compression (well, except compressing strings of lowercase letters)...

Explanation

In binary, the five characters in the string are:

O 1001111
U 1010101
y 1111001
j 1101010
| 1111100

Slice off the initial 1 from each, and you get the pattern for the cube.

"OUyj|"®   c ¤  Å  d0S1U +R
"OUyj|"mZ{Zc s2 s1 d0S1U +R}  // Expanded
                              // Implicit: U = input string
"OUyj|"mZ{                 }  // Replace each character Z in this string with this function:
          Zc                  //   Take the char-code of Z.
             s2               //   Convert to a binary string.
                s1            //   Slice off the first character (always a "1").
                   d0S1U      //   Replace "0"s with spaces and "1"s with the input.
                         +R   //   Append a newline.
                              // Implicit: output result of last expression

ETHproductions

Posted 2017-05-19T17:07:02.143

Reputation: 47 880

I tried a template-based approach (ll can be compressed), but it's 11 bytes longer. – Luke – 2017-05-19T18:13:53.460

Nice. I was down to 23 bytes before I realised I'd made a balls of it! – Shaggy – 2017-05-19T18:20:59.100

6

LOLCODE, 202 170 bytes

I HAS A c
GIMMEH c
VISIBLE"  "AN c AN c AN c AN c AN":) "AN c AN" "AN c AN" "AN c AN":)"AN c AN c AN c AN"  "AN c AN":)"AN c AN" "AN c AN" "AN c AN":)"AN c AN c AN c AN c

In LOLCODE, not much to golf...

This sets the variable c into the input, and creates a giant concatenated string including :) newlines. That's about it.

OldBunny2800

Posted 2017-05-19T17:07:02.143

Reputation: 1 379

Also, VISIBLE implicitly concatenates, so you can remove SMOOSH https://tio.run/nexus/lolcode#@@/h6KlgqGfE5ang4Ris4KiQzOXu6evr6gFkhHkGezr5uCooKQCRo59CMhZCyUoTSVIJF9tKE5sJKAajqCHRoGQu7xCPCKdI1///lQE

– eush77 – 2017-05-20T14:50:17.007

To your first thing, there are some interpreters that don't require HAI or KTHXBYE, e.g. REPL.it. To your second thing, thank you! – OldBunny2800 – 2017-05-20T14:51:58.073

5

Sed, 40 characters

s/./  &&&&\
 & & &\
&&&  &\
& & &\
&&&&/

Almost cheating as the challenge description contained it almost literally.

Sample run:

bash-4.4$ sed 's/./  &&&&\
 & & &\
&&&  &\
& & &\
&&&&/' <<< 'C'
  CCCC
 C C C
CCC  C
C C C
CCCC

Try it online!

manatwork

Posted 2017-05-19T17:07:02.143

Reputation: 17 865

5

Python 2, 61 bytes

lambda c:"""  ####
 # # #
###  #
# # #
####""".replace('#',c)

Try it online!

totallyhuman

Posted 2017-05-19T17:07:02.143

Reputation: 15 378

5

Z80 Assembly, 37 bytes machine code

Assume a memory mapped I/O device:

; DO NOT INPUT A SPACE or it will go into infinite loop printing spaces & newlines!

3A xx xx    ld  a, (input)  ; get input character
11 0A 20    ld  de, 200ah   ; space & newline
21 yy yy    ld  hl, output  ; get output address
4F          ld  c, a        ; put character in c
loop:
72          ld  (hl), d     ; output space * 2       | output character * 2
72          ld  (hl), d
77          ld  (hl), a     ; output character       | output character
71          ld  (hl), c     ; output character * 2   | output space * 2
71          ld  (hl), c
77          ld  (hl), a     ; output character       | output character
73          ld  (hl), e     ; output newline         | output newline
72          ld  (hl), d     ; output space           | output character
71          ld  (hl), c     ; output character       | output space
72          ld  (hl), d     ; output space           | output character
71          ld  (hl), c     ; output character       | output space
72          ld  (hl), d     ; output space           | output character
B9          cp  c           ; set zero flag 1st time | clear 2nd time
20 06       jr  nz, end     ; skip to end
77          ld  (hl), a     ; output character
73          ld  (hl), e     ; output newline
4A          ld  c, d        ; put space in c
57          ld  d, a        ; put character in d
28 FB       jr  z, loop     ; loop to 2nd time
end:
73          ld  (hl), e     ; output newline
77          ld  (hl), a     ; output character * 4
77          ld  (hl), a
77          ld  (hl), a
77          ld  (hl), a
76          halt            ; or C9 ret

Dan Howell

Posted 2017-05-19T17:07:02.143

Reputation: 71

4

V, 27 bytes

4äl2>>Äyvho3pÄÙ3älWx<<3Îd^

Try it online!

Hexdump:

00000000: 34e4 6c32 3e3e c479 7668 6f1b 3370 c4d9  4.l2>>.yvho.3p..
00000010: 33e4 6c57 783c 3c33 ce64 5e              3.lWx<<3.d^

James

Posted 2017-05-19T17:07:02.143

Reputation: 54 537

I'm pretty sure you can replace o<esc> with just ï – user41805 – 2017-05-20T04:57:30.627

4

Charcoal, 17 16 bytes

SβGH7+↗→³β→G↓↙³β

Try it online! Link is to verbose version of code. Longer than I wanted it to be, because the "cube" is slightly wider than it is tall or deep. Fortunately some of the multidirectional characters work with PolygonHollow, which saves me 3 bytes. Edit: Saved a further byte by using + instead of T↑. Explanation:

Sβ          Input the character
GH7+↗→³β    Draw the left half. 7 becomes ←↙ and + becomes →↓←↑.
→           Move right one character.
G↓↙³β       Draw the right half.

At the time of the challenge, the q variable didn't work in verbose mode, otherwise I could have created this 14-byte version:

GH7+↗→³θ→G↓↙³θ

Try it online!

Neil

Posted 2017-05-19T17:07:02.143

Reputation: 95 035

4

PHP, 72 bytes

I made this one just for the fun of it, since there's already a better PHP answer.

for($i=0;$i<27;)echo('00'.decbin(64349871))[$i]?$argn:' ',++$i%6?'':'
';

The cube is drawn by getting the binary value of 64349871, concatenated by '00'.
This returns the following:

0011110101011110011010101111

Every 6th character, I'm outputting a newline, resulting in this:

001111
010101
111001
101010
1111

And, instead of displaying 0, it displays a space, which will look like:

  1111
 1 1 1
111  1
1 1 1 
1111

Ismael Miguel

Posted 2017-05-19T17:07:02.143

Reputation: 6 797

3

Stacked, 31 bytes

' '\+$'9*<'#.2 tb[6 dpad]map#

Try it online!

Here's a hexdump:

λ xxd try-to-make-a-cube.stk
00000000: 2720 275c 2b24 270f 1539 2a3c 2723 2e32  ' '\+$'..9*<'#.2
00000010: 2074 625b 3620 6470 6164 5d6d 6170 23     tb[6 dpad]map#

This converts a character array to binary, pads each row to length 6, and indexes it according to the string ' ' input +

Conor O'Brien

Posted 2017-05-19T17:07:02.143

Reputation: 36 228

3

Pyth, 25 22 21 20 bytes

jcsm?d\ zjC"0¨eC"2 6

Try it!

21 bytes

t::." \"o½MËñ"\!bNw

Try this!

Also 21 bytes:

:jbct." \" ±¢î
"6Nw

Try that!

KarlKastor

Posted 2017-05-19T17:07:02.143

Reputation: 2 352

2

JS (ES6), 64 60 52 bytes

i=>`  ####
 # # #
###  #
# # #
####`.replace(/#/g,i)

Can this be improved:

i=>`  ${y=i+i+i+i}
 # # #
###  #
# # #
${y}`.replace(/#/g,i)

programmer5000

Posted 2017-05-19T17:07:02.143

Reputation: 7 828

1y=i+i+i+i is shorter than y=i.repeat(4) – Stephen – 2017-05-19T17:14:51.067

2... and #### is even shorter. – Arnauld – 2017-05-19T17:17:14.133

1

Actually the whole thing's shorter without templates: Fiddle

– Stephen – 2017-05-19T17:17:22.000

1

C (gcc), 90 84 bytes

i;v;f(g){for(i=32;i--;)putchar((v="####*@#@#@#*#@@###*#@#@#@*####@@"[i])&1?g:v-32);}

Try it online! Defines a function f that takes a character g. Too bad encoding the table directly is shorter...

Old version, 90 bytes

(Still trying to golf this one)

Trying to have only a single putchar, but idk. There are unprintables, so here is the hexdump:

λ xxd try-to-make-a-cube.c
00000000: 693b 6a3b 6628 6729 7b63 6861 722a 6b3d  i;j;f(g){char*k=
00000010: 220f 1539 2a3c 223b 666f 7228 693d 303b  "..9*<";for(i=0;
00000020: 693c 353b 7075 7463 6861 7228 3130 292c  i<5;putchar(10),
00000030: 692b 2b29 666f 7228 6a3d 3332 3b6a 3b6a  i++)for(j=32;j;j
00000040: 2f3d 3229 7075 7463 6861 7228 6b5b 695d  /=2)putchar(k[i]
00000050: 266a 3f67 3a33 3229 3b7d                 &j?g:32);}

This encodes the cube into a binary lookup table, where a 1 bit represents the input and a 0 bit represents a space. Try it online!

Conor O'Brien

Posted 2017-05-19T17:07:02.143

Reputation: 36 228

Can shave a few bytes off for 81 bytes.

– gastropner – 2020-01-23T21:33:43.973

The unprintables one can be squeezed to 73 bytes.

– gastropner – 2020-01-23T21:51:30.977

1

Brain-Flak, 217 bytes

(((((((((((((((((({}))))<([][]()())>)<(([][])[]{}())>)<(([][]){})>)<([])>)<(((()
())[][]{}()()))>)))<((()()()()()){})>)<(((()()()){}){}()[])>)<(((()()())()){}{}[
])>)<(((()()())){}{}[])((()()()()()){})>))))(([]()()()))

Try it online!

Waaaaay too long.

James

Posted 2017-05-19T17:07:02.143

Reputation: 54 537

1

Swift - 82 bytes + Foundation (18 bytes)?

var f={"  ####\n # # #\n###  #\n# # #\n####".replacingOccurrences(of:"#",with:$0)}

By default, Xcode-Swift projects have Whole-Module Optimization, so that import Foundation is not required for this simple lambda-like function. However, running it in online environments requires it, which may add 18 bytes.

Check it out!

Mr. Xcoder

Posted 2017-05-19T17:07:02.143

Reputation: 39 774

1

Java 8, 55 bytes

c->"  ####\n # # #\n###  #\n# # #\n####".replace('#',c) 

Try it here.

Java 7, 77 bytes

String c(char c){return"  ####\n # # #\n###  #\n# # #\n####".replace('#',c);}

Try it here.

Kevin Cruijssen

Posted 2017-05-19T17:07:02.143

Reputation: 67 575

0

CJam, 23 bytes

"pjFUC"{i2b(;}%rS+ff=N*

I feel like I can still golf this.

"pjFUC" e# String literal:          │ "pjFUC"
{       e# For each:                │ 'p
  i     e#   Get code point:        │ 112
  2b    e#   To binary:             │ [1 1 1 0 0 0 0]
  (;    e#   Delete first:          │ [1 1 0 0 0 0]
}%      e# End                      │ [[1 1 0 0 0 0] [1 0 1 0 1 0] [0 0 0 1 1 0] [0 1 0 1 0 1] [0 0 0 0 1 1]]
r       e# Read token:              │ [[1 1 0 0 0 0] [1 0 1 0 1 0] [0 0 0 1 1 0] [0 1 0 1 0 1] [0 0 0 0 1 1]] "&"
S       e# Push space:              │ [[1 1 0 0 0 0] [1 0 1 0 1 0] [0 0 0 1 1 0] [0 1 0 1 0 1] [0 0 0 0 1 1]] "&" " "
+       e# Concatenate:             │ [[1 1 0 0 0 0] [1 0 1 0 1 0] [0 0 0 1 1 0] [0 1 0 1 0 1] [0 0 0 0 1 1]] "& "
ff=     e# Vectorized array lookup: │ ["  &&&&" " & & &" "&&&  &" "& & & " "&&&&  "]
N*      e# Join with newlines       │ "  &&&&
        e#                          │   & & &
        e#                          │  &&&  &
        e#                          │  & & & 
        e#                          │  &&&&  "
e# Implicit output

Esolanging Fruit

Posted 2017-05-19T17:07:02.143

Reputation: 13 542

0

dc, 70 bytes

Encodes the sequence rather directly, with minor optimization:

8224PdPdPdPdP10Pd8192+ddPPP10PdPdPdP8224PdP10Pd256*32+ddPPP10PdPdPdPdP

Try it online!


Taken to a (not very golfy) extreme, 145 bytes:

27065671941896667324298575455432398417474802390765222440949482848513*56759961956005660143530475805610581704254588701249011343446231795984498688+P

Try it online!

This computes A*x+B, where A encodes the positions of the input character and B encodes all the rest:

A = 2560 + 2561 + 2562 + 2563 + 2565 + 2567 + 2569 + 25611 + 25614 + 25615 + 25616 + 25618 + 25620 + 25622 + 25625 + 25626 + 25627 + 25628

B = 10×2564 + 32×2566 + 32×2568 + 10×25610 + 32×25612 + 32×25613 + 10×25617 + 32×25619 + 32×25621 + 32×25623 + 10×25624 + 32×25629 + 32×25630

P command prints the resulting number as a byte stream.

eush77

Posted 2017-05-19T17:07:02.143

Reputation: 1 280

0

Windows batch, 79 bytes

@echo   %1%1%1%1
@echo  %1 %1 %1
@echo %1%1%1  %1
@echo %1 %1 %1
@echo %1%1%1%1

Special char. safe, 97 bytes:

@echo   ^%1^%1^%1^%1
@echo  ^%1 ^%1 ^%1
@echo ^%1^%1^%1  ^%1
@echo ^%1 ^%1 ^%1
@echo ^%1^%1^%1^%1

stevefestl

Posted 2017-05-19T17:07:02.143

Reputation: 539

Can you use line feeds i.e. .. %1%1%1%1\n %1 %1 %1... – TheLethalCoder – 2017-05-22T15:36:35.007

Line feeds are not supported in batch – stevefestl – 2017-05-23T08:38:54.073

I couldn't remember if they was or not and wasn't in a position to test :) – TheLethalCoder – 2017-05-23T08:40:29.190

Sorry, I'm confused, can you repeat? – stevefestl – 2017-05-23T08:40:58.297

I couldn't remember if you could use them or not and I couldn't test at the time I commented so I left the comment so you would still have the idea – TheLethalCoder – 2017-05-23T08:48:28.170

0

C#, 53 bytes

c=>@"  ####
 # # #
###  #
# # #
####".Replace('#',c);

TheLethalCoder

Posted 2017-05-19T17:07:02.143

Reputation: 6 930

0

Tcl, 60 bytes

proc c x {regsub . $x "  &&&&\n & & &\n&&&  &\n& & &\n&&&&"}

avl42

Posted 2017-05-19T17:07:02.143

Reputation: 111