# Rebuild a rectangular array from a corner

I once had a beautiful rectangular array. It was very symmetrical, but unfortunately it has fallen apart and now I only have the top left corner. Your task will be to rebuild the original array.

Your program will receive a 2 dimensional array of integers. For ease of parsing, you may assume they are all between 1 and 9. Your task is to reverse the array's columns, its rows, and both, stitch together the resulting corners, and return the resulting array.

You can assume the array dimensions will be at least 1x1.

Test cases:

Input:
1 2 3
4 5 6

Output:
1 2 3 3 2 1
4 5 6 6 5 4
4 5 6 6 5 4
1 2 3 3 2 1


Input:
1

Output:
1 1
1 1


Input:
9
9
9

Output:
9 9
9 9
9 9
9 9
9 9
9 9


This is , fewest bytes wins!

• I'll bet charcoal can do this in under 10 – FantaC Mar 5 '18 at 16:19
• @tbfninja chat.stackexchange.com/transcript/message/43184083#43184083 but could maybe be shorter with a different input format. – Pavel Mar 5 '18 at 16:20
• @MagicOctopusUrn yes – Pavel Mar 5 '18 at 16:39
• @tfbninja ＷＳ⟦ι⟧‖Ｍ→↓ perhaps? 5 bytes to read the input and 4 to reflect it. – Neil Mar 5 '18 at 17:51
• I'm 99% sure that there is a lang that do this with ╬ (or some similar character) just can't remember which one :c – Rod Mar 5 '18 at 19:36

# Python 3, 49 bytes

def f(a):o=[i+i[::-1]for i in a];return o+o[::-1]


Where a is the input array. This function will return a 2D array.

# Clojure, 56 bytes

(fn[i](map #(concat %(reverse %))(concat i(reverse i))))


Creates an anonymous function which takes the two dimensional list and returns the fixed rectangle as two dimensional list.

Try it online!

# Perl 5-lp-Mfeature=say, 36 bytes

unshift@l,$_.=reverse;END{say for@l}  Deparsed: BEGIN {$/ = "\n"; $\ = "\n"; } use feature 'say'; LINE: while (defined($_ = readline ARGV)) {
chomp $_; unshift @l,$_ .= reverse;
sub END {
say $_ foreach (@l); } } continue { die "-p destination:$!\n" unless print \$_;
}


Try it online!