16
\$\begingroup\$

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>

\$\endgroup\$
  • 5
    \$\begingroup\$ Well, this is somewhat similar, although at least it's not a 3-byte answer in Charcoal this time... \$\endgroup\$ – Neil May 19 '17 at 17:08
  • 1
    \$\begingroup\$ Can the last two lines have leading spaces and can the result have leading newlines? \$\endgroup\$ – dzaima May 19 '17 at 17:15
  • 3
    \$\begingroup\$ B³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. \$\endgroup\$ – Magic Octopus Urn May 19 '17 at 17:39
  • 5
    \$\begingroup\$ @AAlex Sandbox \$\endgroup\$ – xnor May 19 '17 at 19:15
  • 6
    \$\begingroup\$ I don't see how this is a dupe of the square one \$\endgroup\$ – Luis Mendo May 19 '17 at 19:15

26 Answers 26

19
\$\begingroup\$

Carrot, 31 bytes

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

#s are replaced by the input.

Basically a port of this answer, to this problem.

| improve this answer | |
\$\endgroup\$
  • 40
    \$\begingroup\$ that looks like it took hours to golf... \$\endgroup\$ – Cyoce May 19 '17 at 22:36
  • \$\begingroup\$ @KritixiLithos 200 rep because you made a cool language, this doesn't seem fair xD \$\endgroup\$ – Stephen May 24 '17 at 15:03
13
\$\begingroup\$

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
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Can you encode the newline within the list/number to save the last 3 bytes? \$\endgroup\$ – Rod May 19 '17 at 17:48
  • \$\begingroup\$ @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... \$\endgroup\$ – ETHproductions May 19 '17 at 17:50
  • \$\begingroup\$ @Rod: You could do something like this. Unfortunately that turns out a bit longer. Good idea though. \$\endgroup\$ – Emigna May 19 '17 at 17:56
  • 1
    \$\begingroup\$ •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. \$\endgroup\$ – Magic Octopus Urn May 19 '17 at 18:17
  • 1
    \$\begingroup\$ @carusocomputing •nxвΛ•bT𹫇6ô» or ð«T•nxвΛ•br‡6ô» is same length. \$\endgroup\$ – Emigna May 19 '17 at 18:20
10
\$\begingroup\$

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

| improve this answer | |
\$\endgroup\$
9
\$\begingroup\$

SOGL, 13 10 bytes

Βū&⁵'r⁹‘6n

Explanation:

Βū&⁵'r⁹‘    push "  ŗŗŗŗ ŗ ŗ ŗŗŗŗ  ŗŗ ŗ ŗ ŗŗŗŗ", where "ŗ" is replaced with input
        6n  split into lines of length 6
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ How is this sitting at 0? Probably due to lack of a TIO ._. +1 \$\endgroup\$ – Magic Octopus Urn May 19 '17 at 18:21
  • \$\begingroup\$ 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 \$\endgroup\$ – dzaima May 19 '17 at 18:33
  • 6
    \$\begingroup\$ Son Of a Golfing Language? \$\endgroup\$ – ETHproductions May 19 '17 at 21:59
  • \$\begingroup\$ @ETHproductions lol \$\endgroup\$ – dzaima May 19 '17 at 21:59
  • \$\begingroup\$ String Oriented Golfing Language \$\endgroup\$ – user85052 Jan 23 at 2:12
9
\$\begingroup\$

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
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ You can make this 10 bytes if you're okay with unprintables. Try it online! \$\endgroup\$ – Conor O'Brien May 19 '17 at 18:24
  • \$\begingroup\$ @ConorO'Brien Hey, thanks! I wasn't sure Octave was okay with those... how did you even type them? \$\endgroup\$ – Luis Mendo May 19 '17 at 18:25
  • \$\begingroup\$ 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) \$\endgroup\$ – Conor O'Brien May 19 '17 at 18:26
  • \$\begingroup\$ @ConorO'Brien That's way over my head. You should really post that as your answer \$\endgroup\$ – Luis Mendo May 19 '17 at 18:31
  • \$\begingroup\$ It uses the same tactic as yours does, just removing the need for modulo 64 by using the values directly. \$\endgroup\$ – Conor O'Brien May 19 '17 at 18:33
6
\$\begingroup\$

PHP, 52 Bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
6
\$\begingroup\$

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
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I tried a template-based approach (ll can be compressed), but it's 11 bytes longer. \$\endgroup\$ – Luke May 19 '17 at 18:13
  • \$\begingroup\$ Nice. I was down to 23 bytes before I realised I'd made a balls of it! \$\endgroup\$ – Shaggy May 19 '17 at 18:20
6
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ expected HAI at: I tio.run/nexus/… \$\endgroup\$ – eush77 May 20 '17 at 14:44
  • \$\begingroup\$ Also, VISIBLE implicitly concatenates, so you can remove SMOOSH tio.run/nexus/lolcode#@@/… \$\endgroup\$ – eush77 May 20 '17 at 14:50
  • \$\begingroup\$ 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! \$\endgroup\$ – OldBunny2800 May 20 '17 at 14:51
5
\$\begingroup\$

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!

| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

Python 2, 61 bytes

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

Try it online!

| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

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
| improve this answer | |
\$\endgroup\$
4
\$\begingroup\$

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^
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I'm pretty sure you can replace o<esc> with just ï \$\endgroup\$ – user41805 May 20 '17 at 4:57
4
\$\begingroup\$

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
| improve this answer | |
\$\endgroup\$
4
\$\begingroup\$

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!

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

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 +

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

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!

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

JS (ES6), 64 60 52 bytes

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

Can this be improved:

i=>`  ${y=i+i+i+i}
 # # #
###  #
# # #
${y}`.replace(/#/g,i)
| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ y=i+i+i+i is shorter than y=i.repeat(4) \$\endgroup\$ – Stephen May 19 '17 at 17:14
  • 2
    \$\begingroup\$ ... and #### is even shorter. \$\endgroup\$ – Arnauld May 19 '17 at 17:17
  • 1
    \$\begingroup\$ Actually the whole thing's shorter without templates: Fiddle \$\endgroup\$ – Stephen May 19 '17 at 17:17
1
\$\begingroup\$

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!

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Can shave a few bytes off for 81 bytes. \$\endgroup\$ – gastropner Jan 23 at 21:33
  • \$\begingroup\$ The unprintables one can be squeezed to 73 bytes. \$\endgroup\$ – gastropner Jan 23 at 21:51
1
\$\begingroup\$

Brain-Flak, 217 bytes

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

Try it online!

Waaaaay too long.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

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!

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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
| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

C#, 53 bytes

c=>@"  ####
 # # #
###  #
# # #
####".Replace('#',c);
| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

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
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Can you use line feeds i.e. .. %1%1%1%1\n %1 %1 %1... \$\endgroup\$ – TheLethalCoder May 22 '17 at 15:36
  • \$\begingroup\$ Line feeds are not supported in batch \$\endgroup\$ – stevefestl May 23 '17 at 8:38
  • \$\begingroup\$ I couldn't remember if they was or not and wasn't in a position to test :) \$\endgroup\$ – TheLethalCoder May 23 '17 at 8:40
  • \$\begingroup\$ Sorry, I'm confused, can you repeat? \$\endgroup\$ – stevefestl May 23 '17 at 8:40
  • \$\begingroup\$ 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 \$\endgroup\$ – TheLethalCoder May 23 '17 at 8:48
0
\$\begingroup\$

Tcl, 60 bytes

proc c x {regsub . $x "  &&&&\n & & &\n&&&  &\n& & &\n&&&&"}
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy