# Make me a square!

Given one non-whitespace printable character, make a 3x3 square representation of that input. For example, if the input is #, then the output is:

###
# #
###


# Rules

• The output format is strict, although a trailing newline is allowed. It means that the space in the middle is required, and also that the two newline characters separating the three lines are required.

# Testcases

Input: #

Output:

###
# #
###


Input: A

Output:

AAA
A A
AAA


Input: 0

Output:

000
0 0
000


# Scoring

This is . Shortest answer in bytes wins.

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

/* Configuration */

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

/* App */

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

}

jQuery.ajax({
method: "get",
dataType: "jsonp",
crossDomain: true,
success: function (data) {
data.items.forEach(function(a) {
});
comment_page = 1;
}
});
}

jQuery.ajax({
method: "get",
dataType: "jsonp",
crossDomain: true,
success: function (data) {
data.items.forEach(function(c) {
if (c.owner.user_id === OVERRIDE_USER)
});
else process();
}
});
}

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

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

function process() {
var valid = [];

var body = a.body;
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],
});

});

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;

.replace("{{NAME}}", a.user)
.replace("{{LANGUAGE}}", a.language)
.replace("{{SIZE}}", a.size)

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)
language = jQuery(language);
jQuery("#languages").append(language);
}

}
body { text-align: left !important}

width: 290px;
float: left;
}

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

font-weight: bold;
}

table td {
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>

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

</tbody>
</table>
</div>
<table style="display: none">
</tbody>
</table>
<table style="display: none">
<tbody id="language-template">
</tbody>
</table>

• The fact that the size is fixed allows for some optimization. Answers form the linked challenge will probably not be competitive here. So I don't think it's a duplicate – Luis Mendo May 11 '17 at 14:33
• I was the one who downvoted, for it for being a simple, boring challenge. I'm normally a fan of easy challenges, as they're a good place for new golfers to start but this just feels too easy. – Shaggy May 11 '17 at 14:56
• @Ayoungcoder It is a perfectly valid reason to downvote a challenge. – Post Rock Garf Hunter May 11 '17 at 14:59
• @Shaggy: In terms of difficulty, there's difficulty to write the program, and difficulty to golf the program. This program is easy to write, but I'm not so sure it's easy to golf it. – user62131 May 11 '17 at 15:33
• In my opinion, this is a good challenge for people who are just getting started with code golfing. It's good to have a mix of difficulties. Overloading on any one type will be to the detriment of some part of the community. So, I'm glad this challenge was written. – isaacg May 13 '17 at 6:22

# CJam, 11 10 bytes

r9*4St3/N*


Try it online!

Explanation:

r9*4St3/N* e# Expects single char (token) as input
r          e# Get input token (C)
9*        e# Repeat C 9 times
4St     e# Set the 5th char of C to be a space
3/   e# Split into parts of length 3
N* e# Join by newlines


# Windows batch, 37 bytes

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


Simply outputs the first command-line argument in a square form.

# Emacs, 15 keystrokes

The current buffer must only contain the input character, and the cursor must be at the start of the line.

C-k C-y C-y C-y C-a C-k C-y RET C-y C-b BACKSPACE SPC C-e RET C-y


# Python 3, 31 bytes

lambda s:3*s+f'\n{s} {s}\n'+3*s


Try it online!

# StupidStackLanguage 28 bytes

jfffavvflflqvvvviifblflflfff


Explanation:

j # Get the input (x)
fff # first 3
avv # new line
fl # print new line
fl # first x
qvvvviifb # space
lf # second x
lf # new line
lfff # last 3 x's

• Welcome to the site :) – sporeball Jan 30 at 5:20

# Aceto, 19 bytes

nppk
pKLp
pppn
,kpp


Read a single character (,), then activate sticky mode (k). Print it three times, a newline and then the character again (pppnp).

Deactivate sticky mode (K), then load the empty string from quick storage (L), print it (p), activate sticky mode again (k), and print the rest (pnppp).

i:o:o:oao:$o" "|;o~  Try it online! # Retina, 18 bytes :$
$_$_
*2=.



Half of this code looks like trailing empty lines, I like that :)

Try it online!

### Explanation

There are three stages in this program, each of them prints a line of the output, in sequence.

