# Your code has an uncanny mirror twin…

Write two programs, each taking a string s and a number n ≥ 0, such that:

• The first program prints s n times, separated by newlines.
• The second program prints each character of s n times, with repeated characters separated by newlines.
• Every character at column x, line y in one program equals the character at column y, line x in the other program.

Both programs must contain at least two lines. You may take input in any reasonable order or format that works for both programs.

This is ; the less bytes, the better. Count bytes from your longer program (that is, the one with more lines than columns).

Here's an example in a hypothetical programming language, with s = "Hello, world!" and n = 3:

### Program A

a(b*c
defg
h.ij)


### Output

Hello, world!
Hello, world!
Hello, world!


### Program B

adh
(e.
bfi
*gj
c )


### Output

HHH
eee
lll
lll
ooo
,,,

www
ooo
rrr
lll
ddd
!!!

• Related, related, and related. May 30 '20 at 17:15
• Can one program take s first then n, and the other take n then s? May 31 '20 at 0:57
• @Khuldraesethna'Barya The input should be the same format for both programs. May 31 '20 at 2:37
• Can I write a function instead of a program? May 31 '20 at 7:13
• Do both programs need to be in the same language? May 31 '20 at 18:47

# C, 196 bytes

Regular version: 190 bytes

p;f(char *s,n) {
; while( p++<  n)
puts(s);p; }   /*
f*******u*0**;* /
(///////t/)//}+*
c*)dfppnc(;p(w+/
hs{oo=+;h* u"hs}
a, {r0+)a /t"i)/
rn  (;< r *s l;*
/////// /  / e/
******* *  * (*/


Mirrored version: 196 bytes

p;pf(char/*
; u*/*s,n/*
fwt*/){  /*
(hs*/do{ /*
ci(*/for(/*
hls*/p=0;/*
ae)*/p++</*
r(;*/n;)
putchar/*
*p;+*/(*
s+ 0); /*
,+}*/puts/*
n< */(""
)  ;}while(
*++s);/*
{n/ */}/* /
)*/


p; f(char* s, n) {
;
while (p++ < n)
puts(s);
p;
}


p; pf(char* s, n) {
do {
for (p = 0; p++ < n; )
putchar (*s + 0);
puts("");
} while (*++s);
}

• Make sure you mirror your spaces, too! Jun 1 '20 at 3:33
• Oh, you got it, sorry! That's what happens when you do the reversing manually... Jun 1 '20 at 6:39

# MATL, 11 bytes

Inputs are s, then n.

Normal version (10 bytes):

1!X"
XDD
"


Mirrored version (11 bytes):

1X"
!D
XD
"


Try it online!

### Explanation

The normal version is parsed as

1    % Push 1
!    % Transpose: does nothing to the 1
X"   % Implicit inputs: n, s. Repeat s n times vertcally and 1 time horizontally
XD   % Display the full stack contents. This prints the output
D    % Display. Triggers implicit input, which is not present, and so errors
"    % For each. This statement is not reached


The mirrored version is parsed as

1    % Push 1
X"   % Implicit inputs: n, s. Repeat s n times vertcally and 1 time horizontally
!    % Transpose. This transforms the above into the desired output
D    % Display. This prints the output
XD   % Display all stack contents. The stack is empty, so this does nothing
"    % For each. Triggers implicit input, which is not present, and so errors

• @Downvoter Any suggestion to improve my annswer? Jul 21 '20 at 9:46

# perl, 102 bytes

$_=<>;$n=<>;print$_ x$n
__END__
=E
<N
>D
;_
$_ ; = < > ; s / . /$
&
x
$; . " \ n " / g e ; p r i n t  Try it online! $_=<>;$;=<>;s/./$&x$;."\n"/ge;print __END__ =E <N >D ;_$_
n
=
<
>
;
p
r
i
n
t
$_ x$
n


Try it online!

