# Try to make a cube!

Based on this: Try to make 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

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

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

# Carrot, 31 bytes

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


#s are replaced by the input.

Basically a port of this answer, to this problem.

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

# 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

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

# SOGL, 13 10 bytes

Βū&⁵'r⁹‘6n


Explanation:

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

• How is this sitting at 0? Probably due to lack of a TIO ._. +1 – Magic Octopus Urn May 19 '17 at 18:21
• 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 May 19 '17 at 18:33
• Son Of a Golfing Language? – ETHproductions May 19 '17 at 21:59
• @ETHproductions lol – dzaima May 19 '17 at 21:59

# 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

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

# Cubix, 62 bytes

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


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

# PHP, 52 Bytes

<?=strtr("  0000
0 0 0
000  0
0 0 0
0000",0,$argn);  Try it online! ## 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  • I tried a template-based approach (ll can be compressed), but it's 11 bytes longer. – Luke May 19 '17 at 18:13 • Nice. I was down to 23 bytes before I realised I'd made a balls of it! – Shaggy May 19 '17 at 18:20 # 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  # 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. • expected HAI at: I tio.run/nexus/… – eush77 May 20 '17 at 14:44 • Also, VISIBLE implicitly concatenates, so you can remove SMOOSH tio.run/nexus/lolcode#@@/… – eush77 May 20 '17 at 14:50 • 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 May 20 '17 at 14:51 # 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!

# Python 2, 61 bytes

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


Try it online!

# V, 27 bytes

4äl2>>Äyvho3pÄÙ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^

• I'm pretty sure you can replace o<esc> with just ï – Cows quack May 20 '17 at 4:57

# 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  # Charcoal, 17 16 bytes ＳβＧＨ7+↗→³β→Ｇ↓↙³β  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: Ｓβ Input the character ＧＨ7+↗→³β Draw the left half. 7 becomes ←↙ and + becomes →↓←↑. → Move right one character. Ｇ↓↙³β 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: ＧＨ7+↗→³θ→Ｇ↓↙³θ  Try it online! # 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 + # Pyth, 252221 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! # JS (ES6), 6460 52 bytes i=> #### # # # ### # # # # ####.replace(/#/g,i)  Can this be improved: i=>${y=i+i+i+i}
# # #
###  #
# # #
${y}.replace(/#/g,i)  • y=i+i+i+i is shorter than y=i.repeat(4) – Stephen May 19 '17 at 17:14 • ... and #### is even shorter. – Arnauld May 19 '17 at 17:17 • Actually the whole thing's shorter without templates: Fiddle – Stephen May 19 '17 at 17:17 # 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! # Brain-Flak, 217 bytes (((((((((((((((((({}))))<([][]()())>)<(([][])[]{}())>)<(([][]){})>)<([])>)<(((() ())[][]{}()()))>)))<((()()()()()){})>)<(((()()()){}){}()[])>)<(((()()())()){}{}[ ])>)<(((()()())){}{}[])((()()()()()){})>))))(([]()()()))  Try it online! Waaaaay too long. # 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!

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

## 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


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

## C#, 53 bytes

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


# 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

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

# Tcl, 60 bytes

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