text:
Is the checkbox not not unchecked?
Doing code review, I stumbled upon the following code, that tests the status of a checkbox:
if (!isNotUnchecked()) { ... }

I had to brainstorm for 30 minutes to find out what actual checkbox status the code was expecting. Please write me a program that can simplify these silly expressions!

The program should accept as input a string representing the expression to simplify (for example: !isNotUnchecked()). The program should output a logically equivalent simplified expression, either isChecked() or !isChecked().
The method name in the input expression always starts with is, contains 0..n Not, and ends with Checked() or Unchecked().
The method can be prefixed by any number of !.
Examples
isChecked() => isChecked()
isUnchecked() => !isChecked()
isNotChecked() => !isChecked()
!isNotChecked() => isChecked()
!!!isNotNotUnchecked() => isChecked()

Is the text always case-sensitive? Would the input be notunischecked?

@SteveFest No, you can assume the input is always in the format that I've described above. You don't need to handle isnotunchecked for example.

leading/trailing whitespace allowed?

With a function name like that I'd give it 10 to 1 odds that it didn't even actually test the checked condition  consistent with it's naming.

May I comment on your title? This type of function seems trivial: if it is a triple negative of the term "checked" (or double negative of the term "unchecked") it is not "checked" (or it is "unchecked"). So if the answer to your question is yes, the formulation of your question is valid (it is not not unchecked). However, I find the implication for natural language interesting: if you say "the glass is not empty" it doesn't mean the glass is full (the glass may be half-empty). Now if you say "the glass is not not empty" it means that you know what is a non-empty glass, and this glass is not.

In other words, you know what is an unchecked box, you know what is a non-unchecked box (it is checked, if and only if "checked" and "unchecked" are the only two possible states, otherwise it could be anything in the checkbox: int, sign...) and for this specific checkbox, it is not (it is not "checked", whether it is with a check mark or anything). If true then, you are sure that the checkbox is not "checked" by anything. If false, well, you know the checkbox is a non-unchecked box but it doesn't necessarily mean it is checked unless there are only two possible states (then it is checked).

@J Doe thanks for clarification!

Python, 51 bytes
lambda s:sum(map(s.count,'!NU'))%2*'!'+'isC'+s[-8:]

Try it online!

You are a pure genius! Would have never thought of s[-8:]

Surely 'isC'+s[-8:] is a byte longer than 'isChecked'?

but 1 byte shorter than 'isChecked()'

Can someone explain what s[-8:] is/does?

@EdmundReed It takes the last 8 characters of the input, which are always hecked().

@xnor gotcha, thanks!

Retina, 23 bytes
Unc
!C
Not
!
O`is|!
!!

Try it online!
Explanation
Unc
!C

Turn Unchecked into !Checked.
Not
!

Turn all Nots into !. We now get something like !!!is!!!!Checked().
O`is|!

Sort all matches of either is or !. Since ! < is, this moves all the ! to the beginning of the string, so the above example would become !!!!!!!isChecked().
!!

Remove pairs of ! to cancel repeated negation.

///, 26 bytes
/Unc/NotC//isNot/!is//!!//

Try it online!
Port of my Retina answer.

Python, 43 bytes
lambda s:sum(map(ord,s))%2*'!'+'isC'+s[-8:]

An unnamed function taking the string, s and returning a string.
Try it online!
No need to check for existence of characters when !, Not, and Un all have exactly one odd ordinal (and c and C are both odd), so just sum up the ordinals and use the value modulo 2 to decide if we want a ! or not.
Other than that the form is the same as xnor's answer, as I didn't find anything better. The following is also 43:
lambda s:'!isC'[~sum(map(ord,s))%2:]+s[-8:]

JavaScript (ES6), 51 50 bytes

f=
s=>(s.split(/!|n/i).length%2?'':'!')+'isChecked()'
<input oninput=o.textContent=f(this.value)><pre id=o>

Works by looking for !, N, and n characters, which invert the checked state. split returns an odd array length by default, so we add the ! when the split length is even. Edit: Saved 1 byte thanks to @ETHproductions. Alternative version, also for 50 bytes:
s=>`${s.split(/!|n/i).length%2?``:`!`}isChecked()`

Huh, now I go back and look at the other answers, they're all doing this.

You should be able to drop the global flag from the RegEx to save a byte.

@Shaggy Actually my length is correct, I just failed to removed the g in the latest edit.

I think you can save a byte with /!|N/i

@ETHproductions I think you meant /!|N/ without the i modifier

@SplittyDev No, he means to match the n of Unchecked.

@Neil Oh, I see. Just woke up and played around with it in node, must have missed some cases cause it seemed to work just fine without the modifier.

Retina, 24 bytes
Unc
NotC
+`isNot
!is
!!

Try it online!

Java 7, 100 77 bytes
String c(String s){return(s.split("[!NU]").length%2<1?"!":"")+"isChecked()";}

Expanation:
String c(String s){  // Method with String parameter and String return-type
  return(s.split("[!NU]").length
                     //  Count the amount of '!', 'N' and 'U' in the input String (+ 1)
    %2<1?            //  and if they are an even number:
     "!"             //   Start with an examination mark
    :                //  Else:
     "")             //   Start with nothing
    +"isChecked()";  //  And append "isChecked()" to that
}                    // End of method

Test code:
Try it here.
class M{
  static String c(String s){return(s.split("[!NU]").length%2<1?"!":"")+"isChecked()";}

  public static void main(String[] a){
    System.out.println(c("isChecked()"));
    System.out.println(c("isUnchecked()"));
    System.out.println(c("isNotChecked()"));
    System.out.println(c("!isNotChecked()"));
    System.out.println(c("!!!isNotNotUnchecked()"));
  }
}

Output:
isChecked()
!isChecked()
!isChecked()
isChecked()
isChecked()

Aceto, 49 bytes
&M"pp"
L!)(de
&c;`Che"
`!d!sick
!',@p"!'
'N'U`!Lu

yadda yadda Hilbert curve.
First of all, we push the three important characters on the stack:
!'
'N'U

Then we set a catch mark and start by reading a single character. We duplicate it and negate it, and if the result of this is truthy (so if the string was empty; so the input ended), we jump to the end:
;`
d!
,@

With the remaining copy of the input character, we check whether it is contained in the rest of the stack (i.e. if its one of !, N, U). If it's not, we raise an error, throwing us back to our catch mark where we read another character:
&c
`!

Otherwise, we load what's on quick storage (essentially a register that's initially an empty string; falsy), negate it and send it back to quick storage, then raise the error too (going back to reading characters):
&M
L!

When the input stopped, we are sent to the end. There, we reverse the direction, push an exclamation mark, and load quick storage and negate it. If that is truthy (i.e. we've had an odd number of negation things), we print the exclamation mark we've pushed:
p !'
`!Lu

Finally, we push the string in two parts and print them (for space saving reasons):
"pp"
)(de
  Che"
  sick
   "

Afterwards, the program still runs back to the original beginning, but since none of the commands output anything or have loopy behaviour, that doesn't matter. Actually, the first non-nopping command we reach raises an exception, skipping a majority of the code because we jump to the catch mark, meaning all Aceto sees in that part is:
&

!' @
'N'U

Since U is now not preceeded by a single-quote character and is therefore not seen as a character literal, it gets interpreted as a command: U reverses all the elements on the stack (now it's !, N, U, from the top), and 'N and '! push more characters, meaning we end with the stack [U, N, !, N, !].
Side note: This is the first Aceto program written (in part) with the help of Aceto's new editor.

Perl 5, 31 bytes
-2 bytes thanks to @Dom Hastings.
30 bytes of code + -p flag.
/c/i;$_="!"x(y/UN!//%2).isC.$'

Try it online!
y/UN!// counts the number of occurrences of Un, Not, and !. The result is that many ! modulo 2, followed by isChecked().

Another attempt, based on regex, for 38 bytes (Dom Hastings saved 1 byte on that one):
s/isNot|isUn(c)/!is\u$1/?redo:s/!!//g

Try it online!

Your regex version doesn't work because there are two cs in Unchecked.

@Neil the regex only replaces the first one (since I'm not using /g flag). The test cases look good to me (cf the TryItOnline link). So I don't really see what you mean...

Sorry, the correct reason that your regex version doesn't work is that although there is a c in Unchecked there is also one in Checked, so when you subsitute it you end up with CheCked.

@Neil Indeed, that's right, I must be blind for not seeing it.. I added /i flag to correct this, thanks for pointing it out! :)

Hey, hope you're doing alright! I haven't been here in a while, but I've had a little play with these for -2 on the first and -1 on the second

@DomHastings Hey! Awesome, thanks a lot! Happy to see you back around :-)

C, 78 70 68 Bytes
Thank you Christoph!
c;f(char*s){for(c=1;*s;)c^=!!strchr("!NU",*s++);s="!isChecked()"+c;}

Try it online
Output:
isChecked() => isChecked()
isUnchecked() => !isChecked()
isNotChecked() => !isChecked()
!isNotChecked() => isChecked()
!!!isNotNotUnchecked() => isChecked()

c;f(char*s){for(c=1;*s;)c^=!!strchr("!NU",*s++);s="!isChecked()"+c;} using xor to flip c saves 2 byte.

Scala, 39 30 bytes
s=>"!"*(s.sum%2)+"isChecked()"

Try it online!
Unfortunately I couldn't get it to deduce the type of s.
Edit: Moved the type declaration to the header (I think this is allowed, if not I'll put it back).

Ruby, 40 bytes
->x{?!*(x.count('!UN')%2)+'isChecked()'}

Try it online!

Welcome to PPCG! Nice answer. :)

@MartinEnder thanks!

05AB1E, 22 bytes
…Unc„!C:'€–™'!:'!†„!!K

Try it online!

PHP (5.5 - 5.6), 52 50 49 Bytes
<?='!'[count(spliti('!|N',$argn))%2]?>isChecked()

Try it here.
-2 Bytes by @Titus. Ty :)
-1 Byte  by @ETHproductions. Ty :)

PHP (>=5.5), 66 65 61
for($b=b;$a=$argn[$i++];)$b^=$a;echo$b&"!"|" ","isChecked()";

Without regex it gets a bit more compex :) Try it here.
-4 Bytes by @Titus. Ty :)

error_reporting default value is E_ALL&~E_NOTICE&~E_STRICT&~E_DEPRECATED.

@Titus beating JS in a regex challenge yay!

$b^=$a Very nice find! You can also do that without the PHP tags at the same size.

61 bytes if leading whitespace is allowed: for($b=b;$a=$argn[$i++];)$b^=$a;echo$b&"!"|" ","isChecked()";

@Titus I have to admit that it was inspired by this answer.

Jelly,  16  15 bytes
OSḂ⁾!iṫ⁾sCø³ṫ-7

A full program that takes the string as a command line argument and prints the result
Try it online!
OSḂ⁾!iṫ-7³ṫṭ⁾sC or OSḂ⁾!iṫ-7³ṫ⁾sC; would both also work for 15.
How?
Uses the same idea as my Python answer, but saves bytes using a different construction of !isC or isC and some implicit printing in Jelly...
OSḂ⁾!iṫ⁾sCø³ṫ-7 - Main link: s
O               - cast to ordinals
 S              - sum
  Ḃ             - mod 2
   ⁾!i          - literal ['!','i']
      ṫ         - tail -> ['i'] if OSḂ was 0; ['!','i'] if OSḂ was 1
                - this is printed due to the following starting a new leading
                - constant chain. Printing smashes so either "i" or "!i" is printed.
       ⁾sC      - literal ['s','C']
                - this is printed (as "sC") due to the following niladic chain.
          ø     - start a new niladic chain
           ³    - program's first input (3rd command line argument), s
            ṫ-7 - tail from index -7 = ['h','e','c','k','e','d','(',')']
                - implicit print (of "hecked()")

previous @ 16 bytes 9 (using concatenation and pairing with the same underlying idea):
OSḂ⁾!iṫ;⁾sC,ṫ€-7

Ah, darn, I thought I was on to something with the mod 2 trick. Then I found this :P I had this for 18 bytes, maybe it could help: OS1&”!x;“isC”;ṫ-7$

05AB1E, 16 bytes
ÇOÉ'!×…isCyR8£RJ

Try it online!
Uses the trick of summing the ordinals from Jonathan Allan's python answer.
Explanation
 ÇO                # sum of ascii values of input
   É               # is odd
    '!×            # repeat "!" that many times
       …isC        # push the string "isC"
           IR8£R   # push the last 8 chars of input
                J  # join everything to string

Japt, 24 23 bytes
o"!N" l u)ç'! +`‰C”×B()

Explanation
 o"!N" l u)ç'! +`‰C”×B()
