# C4_4 Reflection!

In this challenge, your task is to input a rectangle ASCII pattern (You may assume only printable characters need to be handled, and you may assume a trailing newline or not), C4_4 symmetrify, and output it.

Here, C4_4 symmetric means symmetric under 90-degree rotation around a corner of the corner character. The corresponding "symmetrify" process is copy and rotate 90-degree clockwise three times, and then put all four copies together. For the precise arrangement, you can look at Test Cases.

# Test Cases

Input:
asdf
jkl;

Output:
ja
ks
asdfld
jkl;;f
f;;lkj
dlfdsa
sk
aj

Input:
.O.
..O
OOO

Output:
.O.O..
..OO.O
OOOOO.
.OOOOO
O.OO..
..O.O.

Input:
gc
oo
ld
fe

Output:
gc
oo
ldflog
feedoc
codeef
golfdl
oo
cg


• I'd suggest to add a test case where the height of the input is strictly greater than its width. – Arnauld Oct 4 '19 at 13:12
• Hmm... emoticons? 4_4 – S.S. Anne Oct 5 '19 at 14:51

# Charcoal, 6 bytes

Ａ⟲Ｃ²⁴⁶


Try it online! Link is to verbose version of code. Explanation: Ａ implicitly prints the input, ⟲ performs the rotation, Ｃ signifies to keep copies, and ²⁴⁶ represents the numbers of 45-degree rotations to make. (Charcoal defaults to rotating around the bottom-right corner as desired.)

• Yet another fastest gun! Yeah, Charcoal is very suitable for this challenge. Have a +1! – HighlyRadioactive Oct 4 '19 at 12:39

# Python 3, 193 bytes

def f(s):q=len(s)-len(s);s=[[" "]*len(s)]*q+s;s=[[" "]*-q+l for l in s];j=lambda a,b:[x+y for x,y in zip(a,b)];r=lambda x:[*map(list,zip(*x[::-1]))];return j(s,r(s))+j(r(r(r(s))),r(r(s)))


Try it online!

• I was not expecting this to happen. Nice work! – HighlyRadioactive Oct 4 '19 at 13:06

# J, 38 bytes

(,|."1@|.)@(,.|:@|.)@((2$_1*>./)@${.])


Try it online!

No doubt it can be golfed much further.

# JavaScript (ES6),  178  173 bytes

Takes input as an array of strings. Returns a string.

m=>(g=x=>~y?(Y=y<w?y:W-y,X=x<w?x:W-x,Z=y<w^x<w?Y:X,(m[Z-z*d]||0)[(X^Y^Z)+!z*d]||' ')+[
[x-W]]+g(x<W?x+1:!y--):'')(0,w=m.length,h=m.length,d=w-h,(z=d>0)?0:w=h,y=W=w*2-1)


Try it online!

# Red, 217 bytes

func[a][n: max(l: length? a)length? a/1
p: copy""insert/dup p" "n
loop n - l[insert a copy p]forall a[pad/left a/1 n]repeat y n[repeat x n[append
a/:y a/(n - x + 1)/:y]]repeat y n[append a reverse copy a/(n - y + 1)]]


Try it online!

Returns a list of strings

• pad, append, reverse! This is plain English. I like it. – HighlyRadioactive Oct 5 '19 at 11:37
• @TwilightSparkle Thanks! I like it too :) – Galen Ivanov Oct 5 '19 at 11:51
• I'm curious why Red uses [] unlike lisp. – HighlyRadioactive Oct 5 '19 at 12:01
• @TwilightSparkle I don't know.. [] is a block (list), () is used for grouping – Galen Ivanov Oct 5 '19 at 12:04
• Thanks for your explanation. I think I will probably get deeper into this language, maybe. – HighlyRadioactive Oct 6 '19 at 1:37

# Icon, 255 206 bytes

procedure f(a)
n:=*a;n<:=t:=*a
1to n-*a&push(a,repl(" ",t))&\z
(!a)[1:1]:=repl(" ",n-t)&\z
i:=1to n&j:=1to n&a[i]||:=a[n-j+1,i]&\z
i:=1to n&put(a,"")&j:=1to 2*n&a[n+i]||:=a[n-i+1,2*n-j+1]&\z
return a
end


Try it online!

• No Red answer? :P – HighlyRadioactive Oct 5 '19 at 9:56
• @TwilightSparkle Maybe I'll write one :) – Galen Ivanov Oct 5 '19 at 11:06
• I'm waiting for it then LOL – HighlyRadioactive Oct 5 '19 at 11:07

# Python 3, 140 bytes

def f(a):l=len(a);k=len(a)-l;b=[k*' '+i for i in-k*[l*' ']+a];b+=[*map(''.join,zip(*b))][::-1];return[i+j[::-1]for i,j in zip(b,b[::-1])]


Try it online!

Expects and returns a list of lines.

### Explanation

def f(a):
l=len(a);k=len(a)-l;                     # Extract dimensions
b=[k*' '+i for i in-k*[l*' ']+a];           # Make it square
b+=[*map(''.join,zip(*b))][::-1];           # Construct left half of the output
return[i+j[::-1]for i,j in zip(b,b[::-1])]  # Construct the right half and return

• A nice approach! – HighlyRadioactive Oct 10 '19 at 10:16