:_$_  Add two more copies of the input at the end and print the resulting string. *2=.  There's a single space in the second line. This stage replaces the second character of the string with a space, prints the result, and then reverts the string to what it was before (thanks to the *)   The two final empty lines are a replacement stage with no effect. This is only needed because a final stage with no printing modifier implicitly prints the resulting string. • Save 1 byte by removing the third stage and putting the second stage into a group. The implicit print then moves from the stage to the group, allowing the stage's own dry run to be an additional output. (The ( needs to be at the start of the third line for this to work.) – Neil Jun 4 '17 at 16:24 ## C#, 7471 66 bytes m=>{System.Console.WriteLine("{0}{0}{0}\n{0} {0}\n{0}{0}{0}",m);};  golfed 5 bytes thanks to an anon • You can save some bytes if you use r==1?" ":m directly in WriteLine, instead of assigning it to s. – raznagul May 12 '17 at 10:00 • You need to fully qualify the Console – TheLethalCoder May 12 '17 at 10:56 ## C#, 30 bytes s=>s+s+s+$"\n{s} {s}\n"+s+s+s;


Compiles to a Func<string, string>.

Using Replace for 32 bytes.

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


Compiles to a Func<char, string>.

• @ConorO'Brien Thanks, for some reason I have a problem typing string the right way round... – TheLethalCoder May 12 '17 at 11:26

# ///, 27 bytes

/\\\#//\#\#\#
\#\ \#
\#\#\#


Try it online!

Since there is no other way to take input in ///, it is hard-coded.

/\\\#/INPUT HERE/\#\#\#
\#\ \#
\#\#\#


Version that takes input in Itflabtijtslwi (28 bytes):

GG\\\#GG\#\#\#
\#\ \#
\#\#\#


Try it online!

## QBIC, 23 20 bytes

Brute-forcing this is shorter than fancy string-flips...

?;+A+A?A+@ +A?A+A+A


A=;+A+A+@┘+A?A+@ +_fA


Explanation:

A=;     ; gets a cmd line parameter and assigns it to A$This overrides that value by +A+A appending itself two times +@┘ Then a literal newline +A And another copy of the input char ? PRINT A The combined A$ ("###\n#")
+@     a space
+_fA    and then the flipped version of A$ # Javascript (ES6), 32 bytes i=>### # # ###.replace(/#/g,i)  # R, 43 40 bytes cat(gsub("y",scan(,""),"yyy\ny y\nyyy")) Saved 3 bytes thanks to Giuseppe. Explanation: create a box using the character "y" and then substitute the input character. • You can drop 3 bytes by reading x from stdin instead of making it a function: cat(gsub("y",scan(,""),"yyy\ny y\nyyy")) – Giuseppe May 19 '17 at 17:45 • using 1 in place of "y" saves 2 more bytes. – Giuseppe Jan 30 at 19:16 # Cubix, 26 bytes ./v.o;@?/i:::Ns:Ss:Nu/:::s  This is the first piece of Cubix code I've ever written...I was originally going to try to answer the Try to make a cube challenge, but I figured I'd answer the original (easier) question first. Cubix is pretty cool! ## R, 44 bytes cat(y<-rep(scan(,''),4),' ',y,sep='',fill=3)  Test and output: > cat(y<-rep(scan(,''),4),' ',y,sep='',fill=3) 1: # 2: Read 1 item ### # # ### >  • You can drop a few bytes by returning an anonymous function, but you can do even better by reading from stdin: cat(y=rep(scan(,''),4),' ',y,sep='',fill=3) is 43 bytes. – Giuseppe May 19 '17 at 17:43 # Japt, 11 9 bytes ³+R+U+S ê  Try it online ## Explanation  :Implicit input of string U ³ :Repeat input 3 times +R :Append newline +U :Append input +S :Append space ê :Duplicate string, excluding last character, reverse it and append it to original  ## Alternative, 9 bytes I can't decide which version I prefer. [U³RUS]¬ê  Try it online ## Alternative, 10 bytes I really liked this version, but sadly it came in at a byte too big. NpU²RUS ¬ê  Try it online • Nice! p3  can be shortened to ³ – Oliver May 19 '17 at 14:37 • Aha, hadn't spotted that. Thanks again, @obarakon. – Shaggy May 19 '17 at 14:39 # brainfuck, 48 bytes Great simple challenge. ,...>++++++++++.<.>+[->+>+++<<]>>-.<<<.>>-.<<...  Try it online! # Explanation ,... : take input, print it 3 times >++++++++++. : print ASCII with index 10 (new line) <.> : print input. +[->+>+++<<]>>-. : add 1 to 10, triple it, subtract one and print it (space) <<<.>>-.<<... : print input, newline, and input 3 times  # Perl 5, 23 + 1 (-p) = 24 bytes The brute force way seems to be the shortest. $_.="$_$_
$_$_
$_$_$_"  Try it online! # Syms, 21 bytes {}<[[[++~[{& &}~[>~>>  Try it online! • oops, didnt allow trailing [] but never specified it, lucky ig guess :) – Luc H Sep 16 '17 at 6:37 • Um why is -i on – CalculatorFeline Sep 25 '17 at 19:51 # Pepe, 54 bytes REEeREEEeeReeerREeeeeEeEeReeereeeEeeeeeReeeREEeeReReee  Try it Explanation: REEe # Input as str REEEee # Duplicate it Reee # Output whole stack rREeeeeEeEe # Insert linefeed (10) to the stack Reee # Output whole stack reeeEeeeee # Print space (' ') Reee # Output whole stack REEee # Go to next position ReReee # Pop it (space) and output the whole stack  # Dart, 30 bytes f(s)=>'$s$s$s\n$s$s\n$s$ss';  Try it online! # Keg, 11 bytes ??? ? ? ???  It really just replaces the ?s with the input! Alterate 11 byter ¿3*:& ? ? &  • Neither program works on TIO – Jo King Dec 26 '19 at 9:12 • Because Keg needs a pull on TIO – Lyxal Dec 26 '19 at 9:13 • @JoKing Dennis is not very active this week. He didn't get the latest interpreter on TIO yet. – user85052 Dec 26 '19 at 9:13 • @JoKing TIO is 19 commits behind the Keg repo – Lyxal Dec 26 '19 at 9:15 # 05AB1E, 7 6 bytes using the canvas and compressed integers. 3IŽ9¦Λ  Try it online! • -1 byte by simply changing the Ƶ‘0« to Ž9¦ (see the How to compress large integers? section of this tip). – Kevin Cruijssen Jan 3 at 8:47 • @KevinCruijssen Thanks, I was trying to use compressed integers but it wasn't getting the 0 at the start. – facepalm42 Jan 3 at 20:34 • You're right, 0s at the start (both with compressed integers and compressed integer lists) doesn't work. But since it has to be a square anyway, and your previous answer was appending the 0 at the end, it can be a single compressed integer 2460 to save a byte. :) – Kevin Cruijssen Jan 4 at 11:52 # naz, 46 bytes 1x1f0m9a1a1o0x1r2x1v3o1f1v1o0m4a8m1o1v1o1f1v3o  Strictly speaking, the above program outputs the exact byte stream required to make the square, though the top of the square will be misaligned given that the interpreter linked above always prepends output: to program output. Explanation (with 0x commands removed) 1x1f0m9a1a1o # Function 1 # Reset the register, add 10 and output (produces a newline) 1r2x1v # Read the first byte of input and store it in variable 1 3o # Output the byte 3 times 1f # Call function 1 1v1o0m4a8m1o1v1o # Output variable 1, output 32 (space), then output variable 1 1f # Call function 1 1v3o # Output variable 1 3 times  # GolfScript, 15 bytes ...n\." "\.n\..  Explanation At the beginning of the program, the input is put onto the stack. Each . copies the top of stack. Each n pushes a newline onto the stack. " " pushes a space. \ swaps the top two elements. At the end of the program, the stack is output to the standard output. Try it Online • 13 bytes – user85052 Jan 23 at 4:20 # TI-BASIC, 14 + 6 = 20 bytes This submission uses two programs, the main one and a helper program called prgmΘ. prgmΘ:Disp Ans+" "+Ans:prgmΘ ;main program Disp Ans+Ans+Ans ;helper program "prgmΘ"  Input is a string stored in Ans. # AWK, 2826 25 bytes 0=$0$0$0RS$0FS$0RS$0$0$0


Try it online!

## Wdn, 8 bytes

º±▀σ\g┘╒


Uncompressed:

4*:' S++3,


Explanation:

4*         Repeat input 4 times
:' S++   Put space in middle, append input * 4
3, Chop into 3 equal pieces
Flag: n Join with newlines


## Wd, 1311 9 bytes

Here's a version without chopping or similar built-ins.

↨i♣T'@└µ


## Explanation

Uncompressed is:

' a++bab++E

          E % Foreach in the string:
' a++       % (implicit) input, the space, and input
bab++  % Output the string created by the input,
% the current item, and the input
% With a newline
% The None isn't outputted


# Braingolf, 34 20 bytes

...#
<.># <.>#
<..&@


Little disappointed that this isn't easily golfed. At least it's shorter than JavaScript

### Explanation:

For input #

                   | [35]
...                | [35,35,35,35]
#<newline>      | [35,35,35,35,10]
<.>                | [35,35,35,35,10,35]
#<space>        | [35,35,35,35,10,35,32]
<.>           | [35,35,35,35,10,35,32,35]
#<newline> | [35,35,35,35,10,35,32,35,10]
<..                | [35,35,35,10,35,32,35,10,35,35,35]
&@              | Print entire stack

35 = # ASCII value
10 = <newline> ASCII value
32 = <space> ASCII value

Output:
###
# #
###