The programs are fairly trivial, they just do what is required without any trickery. The only trickery is the __END__; this tells perl to ignore anything what is following. That way, hardly anything is shared between the two programs, only the first two bytes are: $_, where the _ is either the name of the variable, or the first character of the __END__ token. # Charcoal, 20 bytes ＥＮη¿⁰« Ｎ η ‖ ↙ ¿ ⁰ «  Try it online! Explanation: ＥＮη  Convert the input number to an implicit range, map each entry to the input string, and print the result. ¿⁰  Execute the rest of the program only if 0 is true (which it isn't). «  Wrap the rest of the program in a block, so it doesn't matter what its meaning is, since it never gets executed. Reflected: ＥＮη‖↙¿⁰« Ｎ η ¿ ⁰ «  Try it online! Explanation: Much like the other program, except that the ‖↙ reflects the output as desired. • @Jonah You may be confused as I was. The challenge doesn't ask for a single program to be symmetric. So the double bar may appear at only one place in each program May 31 '20 at 0:01 # 05AB1E (legacy), 6 bytes -1 byte thanks to @dingledooper. иø » q  Try it online! ## Explanation (Horizontal) и Sequence product. ø Transpose this product. » Join the product by newlines. q Exit the program.  ## Explanation (transposed) и Sequence product. » Join the product by newlines. q Exit the program. A garbage dump the interpreter ignores: ø $$$$  # Python 2, 95 bytes First program: 94 bytes sfp,n=input();"\ ,or";s=sfp+"\n" print s*n; """ = n ict n pic un* t p (s; ):" #"" """ 1; #\  Try it online! Second program: 95 bytes s,p=input()#"1# for c in s:"";\ print c*p;""" ,"n n;t =s i=s ns* pfn up; t+ (" )\" ;n" """ \  Try it online! # Perl 5 + -pF, 51 bytes I feel I can condense this more so I'll likely tinker with it to try and make it more square... $_=$_ x<>;' ; f =xo <$r
>;@
;.F
$$; \/} .|{ =|$$'


Try it online!

### Explanation

Basically this just runs $_=$_ x <> which, since -p flag is used, will just print out the string triplicated. The rest of the string is avoid by being inside a single quote.

$;=<>;$\.=$_ x$;.$/||$
=for@F;}{'

# Jelly, 10 bytes

Unfortunately, for this challenge, the execution of a Jelly program starts with the bottom line of code, so there's quite a bit of work required to get a solution under about 25 bytes!

W ñ
ẋY
Z
ñ


Try it online!

WẋZñ
Y
ñ


Transposed

### How?

Normal:

W ñ - Link 1: s, n
W   - wrap (s) in a list
ñ - call the next Link (2) as a dyad - f(that, n)

ẋY - Link 2: wrapped s, n
ẋ  - repeat (s) (n) times
Y - join with newlines

ñ - Main Link: s, n
ñ - call the next Link (1) as a dyad - f(s, n)
- implicit (smashing) print


Transposed:

WẋZñ - Link 1: s, n
W    - wrap (s) in a list
ẋ   - repeat (that) (n) times
Z  - transpose
ñ - call the next Link (2) as a dyad - f(that, n)

Y - Link 2: transposed, repeated [s]
Y - join with newlines

ñ - Main Link: s, n
ñ - call the next Link (1) as a dyad - f(s, n)
- implicit (smashing) print


# Mathematica, 114 bytes

Mathematica, with it's long, unsplittable names means that no matter how short I make this, it'll still have obtuse names, the alternative of using <> and #&/@ would be shorter for either individual program, but dealing with them in the transposition makes the program longer overall.

StringRiffle[
t;Table[##],1*
rT;"\n"]&(*  )
ia
nb
gl
Re
i[
f#
f#
l]
e]
[
C,
h"
a\
rn
a"
c,
t"
e"
r]
s&
[(
1*
*)


Normal

StringRiffle[Characters[1*
t;Table[##]],"\n",""]&(*)
rT;
ia"
nb\
gln
Re"
i[]
f#&
f#(
l]*
e,
[1
*)


Transposed

### Base programs:

Normal:

StringRiffle[Table[##],"\n"]&

Transposed:

StringRiffle[Characters[Table[##]],"\n",""]&

# Stax, 6 bytes

]
*M
m


Run and debug it

Mirrored:

]*m
M
`

Run and debug it