Uo"!N" l u)ç'! +`‰C”×B()`
Uo"!N"                     # Only keep "!", "n" and "N" from the input
           ç'!             # Repeat the string "!" by
       l u)                # the parity of the length of the newly formed string
               +`‰C”×B()` # and concatenate with the string "isChecked()"

Try it online!

Wait... How does... Why... Is o case-insensitive? I did not know that...

I didn't know it either, but I found out when I tested with "!NU". The lowercase "n" in "Unchecked" also remained, so I could drop the "U" : )

Mathematica, 82 61 60 Bytes
Small tweak, added one more infix operator:
"!"~Table~Mod[#~StringCount~{"o","n","!"},2]<>"isChecked()"&

Previously:
"!"~Table~Mod[StringCount[#,{"o","n","!"}],2]<>"isChecked()"&

Count up all the o's, n's and !'s then mod 2 and put that many ! in front.
Old version:
"!"~Table~Mod[StringCount[StringReplace[#,{{"o","n"}->"!"}],"!"],2]<>"isChecked()"&

sed, 37 38 bytes
:;s/is(Not|Un)/!is/;s/!!//;t;s/ch/Ch/

37 + 1 for -r switch:
sed -r ':;s/is(Not|Un)/!is/;s/!!//;t;s/ch/Ch/'

That last s/c/C/ caused problems for the Perl 5 answer...

Yeah, looks like the s/c/C/ is catching the second "c" in cases without "Un"

Also, you can save a byte by dropping the g and moving the s/!!// inside the loop.

You don't need the switch to get 37 bytes

Perl 6,  35  31 bytes
{'!'x m:g/<[!NU]>/%2~'isChecked()'}

Try it
{'!'x tr/!NU//%2~'isChecked()'}

Try it
(requires mutable input string which will be mutilated)
Expanded:
{
  #(
    '!'
  x               # string repeat

    # m:g/<[!NU]>/
    tr/!NU//      # find the number of negatives
      % 2         # modulus 2
  #)

  ~                # string concat

    'isChecked()'
}

Sed, 36 Bytes
Same idea as all the other direct substitution answers.
:
s/Unc/NotC/
s/isNot/!is/
s/!!//
t

Windows Batch, 120 bytes
Previously 268 257 253 245 239 221 182 176 169 123 bytes
@set a=%1
@set s=#%a:~,-2%
@set s=%s:!=N#%
@for %%a in (%s:N= %)do @set/ac+=5
@if %c:~-1%==0 cd|set/p=!
@echo isC%a:~-8%

The programs replaces all the ! into N#. Because now all negation signs, !(Now it is N#), Not, and Un contains N, the program can counts the number of appearance of N and determines if an leading ! is required.
Each time the program counts an N, the counter is added by 5. The reason for adding 5 is because each alternating values when adding 5 ends in either 0 or 5. This can be used to determine whether the value is odd or even and the leading ! us added if required.
In addition, xnor's last-eight-character trick is utilized.

One would think programming in windows batch would be impossible...

Of course...... Batch scripting is absurd....

Excel, 90 bytes
=IF(ISODD(SEARCH("C",SUBSTITUTE(SUBSTITUTE(A1,"Un","!"),"Not","!"))),"","!")&"isChecked()"

PHP, 55 Bytes
<?=preg_match_all("#!|N#i",$argn)&1?"!":""?>isChecked()

Try it online!
PHP, 58 Bytes
<?=preg_match_all("#[!NU]#",$argn)%2?"!":"","isChecked()";

instead "#[!NU]#" you can use "#[!N]#i"
Try it online!
PHP, 68 Bytes
Version without Regex

for(;$c=$argn[$i++];)$d^=!trim($c,"UN!");echo"!"[!$d],"isChecked()";

Try it online!

<?=preg_match_all("#[!UN]#",$argn)&1?"!":""?>isChecked() -2 bytes

Had exactly the same answer before I came up with count(split()) :D @Titus nice idea !

@Titus nice idea to leave PHP

66 Bytes without Regex. Can you beat it ? :)

" !"[$d&1] saves another byte if leading whitespace is ok. $d^=!trim($c,"UN!") saves 3 bytes (because you need no &1 anymore).

@Titus Yes one example more that you have more knowledge then myself. Thank You and for the trailing whitespace problem I have make "!"[!$d] instead

@JörgHülsermann I'm pretty sure that if you use a closing tag ?>  you need the opening tag <?. Anyway updated to a 65 byte version :)

@Christoph you are right I have forget it sorry about that

Jelly, 29 28 25 21 bytes
f“NU!”LḂ”!x;“µịÆẹṠƊẹ»

Try it online!
f“NU!”LḂ”!x;“µịÆẹṠƊẹ»  Main link, argument is z
f“NU!”                 Filter to only keep "NU!"
      LḂ”!x            Repeat exclamation mark by the parity of the length
           ;“µịÆẹṠƊẹ»  Concatenate to "isChecked()"

-4 bytes thanks to Jonathan Allan!
-4 bytes thanks to Jonathan Allan!  (by using compressed strings)

Save the interface Lynn made here as a module (say jellyCompress.py), then that would have been formed with jellyCompress.Compress().string("is").dictionary("Checked").string("()").go(). (If you're running in a Windows  cmd install and switch to the font DejaVu Sans Mono and change the codepage with the command chcp 65001 before launching Python to get the characters to display)

@JonathanAllan Oh okay. Thanks!

Japt, 19 bytes
`‰C”×B()`i'!pU¬xc u

Try it online!
Unpacked & How it works
`‰C”×B()`i'!pUq xc u

`‰C”×B()`   Compressed string for "isChecked()"
i     Insert the following string at the beginning...
'!p     "!" repeated the following number of times...
Uq        Split the input into chars
xc        Sum the charcodes
u         Modulo 2

Using the charcode-sum trick from Jonathan Allan's Python solution.

Pascal (FPC), 119 bytes
var s:string;j:word;c:char;begin read(s);for c in s do j:=j+ord(c);if 1=j mod 2then write('!');write('isChecked()')end.

Try it online!
Using method that almost every answer does, summing codepoints of characters in the input, then checking parity of the sum.

ReRegex, 32 bytes
/!!//Not/!/Unc/!C/is!/!is/#input

Explained
Works like the Retina answer
/!!//                            #Remove all !! pairs
     Not/!/                      #Replace all Nots with !s
           Unc/!C/               #Replace any Unc's with !C (Turning Unchecked into !Checked)
                  is!/!is/       #Float all !'s past the is to the left
                          #input #Take the stdin as input

Try it online!


text:
Make me a square!
Task
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 code-golf. Shortest answer in bytes wins.
Leaderboard
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 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 = '
' + c.body.replace(OVERRIDE_REG, '') + '
';
    });

    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 (/ 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;
}

<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

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

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 it's a bad practise to downvote challenges just because you dont like them, please delete your downvote. For you finding it easy, it is about having as little as possible bytes and i don't think that is really easy.

@Ayoungcoder It is a perfectly valid reason to downvote a challenge.

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

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.

Charcoal, 5 3 bytes
Ｂ³Ｓ

Try it online! Edit: Saved 40% thanks to @carusocomputing. Explanation:
Ｂ   Draw a box
³   3×3 (second dimension is implicit if omitted)
Ｓ   Using the input character

I feel like this is cheating...>_>

Then, of course, Ｂ³Ｓ to cheat the living crap outta this.

Why would this be cheating? @carusocomputing and neil his anwser seems right to me

@Ayoungcoder "cheating" as in "seems cheap" not as in "literal cheating"; the code has a built-in for "print a box of dimensions n using character s", the shortest code for this challenge being: 1. Read input. 2. Define dimension. 3. Print box. The answer to this challenge logically won't be below 2 bytes if input is implicit.

@carusocomputing sorry, didnt know :), should it count this as caros' answer or Neil's answer :)

@carusocomputing Ah, the irony - the implicit square behaviour annoyed me in my answer to Visualize the Euclidean algorithm again.

@Ayoungcoder it's his answer :P. Crediting the -2 bytes I saved is the standard, nobody takes someone else's answer over by improving it.

@Ayoungcoder Although this is probably the shortest possible answer, I wouldn't accept it too soon to avoid putting prospective answerers off

@BetaDecay im keeping it like this to thanks neil and caros, i will give it to someone else when they have a shorter one.

inputting longer strings like abcdefgh also gives a fun output

Damnit! I swore I'd remember to try Charcoal at the next opportunity after seeing this - guess I forgot to remember!

@BetaDecay unless there exists a language that implicitly combines two of the 3 steps I previously mentioned, it's not possible to get a shorter answer; I don't know of any languages with "print 3x3 box of" or "3x3 shape using character x" and "in the shape of a box". Though, I agree, it is still possible to tie.

I wonder if Charcoal would benefit from a stack based approach. If it's too different, maybe I could add dialects (Charstick (?) for stack-based memory, and Charbequeue for queue-based memory maybe)

Carrot, 11 bytes
###
# #
###

Try it online!
The program is in caret-mode, where #s are replaced with the input.

The feeling when a program which looks completely invalid at first is actually perfectly valid.

@EriktheOutgolfer ever heard of Perl?

@EriktheOutgolfer ever heard of Brainfuck?

Python 2, 32 bytes
lambda s:s+s.join(s+'\n \n'+s)+s

Try it online!
For s='a' : the middle s+'\n \n'+s generates a\n \na and s.join turns it in aa\na a\naa (bold as are the ones that .join adds), because .join accepts a string as an iterable, then it is surrounded with the two missing characters

How does this add the characters to the middle line? Could you explain the answer please?

@Notts90 added an explanation c:

thanks I didn't know .join could iterate a string.

This works in Python 3 too. Very cool BTW. (Also, using the same method 3*c+c.join('\n \n')+3*c ties at 32.)

MATL, 5 bytes
3Y6*c

Try it online!
Explanation
3Y6   % Push predefined literal: [true true true; true false true; true true true]
*     % Implicitly input a character. Multiply element-wise by its code point
c     % Convert to char. Implicitly display. Char 0 is displayed as space

that was quick! didnt expect a 5 byte to come that fast.

Code-golfing languages, you know... ¯\(ツ)/¯

Of course, because why wouldn't you have a predefined literal for [true true true; true false true; true true true]

@PunPun1000 That's actually used a lot (together with convolution) as it's the standard 8-connectivity mask (Moore neighboorhood)

@LuisMendo That's awesome, learn something new on here every day, not always about code golfing

05AB1E, 8 bytes
4×ð«û3ô»

Try it online!
INPUT    # ['R']                 | Implicit Input: 'R'
---------#-----------------------+-------------------------------
4×       # ['RRRR']              | Repeat string 4 times.
  ð      # ['RRRR',' ']          | Push space onto top of stack.
   «     # ['RRRR ']             | Concatenate last 2 items.
    û    # ['RRRR RRRR']         | Palindromize.
     3ô  # [['RRR','R R','RRR']] | Split into 3 pieces.
       » # ['RRR\nR R\nRRR']     | Join with newlines
---------#-----------------------+-------------------------------
OUTPUT   # RRR                   | Implicitly print the top
         # R R                   | of the stack on exit.
         # RRR                   |

Original idea using 30 as a binary number (unfinished, someone else try this in another lang):
05AB1E, 12 bytes
30bûTIð«‡3ô»

Try it online!

You have been outgolfed.

Python 3.6, 33 bytes
lambda c:f'{3*c}\n{c} {c}\n{3*c}'

Try it online!

No problem. It looks like it's actually 3.6.1 being run; if you try import sys and then sys.version in the repl, it returns 3.6.1 rather than 3.5.2. No idea why it says 3.5.2 at the top then, seems like they have made a mistake there!

Oh, haha, a case of "don't always believe what you read" - thanks!

RPL (Reverse Polish Lisp), 60 characters
→STR 1 4 START DUP NEXT " " + SWAP + 4 ROLLD + + SWAP 2 PICK

(Note that "→" is a single character on the HP48 and compatible calculators)
Would visually represent what you want by having three items on the stack:
3.: "###"
2.: "# #"
1.: "###"

If you insist to return it as one string, one has to add the newline characters as well and combine the strings, left as exercise to the next tester.

Explanation:

→STR: Make the last object in the stack into a string. (So the input can be anything, e.g. a number.)
1 4: Push the number 1 and 4 to the stack.
START [...] NEXT: Like a for loop but without access to the counter variable. Takes two numbers from the stack (here, we just have pushed 1 and 4) and executes the code [...] the corresponding times (here, four times).
DUP: Duplicate the last entry in the stack.
" ": Push the string  (i.e. the string with one whitespace) to the stack.
+: Take two objects from the stack and return them added together, for strings: Concatenated.
4: Push the number 4 to the stack.
ROLLD: Takes the last element (here: 4 that we just have pushed) from the stack and rolls the next element as far down the stack as the number we just took from the stack specifies.
SWAP: Swaps the two last stack elements.
2: Push 2 to the stack.
PICK: Takes an element (here: The 2 we just pushed to the stack), interprets it as a number n, and copies the nth element from the stack.

JavaScript, 28 bytes
c=>c+c+c+`
${c} ${c}
`+c+c+c

Try it

f=
c=>c+c+c+`
${c} ${c}
`+c+c+c
o.innerText=f(i.value="#")
i.oninput=_=>o.innerText=f(i.value)
<input id=i maxlength=1>

I think you might be able to save a byte or two by storing the result of c+'\n'+c in a temporary.

Never mind, I miscounted, it's still 28 bytes.

@Neil: Yeah, there are a couple of options for assigning stuff to a variable,  but they all come in at 28 bytes or more.

Jelly, 8 bytes
1 byte thanks to Erik the Outgolfer.
x4,`Ks3Y

Try it online!

I was wondering how to do this... I had x4µ©;⁶;®œs3Y for 12 bytes because I couldn't figure out how to avoid having the repetition multiply my entire intermediate step but nice!

You know, there's a builtin K for doing j⁶. Oh, and there's a quick, ```, to convert a dyad to a monad by using the same argument on both sides.

sed, 28 18  bytes
s:.:&&&\n& &\n&&&:

Try it online!

this new one doesnt work, the old one did edit: it does but you forgot the : in the anwser

@Ayoungcoder Sorry, mis-pasted the final :. Fixed.

the try it online should be [Try it online!]: https://tio.run/nexus/sed#@19spWelpqYWk6emACLU1Kz@/0/i@pdfUJKZn1f8X7cIAA "sed – TIO Nexus"

@Ayoungcoder Of course, thanks.

Brain-Flak, 76 70 + 1 = 71 bytes
Requires the -c flag
(((((((({})))<((([])[]{}<>)<>)>)<(<>({})({}){}()()<>)>)<([]()()())>)))

Try it online!

You can save 6 bytes if you replace (()()()()()){} with ([])[]{}.

Some competition :)

Java 7, 56 55 bytes
-1 Thanks to  Leaky Nun for pointing out the space I missed
String a(char s){return"...\n. .\n...".replace('.',s);}

Simply replaces the periods with the given character, for input #:
...       ###
. .  =>   # #
...       ###

Try it online!

PHP, 32 Bytes
<?=strtr("000
0 0
000",0,$argn);

Try it online!

Quite interestingly <?=$a=$argn,"$a$a\n$a $a\n$a$a$a"; (real line break instead of \n of course) has exactly the same byte count.

@Christoph make it as your approach. i have not try this alternative way

Pyth, 7 bytes
jc3.[9d

Try this online.
Explanation:
jc3.[9d Expects quoted input.
  3     3
     9  9
      d ' '
        Q (eval'd input) as implicit argument
   .[   Pad B on both sides with C until its length is a multiple of A
 c      Split B to chunks of length A, last chunk may be shorter
j       Join A on newlines

05AB1E, 7 6 bytes
-1 byte thanks to carusocomputing.
Ð¶¹ðJû

Explanation:
         # Implicit input                  # ['R']
 Ð       # Repeat string three times       # ['R', 'R', 'R']
  ¶      # Push newline character          # ['R', 'R', 'R', '\n']
   ¹     # Push first input                # ['R', 'R', 'R', '\n', 'R']
    ð    # Push space                      # ['R', 'R', 'R', '\n', 'R', ' ']
     J   # Join stack                      # ['RRR\nR ']
      û  # Palindromize ("abc" -> "abcba") # ['RRR\nR R\nRRR']
         # Implicit output                 # []

Uses the CP-1252 encoding. Try it online!

Oooo... Smart, I never think about how palindromize works on newlines.

Ð¶¹ðJû for 6 bytes.

Brain-Flak, 61, 59 bytes
(((((((({})))<([][][]())>)<(([][][]()){})>)<([]()()())>)))

Try it online!
This is 58 bytes of code +1 byte for the -c flag which enables ASCII input and output.
Explanation:
(((
   (
    (
     (

      #Duplicate the input 3 times
      ((({})))

#Push 10 (newline)
<([][][]())>

     #Push the input again
     )

#Push 32 (space)
<(([][][]()){})>

    #Push the input again
    )

#Push 10 (newline)
<([]()()())>)

#Push input 3 times
)))

C (gcc), 49 47 bytes
Saved 2 bytes thanks to 2501!
j;f(i){for(j=12;j;)putchar(--j%4?j-6?i:32:10);}

Try it online! has a trailing newline

You can save two bytes by doing: for(j=11;j;)...

Python 3, 34 bytes
lambda s:s*3+"\n"+s+" "+s+"\n"+s*3

Try it online!

-1 byte: lambda x:x*3+'\n%s '%x+x+'\n'+x*3

Octave, 36 bytes
x=repmat(input(0),3);x(5)=32;disp(x)

Try it online!
Explanation
This creates a 3x3 char matrix with the input char repeated, and sets its 5th entry in column-major order (i.e. its center) to 32 (ASCII for space).

Pyke, 5 bytes
dQA.X

Try it online!

Ruby, 27 25 bytes
Saved 2 bytes thanks to  Level River St
->x{[s=x*3,x+" "+x,s]*$/}

Try it online!

when you are doing anwsers like this, please also include the footer as code because it does not work without

@Ayoungcoder this is an anonymous function. you can assign it to a variable (f=...) then call it with f.call(...)

You can use a literal newline inside quotes instead of "\n" for a saving of 1 byte . Even better use $/ which is a special variable set to newline by default - saving 2 bytes.

1 byte less than the tr solution. nice work

Brainfuck, 40 bytes
+++++[->++<<++++++>],...>.<.<++.>.>.<...

Try it online! Requires an implementation that can access left of the starting position.
Also see: Graviton's brainfuck answer which takes a different approach (but is longer).

Explanation:
Brainfuck can do a lot of cool tricks with its limited instruction set. Unfortunately, this answer doesn't use any of them, because it's cheaper (in terms of bytes) to just hardcode everything.
+++++[->++<<++++++>]                         Sets the cells to |5*6|>0<|5*2|
,                   Takes input character into the middle cell | 30|>#<| 10|
...                                Print the top of the square | 30|>#<| 10| ###
>.                                   Print a newline character | 30| # |>10|    \n
<.                               Print another input character | 30|>#<| 10| #
<++.                  Add 30+2 for a space character and print |>32| # | 10|  _
>.                   And just print the 5 remaining characters | 32|>#<| 10|   #
>.                                                             | 32| # |>10|    \n
<...                                                           | 32|>#<| 10| ###

# = input character, _ = space (ASCII 32), \n = newline (ASCII 10)

Results in this beautiful box (for input '+'):
+++
+ +
+++

Vim, 9 keystrokes
Assuming the input char is present in a buffer, vim makes this straightforward
x3pY2plr<space>

There is probably some magic vim commands of use here (there always seem to be some) so improvement suggestions are welcome. Only one keystroke behind V!

I'm pretty sure this is as short as it can get. Nice answer!

Pyth, 11 bytes
jc++K*z4dK3

Try it online!
Explanation:
jc++K*z4dK3    expects a single char as input

j              joins on new line
 c        3    chops array into 3 sized pieces
  +            joins +K*z4d and K
   +           joins K*z4 and d
    K          initialize variable K as *z4
     *z4       duplicate the input 4 times
        d      variable initialized to string " "
         K     calls variable K, in this case *z4

Welcome to PPCG!

AWK, 28 26 25 bytes
$0=$0$0$0RS$0FS$0RS$0$0$0

Try it online!

StupidStackLanguage, 28 bytes
jfffavvflflqvvvviifblflflfff

Try it online!
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 :)

><>, 24 23 bytes
i:o:o:oao:o84*o:a0!.<o$

Try it online!

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

V, 8 bytes
x3p2Ùlr

Try it online!

V has a (undocumented?) <M-h>ollow command that lets you hollow out the inside of your box:  Try it online!

J-uby, 22 20 bytes
-2 bytes thanks to @Jordan

:tr&"...
. .
..."&?.

Explanation
String#tr is Ruby's character-wise replace method. The first & binds :tr to "...\n. .\n...", and the second partially applies '.' to it. Effectively, this is ->s{"...\n. .\n...".tr('.',s)}

Would :tr work as well as :gsub here?

@Jordan yes, thanks!

C#,50 bytes
a=>Console.Write(a+a+a+"\n"+a+" "+a+"\n"+a+a+a);

Test Case:
var f = new Action<string>(
a=>Console.Write(a+a+a+"\n"+a+" "+a+"\n"+a+a+a);
);
f("#");

You need to fully qualify the Console i.e. System.Console..

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.

Z80 or 8080 Assembly, 21 bytes machine code
Assume a memory mapped I/O device:

              Z80                  8080
3A xx xx    ld  a, (input)      lda  input       ; get input character
11 0A 20    ld  de, 200ah       lxi  d, 200ah   ; space & newline
21 yy yy    ld  hl, output      lxi  h, output  ; get output address
77          ld  (hl), a         mov  m, a       ; output character * 3
77          ld  (hl), a         mov  m, a
77          ld  (hl), a         mov  m, a
73          ld  (hl), e         mov  m, e       ; output newline
77          ld  (hl), a         mov  m, a       ; output character
72          ld  (hl), d         mov  m, d       ; output space
77          ld  (hl), a         mov  m, a       ; output character
73          ld  (hl), e         mov  m, e       ; output newline
77          ld  (hl), a         mov  m, a       ; output character * 3
77          ld  (hl), a         mov  m, a
77          ld  (hl), a         mov  m, a
76          halt                hlt             ; or C9 ret

No interpreter needed!
Hexdump:
0000: 3A 00 FF 11 0A 20 21 01 FF 77 77 77 73 77 72 77
0010: 73 77 77 77 76
where the input address is at FF00h and the output address is mapped at FF01h. The actual addresses will depend on the actual hardware. Of course this assumes the I/O is memory mapped. If it is I/O mapped, it would take several extra bytes because Z80 & 8080 I/O instructions are two bytes each. This also assumes the output device interprets 0Ah as a newline and doesn't require a CR (0Dh) which would add an extra 4 bytes to the program.

Welcome to Codegolf.stackexchange, while it seems that you have everything under control please do read the help center and the list of faqs. Good first post

Can you provide a hexdump of your code?

The hex bytes are in the first column, but if you want a "pure" hexdump, I've added it.

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

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

@KevinCruijssen Thanks, I was trying to use compressed integers but it wasn't getting the 0 at the start.

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

Python 3, 31 bytes
lambda s:3*s+f'\n{s} {s}\n'+3*s

Try it online!

MAWP, 29 bytes
|!;!;!;25W;!;84W;!;25W;!;!;;.

Try it!
-6 bytes from Dion's straightformard solution.
MAWP, 35 bytes
%|7[1A~!~]////25W//84W//25W////~[;]

Manually shifting the stack was more practical than trying to loop through it and make a box.
Try it!

Is this even golfed??

...Ok, I take it back.

Doesn't something so straightforward like this work..?

What was I thinking when I made this?!

Swift3, 50 bytes
[1,2,3].map{$0==2 ? print(c+" "+c) : print(c+c+c)}

This uses the ternary operator to print different strings, depending on the row.
Try it online

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

C#, 74 71 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.

You need to fully qualify the Console

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

MATL, 8 bytes
4Y"0yv3e

Unlike my other MATL answer, this builds the output manually, without using any predefined literal.
Try it at MATL Online!
Explanation
Consider input '^' as an example.
      % Implicitly input one char.
4Y"   % Repeat 4 times. Gives a string.     STACK: '^^^^'
0     % Push 0. Char 0 is shown as space.   STACK: '^^^^', 0
y     % Duplicate from below.               STACK: '^^^^', 0, '^^^^'
v     % Concatenate everything vertically.  STACK: ['^';'^';'^';'^';0'^';'^';'^';'^';'^']
3e    % Reshape into a 3-row char matrix.   STACK: ['^^^';'^ ^';'^^^']
      % Implicitly display.

><>, 19 bytes
i:o:o:oao:$o" "|;o~

Try it online!

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.

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

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

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

using 1 in place of "y" saves 2 more bytes.

///, 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!

Javascript (ES6), 32 bytes
i=>`###
# #
###`.replace(/#/g,i)

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!
Try it online! and also Watch the interpeter!

Japt, 11 9 bytes
³+R+U+S ê

Saved 2 bytes thanks to obarakon.

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 ³

Aha, hadn't spotted that. Thanks again, @obarakon.

Syms, 21 bytes
{}<[[[++~[{& &}~[>~>>

Try it online!

oops, didnt allow trailing [] but never specified it, lucky ig guess :)

Um why is -i on

QBIC, 23 20 bytes
Brute-forcing this is shorter than fancy string-flips...
?;+A+A?A+@ `+A?A+A+A

Original answer:
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$

K (oK), 8 bytes
Solution:
3 3#5$4#

Try it online!
Example:
> 3 3#5$4#"@"
("@@@"
 "@ @"
 "@@@")

Explanation:
Evaluated right-to-left. Build 'AAAA', then 'AAAA ' and then shape into the 3x3 grid required.
3 3#5$4# / the solution
      4# / take 4 of whatever is to the right
    5$   / right pad with whitespace to length 5
3 3#     / shape into 3x3 grid

Bonus:
The solution is a polyglot for q/kdb+:
q)3 3#5$4#"*"
"***"
"* *"
"***"

cool way of doing it

Perl 5, 23 + 1 (-p) = 24 bytes
The brute force way seems to be the shortest.
$_.="$_$_
$_ $_
$_$_$_"

Try it online!

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$s$s';

Try it online!

Acc!!, 58 bytes
N
Count i while 11-i {
Write _+i%4/3*(10-_)+i%6/5*(32-_)
}

Try it online!
How?
Let's lay out the desired output in a line, substituting _ for the newlines, and look at patterns and indices.
###_# #_###
01234567890

We need newlines at indices 3 and 7, a space at index 5, and the input character at all other indices. To put it a different way, for index i, we want newline when i%4 == 3, space when i%6 == 5*, and the input character otherwise.
So, after reading the input character into the accumulator with N, we run a Count loop from 0 up to but not including 11. Iff i%4 is 3, i%4/3 is 1, and we output _+(10-_) i.e. 10 i.e. newline. Iff i%6 is 5, i%6/5 is 1, and we output _+(32-_) i.e. 32 i.e. space. Otherwise, we output _ i.e. the accumulator value i.e. the input character. Fortunately, the two modulo cases are never true at the same time; this would happen at index 11, but we stop at index 10.

* The modulo operation would seem unnecessary here, but (as far as I can tell) it is the shortest way to test i == 5 in Acc!!, which doesn't have a comparison operator.

W d n, 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

W d, 13 11 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

Keg, 11 bytes
???
? ?
???

It really just replaces the ?s with the input!
Alterate 11 byter
¿3*:&
? ?
&

Neither program works on TIO

Because Keg needs a pull on TIO

@JoKing Dennis is not very active this week. He didn't get the latest interpreter on TIO yet.

@JoKing TIO is 19 commits behind the Keg repo

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

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.

GolfScript, 13 bytes
4*.' '\++3/n*

Try it online!
Explanation
              # input #
4*            # ["####"]
  .           # ["####","####"]
   ' '        # ["####","####"," "]
      \       # ["####"," ","####"]
       ++     # ["#### ####"]
         3/   # [["###" "# #" "###"]]
           n* # [["###\n# #\n###"]]

Husk, 6 bytes
Husk is way easier to use than Pyth.
C3w½*8

Try it online!
Explanation
    *8 Repeat the input 8 times. "!" -> "!!!!!!!!"
   ½   Halve the input. "!!!!!!!!" -> ["!!!!","!!!!"]
  w    Join with spaces. ["!!!!","!!!!"] -> "!!!! !!!!"
C3     Split into chunks of 3. ["!!!","! !","!!!"]

Husk automatically outputs lists joined with newlines

J, 12 9 bytes
3 3$4j1#]

Try it online!
-3 thanks to FrownyFrog

3 3$4j1#] for 9

That is quite nice.  I had long forgotten about that complex trick, if I ever knew it.

1+, 40 38 bytes
,";";";(|11+""*")++";^";()**;";^;";";;

Longer than I thought. Ungolfed, but it's a start.

Poetic, 208 bytes
BOX,OR SQUARE
i was creating a side,i built a box
i looked,it was four-sided
i am somewhat weirdly earnest,however,about n*n squares having a"no-holes-in-a-drawing"shape
i am trying to produce regular squares

Try it online!

K (ngn/k), 34 bytes
{`0:x,x,x,"\n",x," ",x,"\n",x,x,x}

Try it online!
The straightforward (although long) answer.

Vyxal j, 40 bitsv2, 5 bytes
4*ð+∞²

Try it Online!
Bitstring:
0100101010111010101000100000000000001010

optimal encoding for a 6 byter

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

Retina, 21 bytes
.
$&$&$&¶$& $&¶$&$&$&

Try it online!

It's shorter to match $ and insert $_ or `$`` (saving two bytes)

Befunge, 26 bytes
~:::25*\:84*\:25*\::>:#,_@

Try it online!
Explanation
~::          Take input and put bottom row in stack (: is duplicate)
:25*\:84*\   Create second row (25* is 10 or newline, 84* is 32 or space)
:25*\::      Create top row
>:#,_@       Print out stack until the stack is empty

the \ after the numbers is to switch the stack around since you need the input on
top of the stack to duplicate it

bash, 43 38 bytes
read -sN1 x
echo "$x$x$x
$x $x
$x$x$x"

Scala, 23 bytes
a=>a*3+s"\n$a $a\n"+a*3

Accepts and returns a String. The s before a string literal allows you to use $-prefixed variables in it, or even ${expressions}. * repeats a String, like in Python.
Try it online!

VBScript, 72 bytes
n=chr(10):msgbox replace("###"&n&"# #"&n&"###","#",wscript.arguments(0))

VBScript sucks ;-)

Foo, 40 bytes
&<character as ascii value>&3(-1<$c>)$c13<$c$c32$c$c13>&3(-1<$c>)

As Foo cannot take input, you should replace <character as ascii value> with the ASCII value of the character.
Try it online!

Common Lisp, SBCL, 50 bytes
(format t"~@?
~a ~:*~a
~@*~@?""~3@{~a~:*~}"(read))

Explanation
format              ;printing function
~@?                 ;execute format string given as argument
~a ~:*~a            ;print current argument (will be result of (read))
                    ;then print space, go back one argument (to again use
                    ;result of (read) and print it
~@*~@?              ;go back to first argument, then execute format string
                    ;given as this argument
"~3@{~a~:*~}"       ;loop three times printing argument number 2
                    ;~:* makes it keep going back to argument number 2
(read)              ;take input

Ideas for improvement are welcomed.

Swift, 54 bytes
var s=readLine()!,a=s+s+s+"\n";print(a+s+" "+s+"\n"+a)

Sinclair ZX80/ZX81 (without sanity check), ~55 Bytes (listing)
 1 INPUT A$
 2 PRINT A$;A$;A$
 3 PRINT A$;" ";A$
 4 PRINT A$;A$;A$

With sanity check (ZX80 with 8K ROM or ZX81)
 1 INPUT A$
 2 IF NOT LEN A$ OR LEN A$>1 THEN GOTO 1
 3 PRINT A$;A$;A$
 4 PRINT A$;" ";A$
 5 PRINT A$;A$;A$

Line two of the latter version makes sure that there is a single character entered. So in the first example, it is possible to enter nothing and simply press NEW LINE.

This would use 52 bytes of program memory.

So my approximation is broadly correct? I keep forgetting to POKE the memory to see how much actual RAMs my ZX80/81 programs take up; it also depends on the ROM used in the ZX80. If it's the 'old ROM' then each numeric variable is a 16-bit signed integer only, taking two bytes, whereas with the 8K ROM upgrade that becomes a floating point number of 5 bytes in memories total.

Ah, well fortunately your program contains no numbers (at least, not the short version, which is what I counted). Also, I hope you PEEK to find out the actual usage, which would be PRINT PEEK 16396 + 256 * PEEK 16397 - 16509.

Thanks for this. I was making a general point about all of my ZX80/ZX81 entries rather than something specific about this listing

I'm just amazed that you have a ZX80 with the 8K ROM upgrade. (I'm just marginally too young for that, having started with the ZX81.)

Well, of sorts; I have a Minstrel clone that you can buy which has a 4K/8K ROM. I have lots of ZX81s in various states and a Commodore PET (3032) as well as a VIC/VC 20, C64, C128, +4 etc... I used to write about this stuff for Micro Mart magazine and others but now I'm a software developer I thought it best to make software for these old machines. I currently have a Commodore PET game and some ZX80/ZX81 games ready to be released by Monument Microgames. I'll also be making some VIC-20 and C16 stuff soon.

Our first 'home computer' was the Texas TI99/4a which I think pre-dates the ZX80 even.

Let us continue this discussion in chat.

PowerShell, 26 Bytes
param($c)$c*3;"$c $c";$c*3

takes a char/length 1 string - then prints it 3 times, it twice with a separating space, and it 3 times again.

braingasm, 18 bytes
,...10..32..10....

Yeah... read a byte, print it three times, then print a newline (10), then the byte again, then a space (32), that byte again, another newline and that byte three more times...

Haskell, 45 44 bytes
-1 byte thanks to Laikoni
Naive approach
f s=putStrLn$s:s:s:'\n':s:' ':s:'\n':s:s:[s]

For some reason
f s=putStr$s:s:s:'\n':s:' ':s:'\n':s:s:[s]

won't output the last line on repl.it, but if it's still valid it shaves off 2 bits for a total of 42
And
f s=print$s:s:s:'\n':s:' ':s:'\n':s:s:[s]

will print the answer as "sss\ns s\nsss" instead of properly linebreaking. If that's valid it shaves off 3 bits for a total of 41
There is a solution with replace that's 42 bits long ... but that's without counting the bytes needed to import the necessary module. For reference:
import Data.String.Utils
f s=putStrLn$replace "." s "...\n. .\n..."

You can shorten s:[] to [s].

Ruby, 23+1 = 24 bytes
Uses the -n flag for +1 byte.
puts$_*3,$_+' '+$_,$_*3

Try it online!

OCaml, 53 bytes
let f c=String.map(function '#'->c|c->c)"###
# #
###"

It's pretty bad. OCaml does not even have a replace function
Bash, 26 bytes
echo "$1$1$1
$1 $1
$1$1$1"

5 bytes less boring

Suggestion: Post you OCaml answer and Bash answers separately.

Excel VBA, 27 Bytes
Anonymous VBE immediate window function that takes input from cell [A1] on the Application.ActiveSheet object and outputs a 'square' to the VBE immediate window.
a=[A1]:?a;a;a:?a" "a:?a;a;a

Python 2, 34 bytes
lambda n:3*n+'\n'+n+" "+n+'\n'+3*n

Try it online!

UGL, 23 Bytes
j"\n"++l*I3l++i" "il*i3

try it online (write the code to stdin. you can also use the link at the top of the answer to try online, that accepts ctrl+v)
Equivalent Python code:
cur_inp = ""
def inp():
    global cur_inp
    cur_inp = input()
    return cur_inp
"\n".join([inp*3]+[cur_inp+" "+cur_inp]+[cur_inp*3])

Using Python's string multiplication.

Burlesque, 20 bytes
3.*3.*{1 1}' D!)\[un

Try it online!
3.*       # Make a list of 3 instances     {A A A}
3.*       # Again                          {{A A A} {A A A} {A A A}}
{1 1}' D! # Set value at 1,1 to a space    {{A A A} {A   A} {A A A}}
)\[       # Concatenate each internal list {"AAA" "A A" "AAA"}
un        # Join array with newlines

Burlesque, 23 bytes
495b2"1"x/r~'0' r~3coun

Try it online!
Just for a bit of variety
495b2   # Read the number 495 as binary (111101111)
"1"x/r~ # Replace 1s with input char
'0' r~  # Replace 0 with space
3co     # Chunks of 3
un      # Separate by newlines

APL (Dyalog Extended), 15 bytes
(' ',⍞)[⊤7 5 7]

Try it online!
Indexes into a binary matrix.
Requires ⎕IO←0(0-indexing)

Vyxal, 7 bytes
D¶?ðWṅ∞

Try it Online!
Using the canvas builtin is the same byte count:
Vyxal, 7 bytes
3»«₁»ø∧

Try it Online!

Gema, 22 characters
*=*$0$0\n$0 $0\n$0$0$0

(Frustratingly inefficient. In Gema the * (and ?) have order numbers, so in ***=*** each * on right side matches the * on left side with same order number. ☹)
Sample run:
bash-5.2$ echo -n 'M' | gema '*=*$0$0\n$0 $0\n$0$0$0'
MMM
M M
MMM

Try it online!

AWK, 24 bytes
sub(/./,"&&&\n& &\n&&&")

Attempt This Online! or try some more test cases.
This is one byte shorter than $0=$0$0$0RS$0FS$0RS$0$0$0.
This is basically regex substitution that takes one char and puts it into the box shape. sub without the 3rd argument takes and modifies $0 in-place. Since the substitution always succeeds, the sub call evaluates to true and the modified $0 is printed (the default action).
sub($0,...) doesn't work because some chars don't form a valid regex, such as [.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Perform gravity sort
Challenge
Given a list of integers, show how gravity sort would be done.
Gravity Sort
In gravity sort, imagine the numbers as rows of asterisks. Then, everything falls, and the new rows will be obviously sorted. Let's look at an example:
[2, 7, 4, 6]:
**
*******
****
******
-------
**
****
*******
******
-------
**      | 2
****    | 4
******  | 6
******* | 7

Notice that this is pretty much just parallelized bubble sort.
Exact Specs
On each iteration, starting from the top row, take every asterisk from the row that doesn't have an asterisk below it, and move it down a row. Keep doing that until the list is sorted.
Input
Input will be a list of strictly positive integers.
Output
For the output, you must output each step. You can choose any two non-whitespace printable ASCII characters, one to be the "asterisks", and one to be the separating "dashes". The rows of asterisks must be separated with a standard newline of some sort (e.g. \n or \r\f). The row of dashes must be at least the width of the widest row (otherwise your asterisks are going to fall too far down!). A row of dashes at the very bottom is optional. A trailing newline at the end is permitted. Trailing spaces on each line are permitted.
Test Cases
input will be represented as a list, then output will be listed immediately below. Test cases are separated by a double-newline.
[4, 3, 2, 1]
****
***
**
*
----
***
** *
* *
**
----
**
* *
** *
***
----
*
**
***
****

[6, 4, 2, 5, 3, 1]
******
****
**
*****
***
*
------
****
**  **
****
***
*  **
***
------
**
****
*** **
*  *
***
*****
------
**
***
*  *
*** **
****
*****
------
**
*
***
****
******
*****
------
*
**
***
****
*****
******

[8, 4, 2, 1]
********
****
**
*
--------
****
**  ****
* **
**
--------
**
* **
**  ****
****
--------
*
**
****
********

[2, 7, 4, 6]
**
*******
****
******
-------
**
****
*******
******
-------
**
****
******
*******

Please feel free to correct my test cases if they're wrong, I made them by hand :)
Note: Do not output the sorted list at the end. :)
Scoring
All of your programs will be written on top of each other. You wouldn't want pieces of your program to fall down, so make sure you have the shortest code!

Can we avoid printing dashes? and Instead of printing asterisks can we print matrix of 0s and 1s?I think format of printing  adds nothing to the challenge.

@rahnema1 1. You may replace the dashes with some other non-whitespace character 2. No.

I believe you are missing an asterisk on the 2nd iteration of your last test case

@MistahFiggins Ah, yes. Thanks!

If we don't want pieces of the program to fall down, does this mean that we can't have longer lines of code on top of our shorter lines of code? :o

@ValueInk lol It doesn't really work because your code will get mixed in with other code falling onto your line. :P

@ValueInk that's actually a decent idea for a restricted-source challenge, though maybe only for 2D languages. (too easy with line continuation in most langs)

Hey that's how I sort my books!

I don't suppose we could include a leading or trailing line of -s, could we?

@Shaggy If I were to make this challenge now, I'd considering allow that for output flexibility but I'm going to say no in the interest of consistency, sorry.

No worries; figured that'd be the case but it never hurts to ask :) Thanks for the fun challenge - can't remember the last time I spent this long on a solution.

Just realised that my solution is invalid 'cause I only tested it against the test cases which can all be sorted in exactly length steps which, going by the worked example, is obviously erroneous. So, firstly, I'd suggest adding the example as a test case. And, secondly, if the sort can't be done in less than length steps (not sure on that one), adding a test case to cover that.

@Shaggy Ah, I didn't even notice that. Thanks! Also I don't believe it's possible to require more than length steps to sort but I will think on that.

Pyth, 27 bytes
jsCM.u:R"v "" v"N+R\-.t*L\v

Try it online!

Perl 5, 118 bytes
115 bytes of code + -pla flags.
\@X[$_]for@F;s%\d+ ?%Y x$&.$"x($#X-$&).$/%ge;while(/Y.{$#X} /s){print$_,_ x$#X;1while s/Y(.{$#X}) /X$1b/s;y/bX/Y /}

Try it online!
It seems a bit too long. But again, dealing with multiline strings with regex is usually not easy.
I'm using Y instead of * and _ instead of -.

Octave, 104 bytes
b=(1:max(L=input("")))<=L;do;disp(" *-"([b;max(b)+1]+1))until b==(b=imerode(b,k=[1;1])|imdilate(b,k)~=b)

*Requires image package.
Try it online!
Explanation:
input = [8 ;4 ;2 ;1]

L = input('');                    %input list
b=(1:max(L))<=L;                  % generate matrix of 0s and 1s as indexes of asterisks

b =

  1  1  1  1  1  1  1  1
  1  1  1  1  0  0  0  0
  1  1  0  0  0  0  0  0
  1  0  0  0  0  0  0  0
do;
    disp(' *-'([b;max(b)+1]+1))  %display asterisks and dashes

    E = imerode(b,k=[1;1]);      %morphological erosion
    E =

      1  1  1  1  0  0  0  0
      1  1  0  0  0  0  0  0
      1  0  0  0  0  0  0  0
      1  0  0  0  0  0  0  0

    D = imdilate(b,k);           %morphological dilation
    D =

      1  1  1  1  1  1  1  1
      1  1  1  1  1  1  1  1
      1  1  1  1  0  0  0  0
      1  1  0  0  0  0  0  0

    b_temp = E | (D~=b)          %intermediate result
    b_temp =

      1  1  1  1  0  0  0  0
      1  1  0  0  1  1  1  1
      1  0  1  1  0  0  0  0
      1  1  0  0  0  0  0  0

until b==(b=b_temp)              %loop until no change

sadly, probably there's no bonus points for frame-by-frame animation :|

have now - my apologies, comment retracted

Python, 203 199 bytes
def k(x):
 m,j=max(x),''.join;d=[*map(lambda i:('*'*i).ljust(m),x)];f=sorted(d);print(*d,sep='\n')
 while d!=f:d=[*map(j,zip(*[x.replace('* ',' *')for x in map(j,zip(*d))]))];print('-'*m,*d,sep='\n')

Where are the dashes?

@LeakyNun fixed

Consider using Python 2 instead of your current Python 3, where map returns an array immediately so you don't need to splat it. You'd want to assign a variable to '\n'.join to help you make up for the lack of sep='\n', though, but it's probably still shorter that way.

@ValueInk how would you go about the zips? the lack of unpacking might cost many bytes

Python 2 lets you unpack into a function just fine; I only heard that unpacking into an array sometimes has issues. With only my suggested changes the Python 2 code is 194 bytes, try it online

I'm sorry about the very old post comment, but 182 bytes I think

R, 210 205 bytes
l=scan();w=max(l);h=sum(l|1);a=1:h;p=h+1;m=matrix(' ',w,p);m[,p]='+';for(x in a)m[l[x]:1,x]='*';f=function()write(m,'',w,sep='');f();while(any(i<-m[,a]>m[,a+1])){s=which(i);m[,a][s]=' ';m[,a][s+w]='*';f()}

Try it online!
reads in the list from stdin; separated by + characters instead of -. It's a lot longer than I would have thought it would be. Takes advantage of the fact that the comparison '*'>'+' evaluates to FALSE but '*'>' ' is TRUE, at least on TIO (on my machine I used '=' which looked a little better).
Managed to golf 5 bytes down from all the techniques I've learned since writing the original answer.
Try it online!

Japt, 69 62 bytes
-7 bytes thanks to @Shaggy

®ç'x +SpZnUrwÃpQpUrw¹·
V
l o ®V=z d" x""x " z3ÃuW
X¯XbXgJ)Ä ·

Learning Japt and wanted to try out a more complicated challenge. Outputs with xs and "s instead of asterisks and dashes; takes input as an array of numbers. Assumes sorting will be complete within input.length steps; correct me if that is ever not the case.
Try it online!
Explanation
                              // implicit: U = input array
 ®   ç'x +SpZnUrwÃ pQpUrw¹ ·  // implicit: V = this line
UmZ{Zç'x +SpZnUrw} pQpUrw) qR // ungolfed
UmZ{             }            // U mapped by the function:
    Zç'x                      //   "x" times this item
         +SpZnUrw             //   plus " " times the max of the input array (Urw) minus this value (Z)
                   pQpUrw)    // push " (Q) times the max
                           qR // join with newlines

V                             // implicit: W = this line

 l o ®   V=z d" x""x " z3Ã uW // implicit: X = this line
Ul o mZ{ZV=z d" x""x " z3} uW // ungolfed
Ul o                          // the array of the range [0, U.length)
     mZ{Z                }    // mapped by the no-arg function:
         V=z                  //   set V to itself rotated 90deg
             d" x""x "        //   replace all " x" with "x " to "fall"
                       z3     // rotate back to normal
                           uW // add  W(the original) to the start

X¯XbXgJ)Ä ·                   // implicit: return this line
Xs0,XbXgJ)+1 qR               // ungolfed
Xs0,                          // get the substring of X from 0 to...
    XbXgJ)+1                  // the first index of the last item, plus one
             qR               // join with newlines

A few quick savings for you. I'm sure there are more but I'm quite tired.

@Shaggy Thanks a lot! That's a really good example of setting variables according to the line the statement is on. If that isn't on the Japt tips post, it should be.

Done. Leave a comment if you see any room for improvement.

@Shaggy Looks good, and congrats on your gold badge!

Japt -R, 32 31 30 32 31 30 bytes
Really enjoyed this one but not entirely happy with the final result, especially after having to add 2 bytes to fix a bug. Still determined to get it down under 30 bytes, though.
Uses n instead of *.
¡P=yÈrSùÍSúÍÃª¡XçnÃ·úÃâ qR² ú-

Try it (footer replaces ns with *s) or run all test cases
¡P=yÈrSùÍSúÍÃª¡XçnÃ·úÃâ qR² ú-     :Implicit input of array U
¡                                  :Map
 P=                                :  Reassign to P (initially the empty string)
   y                               :    Transpose P
    È                              :    Pass through the following function and transpose back
     r                             :      Replace
      S                            :        Space
       ù                           :        Left padded with
        Í                          :        "n" to length 2
         SúÍ                       :        With a space right padded with "n" to length 2
            Ã                      :    End function
             ª                     :    Logical OR ('cause it'll still be the empty string on the first iteration)
              ¡                    :      Map each X in U
               Xçn                 :        "n" repeated X times
                  Ã                :      End map
                   ·               :      Join with newlines
                    ú              :      Right pad each with spaces to the length of the longest
                      Ã            :End map
                       â           :Deduplicate
                         q         :Join with
                          R        :  Newline
                           ²       :  Repeated twice
                             ú-    :Right pad each line with "-" to the length of the longest

Haskell, 213 211 208 bytes
import Data.List
(?)=replicate
p=transpose
s l|w<-length l,i<-[n?'*'++w?' '|n<-l]=intercalate[w?'-']$i:(p<$>unfoldr f(p i))
f i|i==n=mempty|2>1=Just(n,n)where n=t<$>i
t(a:b:y)|a>b=" *"++t y|2>1=a:t(b:y);t k=k

Try it online!

Javascript, 274 bytes
a=>(r="",m=Math.max(...a),b=a.map(n=>Array(m).fill(0).map((_,i)=>i<n)),(k=_=>(b.map(c=>r+=c.map(v=>v?"*":" ").join``.trim()+`
`),r+="-".repeat(m)+`
`,n=0,b.map((r,i)=>(s=b[i+1])&&r.map((c,j)=>s[j]||(n|=s[j]=-(c>0),c>0&&(r[j]=0)))),b=b.map(c=>c.map(n=>n<0?1:n)),n&&k()))(),r)

Example code snippet:

f =

a=>(r="",m=Math.max(...a),b=a.map(n=>Array(m).fill(0).map((_,i)=>i<n)),(k=_=>(b.map(c=>r+=c.map(v=>v?"*":" ").join``.trim()+`
`),r+="-".repeat(m)+`
`,n=0,b.map((r,i)=>(s=b[i+1])&&r.map((c,j)=>s[j]||(n|=s[j]=-(c>0),c>0&&(r[j]=0)))),b=b.map(c=>c.map(n=>n<0?1:n)),n&&k()))(),r)

o.innerText = f([6,4,2,5,3,1])
<pre id=o>

J, 49 45 bytes
' *-'{~2,/@,.~[:((]+[-1|.])]<_1|.!.0])^:a:#&1

Try it online!
Takes input as a column vector.
About a third of the bytes are just to conform to the output specs.

#&1 Convert to rows of ones, with 0 fill.
[:(...)^:a: Do ... until a fixed point is reached, keeping track of intermediate results.
]<_1|.!.0] Rotate the rows down, then ask: "where is that less than the original input?"  This will pick out just the valid falling pieces, in their "next" position.  Call these the "rain".
(]+[-1|.]) Add the rain to this step's input minus the rain rotated up.  That is, rewind the "rain" one step, remove this rewinded-rain from the input, and then add the not-rewinded rain.  This is precisely the rain plus the static pieces, which is what we want for the next iteration.
' *-'{~2,/@,.~ Conform to output spec.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Abandon all squares, ye who divide me
Definitions

A perfect square is an integer which can be expressed as the square of another integer. For example, 36 is a perfect square because 6^2 = 36.
A squarefree number is an integer which is not divisible by any perfect square, except by 1. For example, 10 is a squarefree number. However, 12 is not a squarefree number, because 12 is divisible by 4 and 4 is a perfect square.

Task
Given a positive integer n, output the largest squarefree number which divides n.
Testcases
n   output
1   1
2   2
3   3
4   2
5   5
6   6
7   7
8   2
9   3
10  10
11  11
12  6
13  13
14  14
15  15
16  2
17  17
18  6
19  19
20  10
21  21
22  22
23  23
24  6
25  5
26  26
27  3
28  14
29  29
30  30
31  31
32  2
33  33
34  34
35  35
36  6
37  37
38  38
39  39
40  10
41  41
42  42
43  43
44  22
45  15
46  46
47  47
48  6
49  7
50  10

Scoring
This is code-golf. Shortest answer in bytes wins.
Standard loopholes apply.
Reference

OEIS A007947

...and is called the radical - so 1980's!

Closely related, just multiply the two outputs. Edit: Never mind, it only matches on cubefree numbers.

05AB1E, 2 bytes
fP

Try it online!
How it works
f   Implicitly take input and compute the integer's unique prime factors.
 P  Take the product.

_> really...??

@HyperNeutrino yep - if a number is not square-free it is because some of its prime factor(s) have multiplicity.

@JonathanAllan I'm just interested in the built-in for unique prime factors. I wish Jelly had one of those...

@HyperNeutrino It's 05AB1E, get used to it. 05AB1E has some really redundant builtins that apparently save bytes.

Correction, "save bytes", there's no probably about it.

Brachylog, 3 bytes
ḋd×

Try it online!
A very original answer...
Explanation
ḋ          Take the prime factors of the Input
 d         Remove duplicates
  ×        Multiply

Again, Brachylog beats Jelly because a two-byte atom is only one byte here. >:-P

Jelly having a lot of builtins is often seen as an advantage; but more builtins means that they need longer names on average. So there are tradeoffs involved in golfing language design.

I'm not trying to be "that guy", and maybe I just misunderstand byte counting, but isn't this 6 bytes? https://mothereff.in/byte-counter#ḋd×

@CaptainMan Brachylog uses a 256 chars custom code page which you can find here.

JavaScript (ES6), 55 54 50 46 bytes
Quoting OEIS:
a(n) is the smallest divisor u of n such that n divides u^n
Updated implementation:
a(n) is the smallest divisor u of n positive integer u such that n divides u^n

let f =

n=>(g=(p,i=n)=>i--?g(p*p%n,i):p?g(++u):u)(u=1)

for(n = 1; n <= 50; n++) {
  console.log(n,f(n));
}

Nice approach to the problem, esp. given lack of builtin factorization

MATL, 6 4 bytes
2 bytes saved with help from @LeakyNun
Yfup

Try it online!
Explanation
Consider input 48.
Yf   % Implicit input. Push prime factors with repetitions.  STACK: [2 2 2 2 3]
u    % Unique.                                               STACK: [2 3]
p    % Product of array. Implicit display.                   STACK: 6

Out-golfed

@LeakyNun Heh, I was about to post that :-) Thanks

Jelly, 4 bytes
ÆfQP

Try it online!
ÆfQP  Main link, argument is z
Æf    Takes the prime factors of z
  Q   Returns the unique elements of z
   P  Takes the product

CJam, 8 bytes
rimf_&:*

Why does every operation in this program have to be 2 bytes -_-
Try it online!
ri       e# Read int from input
  mf     e# Get the prime factors
    _&   e# Deduplicate
      :* e# Take the product of the list

I couldn't find a way to deduplicate. Nice!

@LuisMendo I just discovered that recently. I always thought it was multiset intersection but apparently it's just normal set intersection.

Retina, 36 30 28 bytes
+`((^|\3)(^(1+?)|\3\4))+$
$3

Input and output in unary.
Try it online! (Includes a header and footer for decimal <-> unary conversion and to run multiple test cases at once.)
Explanation
The idea is to match the input as a square times some factor. The basic regex for matching a square uses a forward-reference to match sums of consecutive odd integers:
(^1|11\1)+$

Since we don't want to match perfect squares, but numbers that are divisible by a square, we replace that 1 with a backreference itself:
(^(1+?)|\1\2\2)+$

So now the outer group 1 will be used n times where n2 is the largest square that divides the input and group 2 stores the remaining factor. What we want is to divide the integer by n to remove the square. The result can be expressed as the number of iterations of group 1 times group 2, but this is a bit tricky to do. Retina's $* will probably soon be improved to take a non-character token as its right hand argument in which case we could simply replace this with $#1$*$2, but that doesn't work yet.
Instead, we decompose the odd numbers differently. Let's go back to the simpler example of matching perfect squares with (^1|11\1)+$. Instead of having a counter \1 which is initialised to 1 and incremented by 2 on each iteration, we'll have two counters. One is initialised to 0 and one is initialised to 1, and they're both incremented by 1 on each iteration. So we've basically decomposed the odd numbers 2n+1 into (n) + (n+1). The benefit is that we'll end up with n in one of the groups. In its simplest form, that looks like this:
((^|1\2)(^1|1\3))+$

Where \2 is n and \3 is n+1. However, we can do this a bit more efficiently by noticing that the n+1 of one iteration is equal to the n of the next iteration, so we can save on a 1 here:
((^|\3)(^1|1\3))+$

Now we just need to go back to using an initial factor instead of 1 to match inputs that are divided by a perfect square:
((^|\3)(^(1+?)|\3\4))+$

Now all we need to do is replace this entire thing with $3 at the end, which stores the initial factor times the number of steps, which drops one factor of the square from the input.
This is done repeatedly with the + at the very beginning of the program, to account for inputs that contain higher powers than squares.

Octave, 27 bytes
@(x)prod(unique(factor(x)))

Similar approach as the other answers. The difference is: The functions have much longer names. I believe the code explains itself really:
Takes the product of the unique prime factors of a number.

You ninja'd me by ~30 seconds :)

longer names you say

Wolfram Language, 29 28 bytes
-1 Thanks to @Martin Ender ♦
Most[1##&@@FactorInteger@#]&

Explanation:
           FactorInteger@#    (*Get prime factorization as {{a,b},{c,d}}*)
     1##&@@                   (*Multiply list elements together, to get the product of the factors and the product of their exponents*)
Most[                     ]&  (*Take the first element*)

Just realized this is basically @GregMartin's comment on the Mathics answer, only less golfy...

Don't feel bad, I had the even less golfy answer of Times@@(#&@@@FactorInteger@#)&

Most leaves it as a list. You need First to get the value.

@IanMiller I realize that, but it is less bytes to just return a list with only one element. I assumed that that was ok, since it is still a reasonable output.

Python, 37 bytes
f=lambda n,r=1:1>>r**n%n or-~f(n,r+1)

Try it online!
The largest squarefree divisor of n is that smallest number r with all of n's prime factors. We can check this as r**n%n==0, since r**n make n copies of each prime factor of r, and is divisible by n only if each of n's prime factors is represented.
The 1>>r**n%n is equivalent to int(r**n%n==0). If True can be used output 1, it's 2 bytes shorter to do.
f=lambda n,r=1:r**n%n<1or-~f(n,r+1)

Mathics, 40 bytes
Times@@(Transpose@FactorInteger@#)[[1]]&

Try it online!

Times@@#&@@Transpose@FactorInteger@#& saves 3 bytes (#&@@ is standard trick for [[1]] and in cases like this it can often save some extra bytes on parentheses).

You can also use Thread instead of Transpose. In Mathematica there's also a 3-byte operator for Transpose, but I don't know whether Mathics supports it.

#&@@(1##&@@FactorInteger@#)& avoids the need to Transpose altogether. (1##&@@ is just Times@@ in disguise, which works great on the ordered pairs yielded by FactorInteger; and '#&@@ is First@ in disguise.)

@GregMartin that's basically your own solution, feel free to post it, if you want.

Looks like Scott Milner got it anyway :)

Alice, 4 bytes
iDo@

Try it online!
Input and output are given as the code point of a character (works for all valid Unicode code points).
Explanation
Well, Alice has a built-in D whose definition is "Deduplicate prime factors". That is, as long as a value is divisible by some p2 for a prime p, divide that value by p. This happens to be exactly the function required in this challenge. The rest is just input, output, terminate the program.
The reason this was added to Alice actually has nothing to do with this integer sequence. I was trying to stick to a theme of associating divisors with substrings and prime factors with characters. And I needed a function that goes with "deduplicate characters" (which is much more useful in general, because it let's you treat strings as sets, especially when used together with the various multiset operators).

The sad part is, even with a builtin this isn't the shortest answer.

@Riker Well, that's because Alice isn't a golfing language so it needs explicit I/O and (since it's a 2D language) program termination.

Yeah, still somewhat sad though.

@ConorO'Brien We just had this discussion elsewhere, and that's only valid if the stand-alone operator is an expression which evaluates to the function (which isn't the case here, since functions/operators aren't first-class values). https://codegolf.meta.stackexchange.com/a/7206/8478

@ConorO'Brien sorry that was an exclusive "we".

@ConorO'Brien independently of that post all answers need to be entire programs, or need to define a function, or be an expression that evaluates to a function.

@MartinEnder Ohhh ok, cool

Haskell, 31 bytes
f n=until(\r->r^n`mod`n<1)(+1)1

Try it online!

Pyke, 3 bytes
P}B

Try it online!
P   -   factors(input)
 }  -  uniquify(^)
  B - product(^)

Prolog (SWI), 84 39 bytes
f(N,P):-between(1,N,P),P^N mod N=:=0,!.

Try it online!
Adapted the idea of @xnor's Haskell answer to Prolog.

PHP, 70 Bytes
for($r=1,$i=2;1<$n=&$argn;)$n%$i?++$i:$n/=$i+!($r%$i?$r*=$i:1);echo$r;

Try it online!

Pyth, 8 6 bytes
*F+1{P

*-2 bytes thanks to @LeakyNun
Would be 3 if Pyth had a built-in for products of lists...
Try it!
*F+1{P
      Q     # Implicit input
     P      # Prime factors of the input
    {       # Deduplicate
  +1        # Prepend 1 to the list (for the case Q==1)
*F          # Fold * over the list

You can use *F+1{P instead.

C, 65 50 bytes
Thanks to @Ørjan Johansen for removing the need for r. Thanks to this and some other dirty tricks I was able to squeeze 15 bytes off!
d;f(n){for(d=1;d++<n;)n%(d*d)||(n/=d--);return n;}

while is gone and replaced with || and index twiddling. <= should have been < all along.
<= turned to < by moving the increment to get n%(++d*d) (should be well defined due to operator precedence).

Original code:
d;r;f(n){for(r=d=1;d++<=n;)while(n%d<1)r*=r%d?d:1,n/=d;return r;}

I think you can shorten it by removing r and instead use while(n%(d*d)<1)n/=d;.

@ØrjanJohansen That seems right. I was thinking construction rather than reduction. I have some additional improvements to add, will update soon.

++d*d is absolutely not well defined by the C standards - it's a classic case of explicitly undefined behavior. But we're going by implementations here, anyway.

Actually, shouldn't d++<n, which is well defined, still work? I think the old version went all the way to n+1 (harmlessly).

You're probably right about the undefined behavior. For some reason I thought that operator precedence would solve that. Most examples I've seen of UB uses same priority operators, but of course there is a data race here as well. You're also right about d++<n being correct, for some reason I didn't see that when I rewrote the code.

49 bytes

R, 52 bytes
`if`((n=scan())<2,1,prod(unique(c(1,gmp::factorize(n))))

reads n from stdin. Requires the gmp library to be installed (so TIO won't work). Uses the same approach as many of the above answers, but it crashes on an input of 1, because factorize(1) returns an empty vector of class bigz, which crashes unique, alas.

This outputs 12 when I input 12.

@Flounderer you are correct, I have updated the code.

Axiom, 89 bytes
f(x:PI):PI==(x=1=>1;g:=factor x;reduce(*,[nthFactor(g,i) for i in 1..numberOfFactors g]))

test and results
(38) -> [[i, f(i)] for i in 1..30 ]
   (38)
   [[1,1], [2,2], [3,3], [4,2], [5,5], [6,6], [7,7], [8,2], [9,3], [10,10],
    [11,11], [12,6], [13,13], [14,14], [15,15], [16,2], [17,17], [18,6],
    [19,19], [20,10], [21,21], [22,22], [23,23], [24,6], [25,5], [26,26],
    [27,3], [28,14], [29,29], [30,30]]

this is the one not use factor() function
g(x:PI):PI==(w:=sqrt(x);r:=i:=1;repeat(i:=i+1;i>w or x<2=>break;x rem i=0=>(r:=r*i;repeat(x rem i=0=>(x:=x quo i);break)));r)

but it is only 125 bytes

Pari/GP, 28 bytes
n->factorback(factor(n)[,1])

Try it online!

Actually, 2 bytes
yπ

Try it online!
Explanation:
yπ
y   prime divisors
 π  product

Pyt, 3 bytes
←ϼΠ

Explanation:
←                  Get input
 ϼ                 Get list of unique prime factors
  Π                Compute product of list
                   Implicit print

Vyxal, 2 bytes
ǏΠ

Try it Online!

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/