33
Rip-off of a rip-off of a rip-off of a rip-off. Go upvote those!
Your task, if you wish to accept it, is to write a program/function that outputs/returns its input/argument¹. The tricky part is that if I transpose your source code², the output/result must be transposed too.
You may choose which kind of 2D data your solution can accept. For example a list of lists, a matrix, a list of strings, etc. State which one(s) it handles. You may assume that the input will always be rectangular and will have a length of 1 or more along each dimension.
For the purposes of transposing, short lines in your source code will be considered as padded with trailing spaces until it is rectangular, however, these padded trailing spaces do not contribute to your code length.
Since this is code-golf, the target is to optimize the byte count of the original source code (not the transposed version).
Examples
Let's say your solution takes a numeric matrix and your source code is
AB
DEF
and its input/argument is [[1,2],[3,4],[5,6]]
. If I write
AD
BE
F
instead and run it, the output/result must be [[1,3,5],[2,4,6]]
.
Let's say your solution takes a linefeed-separated string and your source code is
ABC
and its input/argument is "96\n"
. If I write
A
B
C
instead and run it, the output/result must be "9\n6\n"
.
Can we count our bytes by the transposed version? In my case the transposed version has less newlines, so it is smaller. – Night2 – 2019-09-22T16:05:47.243
23My god. Can we stop? – S.S. Anne – 2019-09-22T16:30:33.833
3@Night2 No, it complicates matters. – Adám – 2019-09-22T16:30:47.837
14@JL2210 No, I have a big one in the works. – Adám – 2019-09-22T16:31:08.283
7These challenges are getting impossible in procedural languages without serious comment abuse. – S.S. Anne – 2019-09-22T16:32:18.233
1What, negate the source code, negate the output? – S.S. Anne – 2019-09-22T16:40:44.850
2
@JL2210 Transforms.
– Adám – 2019-09-22T16:42:04.797The optimization target should be clearly specified in this case (c.f. this related problem) since the original code and transposed code can have different lengths due to different numbers of newlines.
– Joel – 2019-09-22T18:22:45.313@Joel How is it not clear? Your source code size is measure like in any other code-golf challenge. – Adám – 2019-09-22T18:24:04.343
OK. Then you could add sth. like "the target is to optimize the byte count of the original source code. The byte count of the transposed version does not matter". – Joel – 2019-09-22T18:35:48.970
@Joel You wish… – Adám – 2019-09-22T18:37:29.870
Was able to do a couple of the other rip-offs in Turing Machine Language, but I think this challenge may have bested that language's capabilities (or perhaps more accurately my capabilities with it). – ouflak – 2019-09-23T10:42:03.067
@ouflak Isn't it like — per definition — possible to solve this challenge in Turing Machine Language‽ – Adám – 2019-09-23T10:43:21.357
@Adám, Hence my qualification in parethesis. I could put together a limited case I suppose.... – ouflak – 2019-09-23T10:45:00.803
@Adám Similarly, this challenge would be very difficult in Runic, due to its language features/restrictions. Just managing the stack while reading the input would be troublesome. Possible? Yes. Fun, not really. – Draco18s no longer trusts SE – 2019-09-23T13:48:43.210
@nimi You can assume a non-empty array. – Adám – 2019-09-23T20:55:25.867
@SriotchilismO'Zaic Well, some languages cannot distinguish between various 0×n arrays… Anyway, clarified OP to minimum 1×1 – Adám – 2019-09-23T20:56:26.070