text:
Reorder a matrix, twice
You are given a square \$n \times n\$ matrix \$A\$, and a list (or vector) \$u\$ of length \$n\$ containing the numbers \$1\$ through \$n\$ (or \$0\$ through \$n-1\$). Your task is to reorder the columns and rows of the matrix \$A\$ according to the order specified in \$u\$.
That is, you will construct  a matrix \$B\$ where the \$(i,j)\$-th element is the \$(u(i),u(j))\$-th element of \$A\$. You should also output the inverse of this action; that is, the (i,j)-th element of \$A\$ will end up at position \$(u(i),u(j))\$ in a new matrix \$C\$.
For example, given $$A = \begin{bmatrix} 11 &12& 13 \\ 21& 22& 23 \\ 31& 32& 33 \end{bmatrix},\quad u=\begin{bmatrix}3 & 1 & 2\end{bmatrix}$$
the output should be $$B = \begin{bmatrix}33 & 31 & 32 \\ 13 & 11 & 12 \\ 23 & 21 & 22 \end{bmatrix},\quad C= \begin{bmatrix}22 & 23 & 21 \\32 & 33 & 31 \\ 12 & 13 & 11 \end{bmatrix}$$
You may take input and output through any of the default I/O methods. You do not have to specify which matrix is \$B\$ or \$C\$, as long as you output both. You may assume \$A\$ only contains positive integers, and you may use 1- or 0-based indexing for \$u\$. You must support matrices up to at least size \$64 \times 64\$.
Example
===== Input =====
A =
 35     1     6    26    19    24
  3    32     7    21    23    25
 31     9     2    22    27    20
  8    28    33    17    10    15
 30     5    34    12    14    16
  4    36    29    13    18    11
u=
  3 5 6 1 4 2

==== Output =====
B =
  2    27    20    31    22     9
 34    14    16    30    12     5
 29    18    11     4    13    36
  6    19    24    35    26     1
 33    10    15     8    17    28
  7    23    25     3    21    32
C =
 17    15     8    10    28    33
 13    11     4    18    36    29
 26    24    35    19     1     6
 12    16    30    14     5    34
 21    25     3    23    32     7
 22    20    31    27     9     2

Sandbox

Can we output without the empty line here, that is, like this? (there is no ambiguity) Or, failing that, use 0 as separator?

@LuisMendo Sure no problem.

Is 1-indexing required for this? Can we use 0-indexing and input u = [2, 0, 1]?

@ValueInk See the first sentence, [...] containing the numbers 1 through n (or 0 through n−1)

MATL, 15 13 bytes
t3$)&Gw&St3$)

Inputs u,  then A.
Outputs B, then C without a separator, as there is no ambiguity.
Try it online!
Explanation
t     % Take input u implicitly. Duplicate u
3$)   % Take input A implicitly. Index A with u as row and column indices
&G    % Push the two inputs again: u, A
w     % Swap
&S    % Push indices that would make u sorted. Call that v
t     % Duplicate v
3$)   % Index A with v as row as column indices. Display implcitly

R, 42 bytes
function(A,o)list(A[o,o],A[I<-order(o),I])

Try it online!
Takes A as a matrix and 1-based indexes o.

Octave, 33 bytes
@(A,u){A(u,u) A([~,v]=sort(u),v)}

Try it online!
Thanks to Luis for correcting an error and saving several bytes!
Basic indexing works here for both tasks, by defining a vector \$ v \$ equal to the permutation that undoes \$ u \$. That is, if \$ u = ( 3, 1, 2 ) \$ then the first element of \$ v \$ is 2, since 1 is in the second position of \$ u \$. This is accomplished with Octave's sort function.

Python 3 with numpy, 51 45 bytes
lambda m,p:[m[x][:,x]for x in(p,p.argsort())]

Try it online!
-6 bytes thanks to @xnor
The function takes two arguments: a numpy matrix and a permutation vector having values from \$0\$ to \$n-1\$.

45 bytes as lambda

@xnor Thanks ! I felt that it could be shortened in some way but the idea of using a for-loop did not come to my mind.

Wolfram Language (Mathematica), 30 bytes
ii[[#,#]]&/@{#,Ordering@#}&

Try it online!
Input as f[A][u].

PowerShell, 78 73 71 bytes
($A,$u=$args)|%{$A[$u]|%{''+$_[$u]}
$u=1..$u.count|%{$u.indexof($_-1)}}

Try it online.

Jelly, 13 bytes
ŒJṁ⁸ịⱮ⁹,Ụ¤œị⁸

Try it online!

J, 19 bytes
(]/:~"1/:)"_ 1],:/:

Try it online!

Main verb ]/:~"1/:

The right most /: sorts the left arg (matrix) according to the order that would sort the right arg (specified order).  This sorts rows.
Now that result get sorted /:~"1 again according to the order specified ].  But this time we're sorting with rank 1, ie, we're sorting each row, which has the effect of sorting columns.

],:/: We apply the above using both the order specified ] and the grade up of the order specified /:.  This gives us the 2 results we want.

Nice! I was thinking about applying sort+transpose twice, but will end up longer.

u is allowed to be 0-based, so sort (/:) could be indexing ({) with swapped args

J, 17 16 15 14 bytes
-1 thanks to @Jonah
([{"1{)~(,:/:)

Try it online!

Nice! You can get down to 14 with ([{"1{)~(,:/:): Try it online!

Btw, random question: I noticed you golf (very well) in J, APL and K.  Curious which you prefer overall?  Also I seem to recall you saying you used K professionally, am I remembering that right?

@Jonah if i must choose one, that would definitely be k (pls ping me in the k chat if you wanna know the reasons), but i do enjoy golfing in all array languages. sadly, i'm not one of the lucky few who can have a k-language job

JavaScript (Node.js), 77 70 68 bytes
a=>g=(u,v=[])=>[u.map((i,x)=>u.map(j=>a[i][j],v[i]=x)),v&&g(v,0)[0]]

Try it online!

It took me a minute to figure out what v was. It's neat how you found a use for non-strict mode silent failure of property assignment to a primitive value, and used that for your recursion base-case.

APL (Dyalog Extended), 12 bytesSBCS
Full program. Prompts for \$u\$ and then \$A\$. Prints \$C\$ next to \$B\$, separated by two spaces
⌷∘⎕¨⍋¨⍛⍮⍨⍮⍨⎕

Try it online!
⎕ prompt for \$u\$; [3,1,2]
⍮⍨ juxtaposition-selfie; [[3,1,2],[3,1,2]]
⍋¨ permutation-inversion of each; [[2,3,1],[2,3,1]]
⍛ then
⍮⍨ juxtapose with itself [[[2,3,1],[2,3,1]],[[3,1,2],[3,1,2]]]
⌷ reorder
∘ the value of
⎕ \$A\$ as inputted
¨ using each pair as a set of orders, one order per axis

Charcoal, 24 bytes
Ｅ⟦ηＥη⌕ηκ⟧Ｅθ⪫Ｅθ§§θ§ιμ§ιξ

Try it online! Link is to verbose version of code. 0-indexed. Note: Trailing space. Explanation:
    η                       Input `u`
   Ｅ                        Map over elements
     ⌕                      Index of
       κ                    Current index in
      η                     Input `u`
  η                         Input `u`
Ｅ⟦      ⟧                   Map over `u` and its inverse
          θ                 Input `A`
         Ｅ                  Map over elements
             θ              Input `A`
            Ｅ               Map over elements
                θ           Input `A`
               §            Indexed by
                  ι         Current vector
                 §          Indexed by
                   μ        Row index
              §             Indexed by
                     ι      Current vector
                    §       Indexed by
                      ξ     Column index
           ⪫                Join with spaces for readability
                            Implicitly print

Kotlin, 213 bytes
{a:List<List<Int>>,u:List<Int>->val s=u.size
for(l in List(s){r->List(s){c->a[u[r]][u[c]]}})println(l.joinToString(" "))
for(l in List(s){r->List(s){c->a[u.indexOf(r)][u.indexOf(c)]}})println(l.joinToString(" "))}

Try it online!

APL+WIN, 21 bytes
Prompts for input of u followed by a. Outputs b immediately over the top of c with no separator:
(a←⎕)[u;u←⎕]⋄a[⍋u;⍋u]

Try it online! Courtesy of Dyalog Classic

Perl 5, 79 bytes
sub{$[=1;($A,$u)=@_;@$v[@$u]=(1..@$u);map{$x=$_;[map[@$_[@$x]],@$A[@$x]]}$u,$v}

Try it online!

Jelly,  12 11  13 bytes
+2 :( to fix cases when B = C
ṭþ`œị¥@Ƭị@2,0

A dyadic Link accepting a list of lists, A (n by n), on the left and a list of the first n integers on the right, u, which yields a list of lists of lists, [B, C].
Try it online!
How?
ṭþ`œị¥@Ƭị@2,0 - Link: A, u
       Ƭ      - collect up while the results are no longer unique, applying:
     ¥@       -   last two links as a dyad with swapped arguments:
  `           -     use left (u) as both arguments of:
 þ            -       outer product with:
ṭ             -         tack
   œị         -     multi-dimensional index into last result (starting with A)
                ...at the end of the Ƭ-loop we have [A,B,...,C]
                                                 or [A] if A=B=C
                                                 or [A,B] if B=C but A!=B
          2,0 - literal pair [2,0]
         @    - with swapped arguments:
        ị     -   index into (1-based & modular) -> [B,C]
                                                 or [A,A]=[B,C] if A=B=C
                                                 or [B,B]=[B,C] if B=C

C++ (gcc), 148 142 bytes
#import<queue>
#define q[o[i/z]*z+o[i%z]]
using V=std::vector<int>;int f(V m,V o,V&r,V&R,int z){int i=z*z;for(r=R=V(i);i--;r[i]=m q)R q=m[i];}

Try it online!
Thanks to @ceilingcat suggestion to use #import <queue> instead of <vector> which mysteriously brings std::vector

@ceilingcat now I see that import queue gives me access to vector.. Is it compiler dependant? I'm trying to search information about this but found nothing

Tips for golfing in C++

q, 26 bytes
{Y:iasc y;(x[y;y];x[Y;Y])}

iasc returns indexes to sort it's argument.

Clean, 91 bytes
import StdEnv
$a u=map(\l={{a.[i,j]\\j<-l}\\i<-l})[u,[k\\i<-[0..]&_<-u,j<-u&k<-[0..]|j==i]]

Try it online!
Defines $ :: {{a}} [Int] -> [{{a}}] (used with a = Int) taking an array of arrays and a list of zero-based indices, returning a list of arrays of arrays containing B and C.

Python 3, 91 bytes
lambda a,u:[[[a[y][x]for x in t]for y in t]for t in[u,[u.index(i)for i in range(len(u))]]]

Try it online!
Takes parameters as a 2D and 1D list and returns a list containing two 2D lists B and C. I'm not sure if there's a cleaner way to do all the for-loops.


text:
Golf (6-card) Golf!
Golf Golf!
This is my first challenge, so please be gentle! The challenge is to write a program that will output the correct score for a layout in the card game "Golf."
The card game Golf has many variations. The house rules I use follow the standard rules for Six-Card Golf given by Pagat, with one slight difference. There is already a similar challenge here but I think this one is more interesting because it requires you to take the orientation of the cards into account.
Each player has a 2x3 layout of cards. By the end of each round all cards are turned face up and scored as follows:

Each ace counts 1 point.
Each two counts minus two points.
Each numeral card from 3 to 10 scores face value.
Each Jack or Queen scores 10 points.
Each King scores zero points.
A pair of equal cards in the same column scores zero points for the column (even if the equal cards are twos).
A set of three equal cards in the same row scores zero points for the row (even if the equal cards are twos).

Input
The input can be a string or array of any kind.
Output
An integer representing the score of the Golf hand.
Examples
These examples use the notation A23456789TJQK but you need not use that notation in your answer.
Layout
AK3
J23

Score
9
-----------------------
Layout
25Q
25J

Score
20
-----------------------
Layout
T82
T8A

Score
-1
-----------------------
Layout
QQQ
234

Score
5
-----------------------
Layout
TJQ
QTJ

Score
60
-----------------------
Layout
888
382

Score
1
-----------------------
Layout
888
888

Score
0

This is code golf, so the shortest answer in bytes wins!

Shouldn't the first example score 9?

Nice first challenge! As a slight note, the "(even if the equal cards are twos)" parts are unnecessary and slightly confusing in this challenge, since the resulting score isn't compared with other players' scores. Instead, you may want to clarify that the all-equal column and row scores override the individual scores of the cards in their respective column or row.

"...or array of any kind" - must the content be characters (or may we circumvent the mapping of characters to values)?

@JonathanAllan Hm, it does say "These examples use the notation A23456789TJQK but you need not use that notation in your answer."

@EriktheOutgolfer thanks!

I'd suggest adding a test case with a column AND a row being equal, like JJJ 2J2 -> -4.

@JonathanAllan thanks for noticing that error in the first example. I didn't want to specify input format so there is no requirement that the input be characters.

I see nothing about how many decks are used (the rules say larger games use multiple decks) so suggested test case of [5,5,5],[5,5,5] = 0. Unless we're guaranteed at most 4 of one card?

@Veskah I didn't consider that possibility since I've never played the game with >1 deck but I can add the test case.

Jelly, 9 bytes
n/aEÐḟẎḞS

Try it online!
-1 thanks to Jonathan Allan.
Takes input in the form of [[A, B, C], [D, E, F]], where each of A, ..., F are elements in \$(1,-2,3,4,5,6,7,8,9,10,10.1,10.2,0)\$, representing values \$A,2,3,4,5,6,7,8,9,T,J,Q,K\$ respectively.

Haskell, 107 103 98 bytes
f m=sum[min 10k|r<-m,o<-m,any(/=r!!0)r,(j,x)<-zip o r,j/=x,(k,c)<-zip[-2..]"2 KA 3456789TJQ",c==x]

Try it online!
Takes advantage of the fact there are only two rows. We double iterate over the rows taking a row r and a row o. When they are the same row the result will always be zero (due to the "columns" matching) so we will only consider the two iterations in which r and o refer to distinct rows. I zero out rows by first checking whether any entries in the row are not equal to the first. If the row is all equal this will be false and the list will be empty, with a sum of 0. Otherwise I zip this row with the other and iterate over the pairs that aren't equal (this zeroes out equal columns in a similar manner). Finally I index a list of card ranks starting with -2 padding with spaces as necessary to map each rank to its score. I just have to use min 10 to clamp that index to make jacks and queens cost 10 rather than 11 and 12.
EDIT: thanks to @xnor for taking off 4 bytes! I didn't know you could put identifiers directly after number literals that's really cool!
EDIT2: Thanks again to @xnor for another 5 bytes! Great idea to iterate over the rows like that

Nice solution! Two smaller optimizations: you don't need the space after 10, and it's shorter to omit the @(a:_) and instead write r!!0 for a.

Another thought: since a%a and b%b are zero, it looks like you can define f directly by iterating over pairs of lines like this.

Charcoal, 50 bytes
Ｆ²⊞υＳ≔⁰ζＦ⭆υΦι∧⊙ι¬⁼λν⊙υ¬⁼λ§νμ≡ι2≧⁻²ζA≦⊕ζKω≧⁺∨ΣιχζＩζ

Try it online! Link is to verbose version of code. Explanation:
Ｆ²⊞υＳ

Read the layout into an array.
≔⁰ζ

Initialise the score to zero.
Ｆ⭆υΦι∧⊙ι¬⁼λν⊙υ¬⁼λ§νμ

Filter on the input, removing characters that equal all of the characters in its row or column.
≡ι

Switch over each remaining character.
2≧⁻²ζ

2 scores -2.
A≦⊕ζ

A scores 1. (These 4 bytes could be removed if 1 was used to denote 1, but IMHO that's an abuse of the input format.)
Kω

Do nothing for K.
≧⁺∨Σιχζ

Otherwise digits score their value and other letters score 10.
Ｉζ

Cast the sum to string for implicit print.

JavaScript (ES6),  97 95  93 bytes
Takes input as an array of 2 arrays of 3 characters.
a=>a.map((r,i)=>r.map((c,j)=>t-=c!=a[i^1][j]&r!=c+[,c,c]?{K:[],2:2,A:-1}[c]||-c||~9:0),t=0)|t

Try it online!
Commented
a =>                        // a[] = input
  a.map((r, i) =>           // for each row r[] at position i:
    r.map((c, j) =>         //   for each card c at position j in r[]:
      t -=                  //     update t:
        c != a[i ^ 1][j] &  //       if c is not equal to the sibling card in the other row
        r != c + [, c, c] ? //       and r is not made of 3 times the same card:
          { K: [],          //         add 0 point for a King (but [] is truthy)
            2: 2,           //         subtract 2 points for a Two
            A: -1           //         add 1 point for an Ace
          }[c]              //
          || -c             //         or add the face value
          || ~9             //         or add 10 points (Jack or Queen)
        :                   //       else:
          0                 //         add nothing
    ),                      //   end of inner map()
    t = 0                   //   start with t = 0
  ) | t                     // end of outer map; return t

J, 39 28 bytes
[:+/@,]<.@*]+:&(1=#@~.)"1/|:

Try it online!
Credit to Erik the Outgolfer and Jonathan Allen for the input encoding idea.
explanation
A very "J" solution.  I'll explain by example...
Let's take the input:
AK3
J23

and apply this encoding:
┌─┬──┬─┬─┬─┬─┬─┬─┬─┬──┬────┬────┬─┐
│A│2 │3│4│5│6│7│8│9│T │J   │Q   │K│
├─┼──┼─┼─┼─┼─┼─┼─┼─┼──┼────┼────┼─┤
│1│_2│3│4│5│6│7│8│9│10│10.1│10.2│0│
└─┴──┴─┴─┴─┴─┴─┴─┴─┴──┴────┴────┴─┘

which produces:
   1  0 3
10.1 _2 3

Let's look at the first part of the solution, eliding some detail to start:
] (...)"1/ |:

This says take the input ] and its transpose |: and create a
"multiplication table" of all the combinations, except instead of
multiplication we'll apply the verb in parenthesis.  The rank "1 specifier
ensures that we take all combinations of rows from both arguments, but since
the rows of the transpose are the columns of the original matrix, this means
we'll be taking all combinations of rows and columns.  That is, we'll be doing:
  Rows                            Cols
┌─────────┐                     ┌──────┐
│1 0 3    │                     │1 10.1│
├─────────┤  "times" table      ├──────┤
│10.1 _2 3│                     │0 _2  │
└─────────┘                     ├──────┤
                                │3 3   │
                                └──────┘

which produces:

┌───────────────────────┬─────────────────────┬────────────────────┐
│┌─────┬────┬──────┐    │┌─────┬────┬────┐    │┌─────┬────┬───┐    │
││1 0 3│verb│1 10.1│    ││1 0 3│verb│0 _2│    ││1 0 3│verb│3 3│    │
│└─────┴────┴──────┘    │└─────┴────┴────┘    │└─────┴────┴───┘    │
├───────────────────────┼─────────────────────┼────────────────────┤
│┌─────────┬────┬──────┐│┌─────────┬────┬────┐│┌─────────┬────┬───┐│
││10.1 _2 3│verb│1 10.1│││10.1 _2 3│verb│0 _2│││10.1 _2 3│verb│3 3││
│└─────────┴────┴──────┘│└─────────┴────┴────┘│└─────────┴────┴───┘│
└───────────────────────┴─────────────────────┴────────────────────┘

Now the verb we apply to each of these combos is +:&(1=#@~.) and this verb
returns false if "either argument consists of a single repeated item" and true
otherwise.  It does this by taking the nub, or uniq ~., asking if its length
is one 1=#, and taking the nor of the result +:.
That is, this will return a boolean mask with the same shape as the input matrix,
but with zeros for any item in a row or column of all equal items.
1 1 0
1 1 0

Now we simply mutliply the original matrix by this mask and take the floor
]<.@*:
1   0 0
10 _2 0

and then flatten and sum the result of that: +/@,
9

PHP, 145 109 bytes
After using the default A23456789TJQK coding for inputs and not getting a good result, I switched to using this coding similar to other answers:
A |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |  T |    J |    Q | K
1 | -2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 10.1 | 10.2 | 0

Input is a two dimensional array in this format: [[1,0,3],[10.1,-2,3]]. Basically checks the row (using min and max) and the column for each card to not contain equal values and then adds card value to the total score and at the end prints integer portion of the total score.
function($a){for(;$x++<2;)for($i=3;$i--;)min($r=$a[$x-1])-max($r)&&$r[$i]-$a[$x%2][$i]&&$s+=$r[$i];echo$s^0;}

Try it online! (Note: TIO for PHP is broken at the moment, because of a wrong version upgrade, but should come back OK)

Japt, 22 bytes
c xÈf *YgUïUÕ me_â Ê>1

Try it

Python 3, 79 bytes
lambda d:sum([({*a}!={x}!={y})*int(x)for a,b in(d,d[::-1])for x,y in zip(a,b)])

Try it online!
Uses the same input format as some other answers, values \$1,-2,3,4,5,6,7,8,9,10,10.1,10.2,0\$ for the cards.

Python 3, 118 bytes
More readable input format
lambda d:sum([({*a}!={x}!={y})*[10,10,10,1,0,-2,int(x,36)]['TJQAK2'.find(x)]for a,b in(d,d[::-1])for x,y in zip(a,b)])

Try it online!

Kotlin, 159 bytes
Lambda takes 1.3456789TJQ0 as input. The outer code takes A23456789TJQK as input, converts the ace, two, and king so the math works out, and displays the cards & score.
{d:List<String>->Int
var s=0
for(r in 0..1)for(c in 0..2)if((d[r][0]!=d[r][1]||d[r][1]!=d[r][2])&&d[0][c]!=d[1][c]){
val n=d[r][c]-'0'
s+=if(n>9)
10
else
n}
s}

Try it online!

source: Stack Exchange

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

sort: votes


text:
I reverse the source code, you reverse the input!
Yet another blatant 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 string input/argument. The tricky part is that if I reverse your source code, the output must be reversed too.
For simplicity, you can assume that the input is always a single line string containing only ASCII letters (a-z), digits (0-9) and spaces.
Should support an input of at least 8 characters long (longer than 8 is not necessary).
Behaviour for empty input is undefined.
Examples
Let's say your source code is ABC and its input is xyz. If I write CBA instead and run it, the output must be zyx.
Let's say your source code is ABC and its input is 96. If I write CBA instead and run it, the output must be 69.
A single leading or trailing white-space is acceptable as long as it is consistent in both normal and reversed outputs.

JavaScript, 32 bytes
s=>s//``nioj.)(esrever.]s...[>=s

Reversed:
s=>[...s].reverse().join``//s>=s

Well done, didn't know JS doesn't have a builtin reverse for strings. By the way, TIO links usually make answers more likable: Try it online! Reversed

There is no string reverse. [...s] converts to array, which is reversed then joined back together as a string.

If you also stumbled over .join\`` - have a look at Tagged Templates

APL (Dyalog Unicode), 3 2 bytesSBCS
-1 byte thanks to dzaima
⌽⊂

Try it online!
⊂ enclose the argument to treat it as a singleton: [1,2,3] → [[1,2,3]]
⌽ reverse (has no effect on singletons): [[1,2,3]] → [[1,2,3]]
An enclosed array prints with a leading an a trailing space.
!enilno ti yrT
⌽ reverse (has no effect on singletons): [1,2,3] → [3,2,1]
⊂ enclose: [3,2,1] → [[3,2,1]]
An enclosed array prints with a leading an a trailing space.

Nice.  Digraphs make this more difficult in J... haven’t come up with anything yet

I was pretty happy with my 5 byte solution, but yours is so elegant.  {⍵⋄⍵⌽⊢}

@AndrewOgden That wouldn't work though, as the reverse is }⊢⌽⍵⋄⍵{

@Adám Lol, I was so focused on the stuff inside the brackets, I completely forgot that they also needed reversing.

@AndrewOgden Tacit is the way to go. A more "correct" solution would be ⌽⊢⊢

@Adám Now I need to go check my answer to another problem :|

@Adám Is that considered a complete function? even in reverse?

@AndrewOgden Sure, why not?

@Adám No, I recognized that it would run, somewhere along the way I'd gotten it into my head that those didn't count in the context of code golf ⍨

@AndrewOgden Sure, but let's continue in chat…

@Adám If you have a second, could you explain what you meant by this comment, I guess I'ma missing something.  https://codegolf.stackexchange.com/questions/221321/to-count-the-sum-of-all-unicode-characters-of-a-given-input-under-an-interesting/221330#comment514839_221330

Bash, 9 bytes
cat # ver

Reversed:
rev # tac

Try it online! !enilno ti yrT

This would be easier if the challenge was to reverse the line order; then I could just use cat.

Keg, 3 2 bytes
#?

Try it online! or !enilno ti yrT
Explained
#? #Implicit cat
?# Reversed input

Heh. That's right. Keg can stand up to those 2-byte answers too (and using pure, plain ASCII)!
Old Program
^#?

Try it online!
Or
!enilno ti yrT
Because two can play the 3-byte game. That's why. (did I mention that's 3 bytes of utf8 ASCII?)
^#? #Reverse an empty stack, taking implicit input

?#^ #take input

interpreter where

Ruby, 21 bytes
->x{x}#}esrever.x{x>-

Try it online!
->x{x.reverse}#}x{x>-

!enilno ti yrT

Stack Cats -m, 4 bytes
|>I|

Try it online!
Try it reversed!
This works for any inputs that don't contain null bytes.
Explanation
Wow, I've reached the point where I'm writing these by hand...
The full program is |>I|I<|.
|   Reverse the entire stack down to the EOF marker -1 (since there are no zeros in the input).
>   Move one stack over to the right (which only contains zeros).
I   Does nothing on zero.
|   Does nothing on zero.
I   Does nothing on zero.
<   Move back to the initial stack.
|   Reverse the input once more.

As in the solution to the previous challenge, since the centre command | does nothing, so does the entire program.
The reversed program is then |I>|<I|.
|   Reverse the entire stack down to the EOF marker -1 (since there are no zeros in the input).
I   Move the -1 one stack to the left and turn it into a +1.
>   Move back to the initial stack.
|   Reverse it again, but this time without the EOF marker.
<   Move back to the left.
I   Move the +1 back onto the initial stack and turn it into a -1 again.
|   Reverse the entire stack. We now have the -1 as an EOF marker again at the bottom
    and the rest of the stack has been reversed three times, i.e. one net reversal.

Interestingly, if we use this reversing program without -m we still get a working solution this time, so the only additional bytes incurred by omitting -m are those we get from mirroring the code.

Stack Cats, 7 bytes
|I<|>I|

Try it online!
Try it reversed!
Explanation
The reversed version of this program is |I>|<I|, the same as above so we can ignore that. But the non-reversed version differs. Since the <> now point the other way, the centre command ends up doing nothing, so the program becomes a cat:
|   Reverse the entire stack down to the EOF marker -1 (since there are no zeros in the input).
I   Move the -1 one stack to the left and turn it into a +1.
<   Move another stack to the left, which contains only zeros.
|   Does nothing on zero.

And thus, >I| exactly undo the first half of the program.

Haskell, 11 bytes
id--esrever

Try it online! Try it reversed!

Pyth, 5 3 bytes
z_k
-2 bytes by realizing the newline flips around anyways
Explanation:
z   # Implicitly print the input
 _k # Implicitly print the reversed empty string

Reversed Explanation:
k     # Implicitly print the empty string
 _z   # Implicitly print the reversed input

Turing Machine Language, 14324 14321 13257 bytes
0 ( ( l 6;
0 * * l 2;
1 _ _ l 2;
2 _ ( r 3;
3 _ _ r 4;
4 _ _ l 3);
4 * * r 2;
3) _ ) l 5;
3 * * r 3;
5 ( ( * 0;
5 * * l 5;
6 _ _ l 7;
7 _ ] r 8;
8 ) ) l 9;
8 * * r 8;
9 0 @ l c0;
9 1 @ l c1;
9 2 @ l c2;
9 3 @ l c3;
9 4 @ l c4;
9 5 @ l c5;
9 6 @ l c6;
9 7 @ l c7;
9 8 @ l c8;
9 9 @ l c9;
9 a @ l a;
9 A @ l A;
9 b @ l b;
9 B @ l B;
9 c @ l c;
9 C @ l C;
9 d @ l d;
9 D @ l D;
9 e @ l e;
9 E @ l E;
9 f @ l f;
9 F @ l F;
9 g @ l g;
9 G @ l G;
9 h @ l h;
9 H @ l H;
9 i @ l i;
9 I @ l I;
9 j @ l j;
9 J @ l J;
9 k @ l k;
9 K @ l K;
9 l @ l l;
9 L @ l L;
9 m @ l m;
9 M @ l M;
9 n @ l n;
9 N @ l N;
9 o @ l o;
9 O @ l O;
9 p @ l p;
9 P @ l P;
9 q @ l q;
9 Q @ l Q;
9 r @ l r;
9 R @ l R;
9 s @ l s;
9 S @ l S;
9 t @ l t;
9 T @ l T;
9 u @ l u;
9 U @ l U;
9 v @ l v;
9 V @ l V;
9 w @ l w;
9 W @ l W;
9 x @ l x;
9 X @ l X;
9 y @ l y;
9 Y @ l Y;
9 z @ l z;
9 Z @ l Z;
c0 ] ] l c0a;
c0 * * l c0;
c0a _ 0 r @0;
c0a * * l c0a;
@0 @ 0 l nC;
@0 * * r @0;
c1 ] ] l c1a;
c1 * * l c1;
c1a _ 1 r @1;
c1a * * l c1a;
@1 @ 1 l nC;
@1 * * r @1;
c2 ] ] l c2a;
c2 * * l c2;
c2a _ 2 r @2;
c2a * * l c2a;
@2 @ 2 l nC;
@2 * * r @2;
c3 ] ] l c3a;
c3 * * l c3;
c3a _ 3 r @3;
c3a * * l c3a;
@3 @ 3 l nC;
@3 * * r @3;
c4 ] ] l c4a;
c4 * * l c4;
c4a _ 4 r @4;
c4a * * l c4a;
@4 @ 4 l nC;
@4 * * r @4;
c5 ] ] l c5a;
c5 * * l c5;
c5a _ 5 r @5;
c5a * * l c5a;
@5 @ 5 l nC;
@5 * * r @5;
c6 ] ] l c6a;
c6 * * l c6;
c6a _ 6 r @6;
c6a * * l c6a;
@6 @ 6 l nC;
@6 * * r @6;
c7 ] ] l c7a;
c7 * * l c7;
c7a _ 7 r @7;
c7a * * l c7a;
@7 @ 7 l nC;
@7 * * r @7;
c8 ] ] l c8a;
c8 * * l c8;
c8a _ 8 r @8;
c8a * * l c8a;
@8 @ 8 l nC;
@8 * * r @8;
c9 ] ] l c9a;
c9 * * l c9;
c9a _ 9 r @9;
c9a * * l c9a;
@9 @ 9 l nC;
@9 * * r @9;
a ] ] l aa;
a * * l a;
aa _ a r @a;
aa * * l aa;
@a @ a l nC;
@a * * r @a;
A ] ] l Aa;
A * * l A;
Aa _ A r @A;
Aa * * l Aa;
@A @ A l nC;
@A * * r @A;
b ] ] l ba;
b * * l b;
ba _ b r @b;
ba * * l ba;
@b @ b l nC;
@b * * r @b;
B ] ] l Ba;
B * * l B;
Ba _ B r @B;
Ba * * l Ba;
@B @ B l nC;
@B * * r @B;
c ] ] l ca;
c * * l c;
ca _ c r @c;
ca * * l ca;
@c @ c l nC;
@c * * r @c;
C ] ] l Ca;
C * * l C;
Ca _ C r @C;
Ca * * l Ca;
@C @ C l nC;
@C * * r @C;
d ] ] l da;
d * * l d;
da _ d r @d;
da * * l da;
@d @ d l nC;
@d * * r @d;
D ] ] l Da;
D * * l D;
Da _ D r @D;
Da * * l Da;
@D @ D l nC;
@D * * r @D;
e ] ] l ea;
e * * l e;
ea _ e r @e;
ea * * l ea;
@e @ e l nC;
@e * * r @e;
E ] ] l Ea;
E * * l E;
Ea _ E r @E;
Ea * * l Ea;
@E @ E l nC;
@E * * r @E;
f ] ] l fa;
f * * l f;
fa _ f r @f;
fa * * l fa;
@f @ f l nC;
@f * * r @f;
F ] ] l Fa;
F * * l F;
Fa _ F r @F;
Fa * * l Fa;
@F @ F l nC;
@F * * r @F;
g ] ] l ga;
g * * l g;
ga _ g r @g;
ga * * l ga;
@g @ g l nC;
@g * * r @g;
G ] ] l Ga;
G * * l G;
Ga _ G r @G;
Ga * * l Ga;
@G @ G l nC;
@G * * r @G;
h ] ] l ha;
h * * l h;
ha _ h r @h;
ha * * l ha;
@h @ h l nC;
@h * * r @h;
H ] ] l Ha;
H * * l H;
Ha _ H r @H;
Ha * * l Ha;
@H @ H l nC;
@H * * r @H;
i ] ] l ia;
i * * l i;
ia _ i r @i;
ia * * l ia;
@i @ i l nC;
@i * * r @i;
I ] ] l Ia;
I * * l I;
Ia _ I r @I;
Ia * * l Ia;
@I @ I l nC;
@I * * r @I;
j ] ] l ja;
j * * l j;
ja _ j r @j;
ja * * l ja;
@j @ j l nC;
@j * * r @j;
J ] ] l Ja;
J * * l J;
Ja _ J r @J;
Ja * * l Ja;
@J @ J l nC;
@J * * r @J;
k ] ] l ka;
k * * l k;
ka _ k r @k;
ka * * l ka;
@k @ k l nC;
@k * * r @k;
K ] ] l Ka;
K * * l K;
Ka _ K r @K;
Ka * * l Ka;
@K @ K l nC;
@K * * r @K;
l ] ] l la;
l * * l l;
la _ l r @l;
la * * l la;
@l @ l l nC;
@l * * r @l;
L ] ] l La;
L * * l L;
La _ L r @L;
La * * l La;
@L @ L l nC;
@L * * r @L;
m ] ] l ma;
m * * l m;
ma _ m r @m;
ma * * l ma;
@m @ m l nC;
@m * * r @m;
M ] ] l Ma;
M * * l M;
Ma _ M r @M;
Ma * * l Ma;
@M @ M l nC;
@M * * r @M;
n ] ] l na;
n * * l n;
na _ n r @n;
na * * l na;
@n @ n l nC;
@n * * r @n;
N ] ] l Na;
N * * l N;
Na _ N r @N;
Na * * l Na;
@N @ N l nC;
@N * * r @N;
o ] ] l oa;
o * * l o;
oa _ o r @o;
oa * * l oa;
@o @ o l nC;
@o * * r @o;
O ] ] l Oa;
O * * l O;
Oa _ O r @O;
Oa * * l Oa;
@O @ O l nC;
@O * * r @O;
p ] ] l pa;
p * * l p;
pa _ p r @p;
pa * * l pa;
@p @ p l nC;
@p * * r @p;
P ] ] l Pa;
P * * l P;
Pa _ P r @P;
Pa * * l Pa;
@P @ P l nC;
@P * * r @P;
q ] ] l qa;
q * * l q;
qa _ q r @q;
qa * * l qa;
@q @ q l nC;
@q * * r @q;
Q ] ] l Qa;
Q * * l Q;
Qa _ Q r @Q;
Qa * * l Qa;
@Q @ Q l nC;
@Q * * r @Q;
r ] ] l ra;
r * * l r;
ra _ r r @r;
ra * * l ra;
@r @ r l nC;
@r * * r @r;
R ] ] l Ra;
R * * l R;
Ra _ R r @R;
Ra * * l Ra;
@R @ R l nC;
@R * * r @R;
s ] ] l sa;
s * * l s;
sa _ s r @s;
sa * * l sa;
@s @ s l nC;
@s * * r @s;
S ] ] l Sa;
S * * l S;
Sa _ S r @S;
Sa * * l Sa;
@S @ S l nC;
@S * * r @S;
t ] ] l ta;
t * * l t;
ta _ t r @t;
ta * * l ta;
@t @ t l nC;
@t * * r @t;
T ] ] l Ta;
T * * l T;
Ta _ T r @T;
Ta * * l Ta;
@T @ T l nC;
@T * * r @T;
u ] ] l ua;
u * * l u;
ua _ u r @u;
ua * * l ua;
@u @ u l nC;
@u * * r @u;
U ] ] l Ua;
U * * l U;
Ua _ U r @U;
Ua * * l Ua;
@U @ U l nC;
@U * * r @U;
v ] ] l va;
v * * l v;
va _ v r @v;
va * * l va;
@v @ v l nC;
@v * * r @v;
V ] ] l Va;
V * * l V;
Va _ V r @V;
Va * * l Va;
@V @ V l nC;
@V * * r @V;
w ] ] l wa;
w * * l w;
wa _ w r @w;
wa * * l wa;
@w @ w l nC;
@w * * r @w;
W ] ] l Wa;
W * * l W;
Wa _ W r @W;
Wa * * l Wa;
@W @ W l nC;
@W * * r @W;
x ] ] l xa;
x * * l x;
xa _ x r @x;
xa * * l xa;
@x @ x l nC;
@x * * r @x;
X ] ] l Xa;
X * * l X;
Xa _ X r @X;
Xa * * l Xa;
@X @ X l nC;
@X * * r @X;
y ] ] l ya;
y * * l y;
ya _ y r @y;
ya * * l ya;
@y @ y l nC;
@y * * r @y;
Y ] ] l Ya;
Y * * l Y;
Ya _ Y r @Y;
Ya * * l Ya;
@Y @ Y l nC;
@Y * * r @Y;
z ] ] l za;
z * * l z;
za _ z r @z;
za * * l za;
@z @ z l nC;
@z * * r @z;
Z ] ] l Za;
Z * * l Z;
Za _ Z r @Z;
Za * * l Za;
@Z @ Z l nC;
@Z * * r @Z;
Sp ] ] l Sp1;
Sp * * l Sp;
Sp1 _ ~ r @Sp;
Sp1 * * l Sp1;
@Sp @ _ l nC;
@Sp * * r @Sp;
nC _ @ l Sp;
nC 0 0 * 9;
nC 1 1 * 9;
nC 2 2 * 9;
nC 3 3 * 9;
nC 4 4 * 9;
nC 5 5 * 9;
nC 6 6 * 9;
nC 7 7 * 9;
nC 8 8 * 9;
nC 9 9 * 9;
nC - - * 9;
nC a a * 9;
nC A A * 9;
nC b b * 9;
nC B B * 9;
nC c c * 9;
nC C C * 9;
nC d d * 9;
nC D D * 9;
nC e e * 9;
nC E E * 9;
nC f f * 9;
nC F F * 9;
nC g g * 9;
nC G G * 9;
nC h h * 9;
nC H H * 9;
nC i i * 9;
nC I I * 9;
nC j j * 9;
nC J J * 9;
nC k k * 9;
nC K K * 9;
nC l l * 9;
nC L L * 9;
nC m m * 9;
nC M M * 9;
nC n n * 9;
nC N N * 9;
nC o o * 9;
nC O O * 9;
nC p p * 9;
nC P P * 9;
nC q q * 9;
nC Q Q * 9;
nC r r * 9;
nC R R * 9;
nC s s * 9;
nC S S * 9;
nC t t * 9;
nC T T * 9;
nC u u * 9;
nC U U * 9;
nC v v * 9;
nC V V * 9;
nC w w * 9;
nC W W * 9;
nC x x * 9;
nC X X * 9;
nC y y * 9;
nC Y Y * 9;
nC z z * 9;
nC Z Z * 9;
nC ( ( * fC;
fC ] ] l fC1;
fC * * l fC;
fC1 _ [ * cl;
fC1 * * l fC1;
cl [ _ r cl;
cl ] _ r cl;
cl ~ _ r cl;
cl ( _ r clO;
clO ) _ * halt-accept;
clO * _ r clO;
cl ) ) * halt-accept;
cl * * r cl;
;lc r * * lc
;tpecca-tlah * ) ) lc
;Olc r _ * Olc
;tpecca-tlah * _ ) Olc
;Olc r _ ( lc
;lc r _ ~ lc
;lc r _ ] lc
;lc r _ [ lc
;1Cf l * * 1Cf
;lc * [ _ 1Cf
;Cf l * * Cf
;1Cf l ] ] Cf
;Cf * ) ) Cn
;9 * Z Z Cn
;9 * z z Cn
;9 * Y Y Cn
;9 * y y Cn
;9 * X X Cn
;9 * x x Cn
;9 * W W Cn
;9 * w w Cn
;9 * V V Cn
;9 * v v Cn
;9 * U U Cn
;9 * u u Cn
;9 * T T Cn
;9 * t t Cn
;9 * S S Cn
;9 * s s Cn
;9 * R R Cn
;9 * r r Cn
;9 * Q Q Cn
;9 * q q Cn
;9 * P P Cn
;9 * p p Cn
;9 * O O Cn
;9 * o o Cn
;9 * N N Cn
;9 * n n Cn
;9 * M M Cn
;9 * m m Cn
;9 * L L Cn
;9 * l l Cn
;9 * K K Cn
;9 * k k Cn
;9 * J J Cn
;9 * j j Cn
;9 * I I Cn
;9 * i i Cn
;9 * H H Cn
;9 * h h Cn
;9 * G G Cn
;9 * g g Cn
;9 * F F Cn
;9 * f f Cn
;9 * E E Cn
;9 * e e Cn
;9 * D D Cn
;9 * d d Cn
;9 * C C Cn
;9 * c c Cn
;9 * B B Cn
;9 * b b Cn
;9 * A A Cn
;9 * a a Cn
;9 * - - Cn
;9 * 9 9 Cn
;9 * 8 8 Cn
;9 * 7 7 Cn
;9 * 6 6 Cn
;9 * 5 5 Cn
;9 * 4 4 Cn
;9 * 3 3 Cn
;9 * 2 2 Cn
;9 * 1 1 Cn
;9 * 0 0 Cn
;pS l @ _ Cn
;pS@ r * * pS@
;Cn r _ @ pS@
;1pS l * * 1pS
;pS@ r ~ _ 1pS
;pS l * * pS
;1pS l ] ] pS
;Z@ r * * Z@
;Cn r Z @ Z@
;aZ l * * aZ
;Z@ r Z _ aZ
;Z l * * Z
;aZ l ] ] Z
;z@ r * * z@
;Cn r z @ z@
;az l * * az
;z@ r z _ az
;z l * * z
;az l ] ] z
;Y@ r * * Y@
;Cn r Y @ Y@
;aY l * * aY
;Y@ r Y _ aY
;Y l * * Y
;aY l ] ] Y
;y@ r * * y@
;Cn r y @ y@
;ay l * * ay
;y@ r y _ ay
;y l * * y
;ay l ] ] y
;X@ r * * X@
;Cn r X @ X@
;aX l * * aX
;X@ r X _ aX
;X l * * X
;aX l ] ] X
;x@ r * * x@
;Cn r x @ x@
;ax l * * ax
;x@ r x _ ax
;x l * * x
;ax l ] ] x
;W@ r * * W@
;Cn r W @ W@
;aW l * * aW
;W@ r W _ aW
;W l * * W
;aW l ] ] W
;w@ r * * w@
;Cn r w @ w@
;aw l * * aw
;w@ r w _ aw
;w l * * w
;aw l ] ] w
;V@ r * * V@
;Cn r V @ V@
;aV l * * aV
;V@ r V _ aV
;V l * * V
;aV l ] ] V
;v@ r * * v@
;Cn r v @ v@
;av l * * av
;v@ r v _ av
;v l * * v
;av l ] ] v
;U@ r * * U@
;Cn r U @ U@
;aU l * * aU
;U@ r U _ aU
;U l * * U
;aU l ] ] U
;u@ r * * u@
;Cn r u @ u@
;au l * * au
;u@ r u _ au
;u l * * u
;au l ] ] u
;T@ r * * T@
;Cn r T @ T@
;aT l * * aT
;T@ r T _ aT
;T l * * T
;aT l ] ] T
;t@ r * * t@
;Cn r t @ t@
;at l * * at
;t@ r t _ at
;t l * * t
;at l ] ] t
;S@ r * * S@
;Cn r S @ S@
;aS l * * aS
;S@ r S _ aS
;S l * * S
;aS l ] ] S
;s@ r * * s@
;Cn r s @ s@
;as l * * as
;s@ r s _ as
;s l * * s
;as l ] ] s
;R@ r * * R@
;Cn r R @ R@
;aR l * * aR
;R@ r R _ aR
;R l * * R
;aR l ] ] R
;r@ r * * r@
;Cn r r @ r@
;ar l * * ar
;r@ r r _ ar
;r l * * r
;ar l ] ] r
;Q@ r * * Q@
;Cn r Q @ Q@
;aQ l * * aQ
;Q@ r Q _ aQ
;Q l * * Q
;aQ l ] ] Q
;q@ r * * q@
;Cn r q @ q@
;aq l * * aq
;q@ r q _ aq
;q l * * q
;aq l ] ] q
;P@ r * * P@
;Cn r P @ P@
;aP l * * aP
;P@ r P _ aP
;P l * * P
;aP l ] ] P
;p@ r * * p@
;Cn r p @ p@
;ap l * * ap
;p@ r p _ ap
;p l * * p
;ap l ] ] p
;O@ r * * O@
;Cn r O @ O@
;aO l * * aO
;O@ r O _ aO
;O l * * O
;aO l ] ] O
;o@ r * * o@
;Cn r o @ o@
;ao l * * ao
;o@ r o _ ao
;o l * * o
;ao l ] ] o
;N@ r * * N@
;Cn r N @ N@
;aN l * * aN
;N@ r N _ aN
;N l * * N
;aN l ] ] N
;n@ r * * n@
;Cn r n @ n@
;an l * * an
;n@ r n _ an
;n l * * n
;an l ] ] n
;M@ r * * M@
;Cn r M @ M@
;aM l * * aM
;M@ r M _ aM
;M l * * M
;aM l ] ] M
;m@ r * * m@
;Cn r m @ m@
;am l * * am
;m@ r m _ am
;m l * * m
;am l ] ] m
;L@ r * * L@
;Cn r L @ L@
;aL l * * aL
;L@ r L _ aL
;L l * * L
;aL l ] ] L
;l@ r * * l@
;Cn r l @ l@
;al l * * al
;l@ r l _ al
;l l * * l
;al l ] ] l
;K@ r * * K@
;Cn r K @ K@
;aK l * * aK
;K@ r K _ aK
;K l * * K
;aK l ] ] K
;k@ r * * k@
;Cn r k @ k@
;ak l * * ak
;k@ r k _ ak
;k l * * k
;ak l ] ] k
;J@ r * * J@
;Cn r J @ J@
;aJ l * * aJ
;J@ r J _ aJ
;J l * * J
;aJ l ] ] J
;j@ r * * j@
;Cn r j @ j@
;aj l * * aj
;j@ r j _ aj
;j l * * j
;aj l ] ] j
;I@ r * * I@
;Cn r I @ I@
;aI l * * aI
;I@ r I _ aI
;I l * * I
;aI l ] ] I
;i@ r * * i@
;Cn r i @ i@
;ai l * * ai
;i@ r i _ ai
;i l * * i
;ai l ] ] i
;H@ r * * H@
;Cn r H @ H@
;aH l * * aH
;H@ r H _ aH
;H l * * H
;aH l ] ] H
;h@ r * * h@
;Cn r h @ h@
;ah l * * ah
;h@ r h _ ah
;h l * * h
;ah l ] ] h
;G@ r * * G@
;Cn r G @ G@
;aG l * * aG
;G@ r G _ aG
;G l * * G
;aG l ] ] G
;g@ r * * g@
;Cn r g @ g@
;ag l * * ag
;g@ r g _ ag
;g l * * g
;ag l ] ] g
;F@ r * * F@
;Cn r F @ F@
;aF l * * aF
;F@ r F _ aF
;F l * * F
;aF l ] ] F
;f@ r * * f@
;Cn r f @ f@
;af l * * af
;f@ r f _ af
;f l * * f
;af l ] ] f
;E@ r * * E@
;Cn r E @ E@
;aE l * * aE
;E@ r E _ aE
;E l * * E
;aE l ] ] E
;e@ r * * e@
;Cn r e @ e@
;ae l * * ae
;e@ r e _ ae
;e l * * e
;ae l ] ] e
;D@ r * * D@
;Cn r D @ D@
;aD l * * aD
;D@ r D _ aD
;D l * * D
;aD l ] ] D
;d@ r * * d@
;Cn r d @ d@
;ad l * * ad
;d@ r d _ ad
;d l * * d
;ad l ] ] d
;C@ r * * C@
;Cn r C @ C@
;aC l * * aC
;C@ r C _ aC
;C l * * C
;aC l ] ] C
;c@ r * * c@
;Cn r c @ c@
;ac l * * ac
;c@ r c _ ac
;c l * * c
;ac l ] ] c
;B@ r * * B@
;Cn r B @ B@
;aB l * * aB
;B@ r B _ aB
;B l * * B
;aB l ] ] B
;b@ r * * b@
;Cn r b @ b@
;ab l * * ab
;b@ r b _ ab
;b l * * b
;ab l ] ] b
;A@ r * * A@
;Cn r A @ A@
;aA l * * aA
;A@ r A _ aA
;A l * * A
;aA l ] ] A
;a@ r * * a@
;Cn r a @ a@
;aa l * * aa
;a@ r a _ aa
;a l * * a
;aa l ] ] a
;9@ r * * 9@
;Cn r 9 @ 9@
;a9c l * * a9c
;9@ r 9 _ a9c
;9c l * * 9c
;a9c l ] ] 9c
;8@ r * * 8@
;Cn r 8 @ 8@
;a8c l * * a8c
;8@ r 8 _ a8c
;8c l * * 8c
;a8c l ] ] 8c
;7@ r * * 7@
;Cn r 7 @ 7@
;a7c l * * a7c
;7@ r 7 _ a7c
;7c l * * 7c
;a7c l ] ] 7c
;6@ r * * 6@
;Cn r 6 @ 6@
;a6c l * * a6c
;6@ r 6 _ a6c
;6c l * * 6c
;a6c l ] ] 6c
;5@ r * * 5@
;Cn r 5 @ 5@
;a5c l * * a5c
;5@ r 5 _ a5c
;5c l * * 5c
;a5c l ] ] 5c
;4@ r * * 4@
;Cn r 4 @ 4@
;a4c l * * a4c
;4@ r 4 _ a4c
;4c l * * 4c
;a4c l ] ] 4c
;3@ r * * 3@
;Cn r 3 @ 3@
;a3c l * * a3c
;3@ r 3 _ a3c
;3c l * * 3c
;a3c l ] ] 3c
;2@ r * * 2@
;Cn r 2 @ 2@
;a2c l * * a2c
;2@ r 2 _ a2c
;2c l * * 2c
;a2c l ] ] 2c
;1@ r * * 1@
;Cn r 1 @ 1@
;a1c l * * a1c
;1@ r 1 _ a1c
;1c l * * 1c
;a1c l ] ] 1c
;0@ r * * 0@
;Cn r 0 @ 0@
;a0c l * * a0c
;0@ r 0 _ a0c
;0c l * * 0c
;a0c l ] ] 0c
;Z l @ Z 9
;z l @ z 9
;Y l @ Y 9
;y l @ y 9
;X l @ X 9
;x l @ x 9
;W l @ W 9
;w l @ w 9
;V l @ V 9
;v l @ v 9
;U l @ U 9
;u l @ u 9
;T l @ T 9
;t l @ t 9
;S l @ S 9
;s l @ s 9
;R l @ R 9
;r l @ r 9
;Q l @ Q 9
;q l @ q 9
;P l @ P 9
;p l @ p 9
;O l @ O 9
;o l @ o 9
;N l @ N 9
;n l @ n 9
;M l @ M 9
;m l @ m 9
;L l @ L 9
;l l @ l 9
;K l @ K 9
;k l @ k 9
;J l @ J 9
;j l @ j 9
;I l @ I 9
;i l @ i 9
;H l @ H 9
;h l @ h 9
;G l @ G 9
;g l @ g 9
;F l @ F 9
;f l @ f 9
;E l @ E 9
;e l @ e 9
;D l @ D 9
;d l @ d 9
;C l @ C 9
;c l @ c 9
;B l @ B 9
;b l @ b 9
;A l @ A 9
;a l @ a 9
;9c l @ 9 9
;8c l @ 8 9
;7c l @ 7 9
;6c l @ 6 9
;5c l @ 5 9
;4c l @ 4 9
;3c l @ 3 9
;2c l @ 2 9
;1c l @ 1 9
;0c l @ 0 9
;8 r * * 8
;9 r ( ( 8
;8 r ] _ 7
;7 l _ _ 6
;5 l * * 5
;0 * ( ( 5
;3 r * * 3
;5 l ) _ )3
;3 r * * 4
;)3 l _ _ 4
;4 r _ _ 3
;3 r ( _ 2
;2 l _ _ 1
;2 l * * 0
;6 l ( ( 0

Try it online!
Try it reversed!
I used this site to reverse it.

Well...! I hope you haven't written the first half, manually! I really hope!

It really wasn't that much once I had the strategy sorted. After the basic logic was laid out, it was mostly copy/pasting/tweaking followed by debugging my muffed attempts at copy/pasting/tweaking.

05AB1E, 2 bytes
RI

Try it online or try it online reversed.
Explanation:
R   # Reverse the (implicit) input
 I  # Push the input
    # (output the top of the stack implicitly as result)

I   # Push the input
 R  # Reverse it
    # (output the top of the stack implicitly as result)

Six more: ,R =R ?R Rs R¹ ¸R

qR works as well.

J, 7 bytes
,&.|:@]

Reversed:
]@:|.&,

Try it online!
Jonah's comment on Adam's APL answer made me take the challenge. It was pretty hard indeed, because the inflections . and : always attach to the symbol on their left, and a sole | (abstract value) isn't happy with strings.
How these work
Basically, it is a random mix of no-ops connected through various connectors.
,&.|:@]
     @]   Pass the argument unchanged
 &.|:     Apply inverse of |: (transpose), no-op on single string
,         Ravel, no-op on a single string
 &.|:     Apply |: again, still no-op

]@:|.&,
     &,   Ravel, no-op
 @:|.     Reverse
]         Pass the argument unchanged

This answer is one byte shorter than the trivial comment-abuse:
J, 8 bytes
]NB.BN.|

Reversed:
|.NB.BN]

Try it online!
In J, the in-line comment marker is NB., which is longer than every other language I know of.

Charcoal, 2 bytes
Ｓ←

Try it online! Explanation: Ｓ implicitly prints the explicit input and ← moves the cursor left (no effect on the final output). Reversed:
←Ｓ

Try it online! ← changes the direction of the implicit print of the explicit input Ｓ thus reversing the output.

Python 3, 27 bytes
lambda s:s#]1-::[s:s adbmal

Try it online!
!enilno ti yrT

Gaia, 2 bytes
pv

Try it online!
Try it reversed!
Very similar solution to other golfing languages.
Explanation
p    Print the (implicitly grabbed) input
 v   Reverse the input

Reverse
v    Reverse the (implicitly grabbed) input
 p   Print the result

Well that's certainly efficient.

J 9, 4 bytes
][.|

Attempt This Online!
See this answer for the 7-byter that works in previous versions.
J 9 (re-)introduces modifier trains and adds some adverb and conjunction equivalents of identity functions (] and [):
]: Ident (adverb)    / u]:  evaluates to u
]. Dex (conjunction) / u].v evaluates to v
[. Lev (conjunction) / u[.v evaluates to u

The above code parses as
] [. |    left operand ([.) out of identity(]) and absolute value(|),
          which is identity

while the reverse |.[] parses as a 3-train:
|. [ ]    left argument ([) out of the results of reverse (|.) and identity (])
          which is reverse

V nice, I had not noticed these new features

Cubix, 19 bytes
.@o?A^;/|?$oqBA.UW.

Try it online!
Cubified
    . @
    o ?
A ^ ; / | ? $ o
q B A . U W . .
    . .
    . .

A^ get all the input and enter the loop
o? output the TOS of stack and test
@ exit if it tests to negative
/;^ reflect back, pop TOS and re-enter loop

All other commands are avoided.
Reversed
.WU.ABqo$?|/;^A?o@.

Try it online!
Cubified
   . W
    U .
A B q o $ ? | /
; ^ A ? o @ . .
    . .
    . .

ABq Get all input, reverse and drop TOS to bottom of stack
o$?|? output TOS, skip the test and relect back onto test
@ halt if test if negative
WUq change lane, u-turn onto drop TOS start of loop

Wolfram Language (Mathematica), 16 bytes
1&esreveR//#& &1

Try it online!
Reversed:
1& &#//Reverse&1

Try it online!
Takes a list of characters as input. For string input, use StringReverse.

Pip, 4 bytes
aVRa

Try it online! !enilno ti yrT
Makes use of the fact that RV is the reverse operator but VR is an undefined variable. Both versions print the value of their last expression; in the standard version, that's a (with the first a and the VR being no-ops), while in the reversed version, that's RVa (with the first a being a no-op).

Perl 5 -p, 11 bytes
The obvious.
#esrever=_$

Pushy, 4 bytes
"\"@

Try it online: Forwards, Backwards
Simple implementation with the comment character \. In the forwards program, " prints the input and the rest is a comment; in the backwards program, @ reverses the input before printing.
We could alternatively replace \ with c, which would clear the input from the stack.

Jelly, 2 bytes
Uṛ

Try it online!
Reversed!
Explanation
U  | Reverse
 ṛ | Right argument (when used in a monadic chain like this, will return the original argument to the chain)

Explanation (reversed)
ṛ  | Right argument (when used in a monadic chain and followed by a monadic link, will return the output of that monadic link)
 U | Reverse

Seven other two-byters Ṛṛ ḷU ḷṚ Uȧ Ṛȧ ȯU ȯṚ

Japt, 2 bytes
ÔU

Try it | Reversed

MathGolf, 3 bytes
x;l

Explanation:
x   Reverse the implicit input
 ;  Discard the string
  l Push a string input
Implicit output TOS

Reversed:
l   Push a string input
 ;  Discard it
  x Reverse the implicit input
Implicit output TOS

C (gcc), 56 bytes
Nothing fancy. Would have used puts() but then trailing whitespace would not have been consistent between the two variants.
f(int*s){printf(s);}//};))1+s(f,s*(rahctup&&s*{)s*rahc(f

Try it online!
f(char*s){*s&&putchar(*s,f(s+1));}//};)s(ftnirp{)s*tni(f

Reversed!

W, 2 bytes
Pretty much the same as the 05AB1E solution.
a_

Explanation
a   % Push the input
 _  % Reverse the input
    % Implicit print the top of the stack

noitanalpxE
_   % Reverse the implicit input
 a  % Push the input
    % Implicit print the top of the stack

BRASCA (brasca-online), 5 bytes
The broken loops crash the Python-based interpreter, but it works on brasca-online.
,[o],

,]o[,

Try it! | !ti yrT
Explanation
,     - Reverses stack                     (1,2,3 => 3,2,1)
 [o]  - Output stack one by one            (3,2,1 => empty)
    , - Reverse it again                   (empty => empty)

Reversed:
,     - Reverses stack                     (1,2,3 => 3,2,1)
 ]o[  - Broken loops, output top of stack  (3,2,1 => 3,2  )
    , - Reverses it again                  (3,2   => 2,3  )
      - Implicit output the stack reversed (2,3   => empty)

Factor, 17 bytes
[ ] ! ] esrever [

Try it online!
!enilno ti yrT
Fixed thanks to Bubbler

I think the reversed part should look like ] whatever [ :)

@Bubbler Oops, you're right! I'll remind myself not to use a mirror next time :P

Stack Exchange, 2 bytes
EP

Reversed:
PE

Sadly, there is no online interpreter, especially since this language is still a work in progress (although P and E are two of the commands I've finalized).
Stack Exchange is a language that resolves around stacks. It is a stack-based language where the only data structure is a stack. A string is represented as a stack of characters, and a character is represented by a stack of empty stacks where the length represents a codepoint.
The E command encloses all elements of the main stack in a stack and pushes that stack onto the main stack. The P dumps all elements of the top stack onto the main stack in reverse. P does this in reverse because it's easier to make it stack-safe that way, but I didn't realize until now that it's perfect for this challenge. Whereas PE dumps the input onto the stack in reverse and bundles it back up in a stack so it can be returned, EP encloses the input in a singleton stack and then unwraps it again, making no change.
As an example, running EP on the input { {{}{}{}} {} {{}{}} {{}} {} } returns the same stack back, whereas running PE returns { { {} {{}} {{}{}} {} {{}{}{}} } }. { {{}{}{}} {} {{}{}} {{}} {} } represents the string made of the characters \u0003, \u0000, \u0002, \u0001, and \u0000.

Stax, 2 bytes
Pr

Run it Reversed

CJam, 7 bytes
qe#e%Wq

Boring version with comments. If CJam would fail silently i could have saved like 3 bytes in 2 questions already!

Try it online!
Try it reversed!

Brain-Flak, 13 bytes
#><}><)><}{({

Try it online!
Forward: Just a comment, so that it just outputs the input
Reversed:
{({}<>)<>}<>#

Try it online!
Move everything to the second stack, so it is reversed.

Kotlin, 15 bytes
My first Kotlin answer, and far shorter than the java equivalent!
s//)(desrever.s

Try it online!
Reversed:
s.reversed()//s

!enilno ti yrT

The parenthesis are the wrong way. A more correct answer would be s//)(desrever.s. However i think it is custom to provide at least a full lambda in Kotlin (or at least Java). So something like {it}//})(desrever.ti{ should do the trick.

PHP, 27 bytes
<?=$argn;#;)ngra$(verrts=?<

Try it online!
Try it online!

x86 opcode, 19 bytes
85 c9 7e 0e 49 8a 06 8a 24 0e 88 26 88 04 0e 46 e2 ee c3

!enilno ti yrT
17 bytes
f:  cmp esi, edi
    jae ok
    dec edi
    mov al, [esi]
    mov ah, [edi]
    mov [esi], ah
    mov [edi], al
    inc esi
    jmp f
ok: ret

input esi(begin) and edi(end)

MAWP, 12 bytes
%|0~[;]~0~|%

It would have been cute to have a palindromic solution.
The program inserts a zero at the end of the string and prints it normally, or it does the opposite.
Try it!
!ti yrT

Google Sheets, 69
Forward:
=A1&T(N("(N^1,))1A(NEL(ECNEUQES-)1A(NEL+1,1A(DIM((alumroFyarrA,(NIOJ=

Backward:
=JOIN(,ArrayFormula((MID(A1,1+LEN(A1)-SEQUENCE(LEN(A1)),1^N("(N(T&1A=

Easy enough. Google Sheets auto-closes quotes and parens.
T(<number>) is always an empty string. N("...") is always 0.

Rust, 34 bytes
|s|s//)(tcelloc.)(ver.)(srahc.s|s|

Reversed:
|s|s.chars().rev().collect()//s|s|

Try it online

Pxem, 29 bytes (Filename) + 0 bytes (Content) = 29 bytes, syntaxically not valid.

Filename (escaped some): .w.o.i.c\001.+.a.d.p.a.+.\001c.i.w.

Reversed: .w.i.c\001.+.a.p.d.a.+.\001c.i.o.w.

Content: empty

How it works
Original
As in this, except with .d: exiting/returning command. Since pxemi.2.min.posixism automatically removes deadcode, the code after that will be ignored, even .a comes before .w (which is syntax error).
Reversed
Since Pxem is stack-oriented, not outputting any characters until EOF would produce input reversed. Then .p outputs from top to bottom, which is in reverse order compared from original input.
TIO links

Try it online!
!enilno ti yrT

Pxem, 39 bytes (Filename) + 0 bytes (Content) = 39 bytes, syntaxically safe.

Filename: .w?.s.o.i.c\001.+.a?.d.p.s.?a.+.\001c.i.s.?w.

Reversed: .w?.s.i.c\001.+.a?.s.p.d.?a.+.\001c.i.o.s.?w.

VBA, 23 bytes
?[A1]')]1A[(esreveRrtS?

Input is in cell A1 of the active sheet. Code must be run from the immediate window. It's a simple implementation where a backtick indicates the rest of the line is a comment.

Raku, 9 bytes
~*#pilf.*

This seems too trivial for a Try It Online link...
# is the comment character.  Forwards, ~* is an anonymous function that stringifies its argument.  Backwards, *.flip is another anonymous function that calls the flip method on its argument, which reverses strings, or the string representation of objects implicitly convertible to strings (numbers, etc).

Vyxal, 2 bytes
#Ṙ

Try it Online!
Same as Keg

RProgN 2, 2 bytes
pi

There's a joke to be made about π here, but I can't find it.
wi can be used instead, which doesn't include a trailing newline.
Try it online!
!enilno ti yrT
Explained
pi
p  | [p]rint the top of the stack, popping.
 i | [i]nverse the top of the stack, doing nothing.

denialpxE
ip
i  | [i]nverse the top of the stack
 p | [p]rint the top of the stack, popping.

Python 3.11, 35 bytes
A full program, not just a lambda.
print(input())#)]1-::[)(tupni(tnirp

Attempt this online!
Reversed:
print(input()[::-1])#))(tupni(tnirp

TypeScript's Type System, 84 bytes
Same comment out the opposite code trick.
Forwards:
type F<S>=S//V:>`}gnirts&V{$}C{$`,R<F?`}R refni{$}C refni{$`sdnetxe S=>""=V,S<F epyt

Try it at the TypeScript playground!
Backwards:
type F<S,V="">=S extends`${infer C}${infer R}`?F<R,`${C}${V&string}`>:V//S=>S<F epyt

!dnuorgyalp tpircSepyT eht ta ti yrT

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


text:
I transpose the source code, you transpose the input!
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.

My god. Can we stop?

@Night2 No, it complicates matters.

@JL2210 No, I have a big one in the works.

These challenges are getting impossible in procedural languages without serious comment abuse.

What, negate the source code, negate the output?

@JL2210 Transforms.

The 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 How is it not clear? Your source code size is measure like in any other code-golf challenge.

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 You wish…

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 Isn't it like — per definition — possible to solve this challenge in Turing Machine Language‽

@Adám, Hence my qualification in parethesis. I could put together a limited case I suppose....

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

@nimi You can assume a non-empty array.

@SriotchilismO'Zaic Well, some languages cannot distinguish between various 0×n arrays… Anyway, clarified OP to minimum 1×1

Python 3 + numpy, 45 bytes
lambda\
a:a
ma= """
b.    "
dT"   "
a "
\ """

Try it online!
Thanks to @EriktheOutgolfer pointing out a bug of the previous version
Transposed:
lambda\
a:a.T
ma= """
b     "
d "   "
a "
\ """

Try it online!
The functions take a numpy matrix as input and output a numpy matrix. The solution does not rely on comments like many other solutions do but instead exploits multi-line strings.

That's really neat!

Hm, I'm pretty sure that the transposed version will be padded with spaces, so the last line will contain trailing spaces, therefore the \ will throw a SyntaxError. You need to move the quotes in both directions to fix this.

@EriktheOutgolfer Fixed. Thanks.

Jelly, 2 bytes
Input is a list of lists. Thanks to Luis Mendo and Nick Kennedy for improving the answer.
ZZ

Try it online! Try it transposed!
The program transposes the input twice, returning the original input. The transposed version ignores the first line and only transposes once.

R, 5 4 bytes
#t
I

Try it online!
An R function, either the identity function I or the transpose function t when transposed. Footer on TIO shows output of both.
Thanks to @RobinRyder for saving a byte!

You don't need the final #.

@RobinRyder thanks! For some reason I was padding to a rectangle even though I’d seen the statement that it was unnecessary.

C (gcc), 209 205 203 201 bytes
Normal
f(n,L,r,c)char**L;{for(c=0;0?L+  c:c<n;c+=puts(""))for(r=0;0?r :L[c][r];r++)putchar(L[ c ][ r ]);}/*
          \\\      \\      1 [0][]      \ \\\  \   \\      1 <n          \  \\\\\\   r+-c c+-r    */

Try it online!
Transposed
f
(
n
,
L
,
r
,
c
)
c\
h\
a\
r
*
*
L
;
{
f\
o\
r
(
c
=
0
;
01
?
L[
+0
 ]
 [
c]
:
c
<
n
;
c
+\
=
p\
u\
t\
s
(
"\
"
)
)
f\
o\
r
(
r
=
0
;
01
?
r<
 n
:
L
[
c
]
[
r
]
;
r
+\
+
)
p\
u\
t\
c\
h\
a\
r
(
L
[r
 +
c-
 c
]
[c
 +
r-
 r
]
)
;
}
/*
*/

Try it online!

Haskell, 51 bytes
This version is valid, but will not halt when given [] as input.
f
--(:[|,<zabf=]f
--abx(y-i$]
-- ):x) pf;x[:x
 y =y

Try it online!
Transposed, 75 bytes
f---
 ---y
 (a
 :b)=
 [x:y
 |(x
 ,y)
 <-
 zip
 a$f
 b];
 f x
 = [
 ] :
 f x

Try it online!
Haskell, 51 bytes
This version is valid, but crashes with [] as input for the transposed version.
f
--d[(idi)z[.]d!0
-- m!)|,<i0.$ !]
-- a! (_-p
 p=p

Try it online!
Transposed
Haskell, 75 67 57 bytes
At least 7 bytes saved thanks to Ørjan Johansen
This version outputs [] when given [] as input.
f
--[[d(i<di)z[.$!0
--]]=!)$|,<i0.d!]
-- ;[! >(_-p ]
 f=f

Try it online!
Transposed

60 bytes

@ØrjanJohansen Thanks! I had tried something like that earlier but I couldn't get it to work.  There is also a pretty easy way to take 3 more bytes off of your 60.

Python 3, 51 bytes
lambda\
a:a
mz= '''
bi'   '
dp'   '
a('
 *
 a
\)'''

Try it online!
Based on Joel's approach. The input is a tuple of tuples, and the output is a zip (converted to a tuple over TIO for better visibility).
Transposed:
lambda  \
a:zip(*a)
ma='''  '
b       '
d '     '
a '
\ '''

Try it online!

Perl 6, 20 11 bytes
#&
*[
#Z
 ]

Try it online!
Transposed
#*#
&[Z]

Try it online!
Both functions work on list of lists.
*[ ] is a WhateverCode returning the zen slice of its argument, effectively the identity function.
&[Z] is the zip operator.

JavaScript (Node.js), 62 bytes
//m0()m  ]
//=](=a  )
//>.a>p( )
//mm,m/aa
//[ap./=[
   p  =>p

Try it online!
Improved with a different layout
/////
/////
m=>m[
0].map
((a,p
)=>m.
map//=
  (a=>
   a[p
]))

Haskell, 185 161 bytes
t i
 =
 i
af

 n m
 u a e i
 l p s d
 lu h=u
 (
 h
 e
 a
 d

 a
 )
 t
 h
 e
 n
 [
 ]
 e
 l
 s
 e

 m
 a
 p

 h
 e
 a
 d

 a
 :
 t
 (
 m
 a
 p

 t
 a
 i
 l

 a
 )

Try it online!
Transposed:
t  a
 =if null(head a)then[]else map head a:t(map tail a)
i       u
     map
        h
      es=
        u
      id

Try it online!
No comments, no string literals, just some additional function definitions.
Edit: -24 bytes thanks to @Ørjan Johansen.

161 bytes

PHP (7.4), 114 86 70 bytes
My first ever experience doing something like this in PHP, there must be a better way I cannot see! Input is an array of arrays like [[1,2],[3,4],[5,6]].
Normal:
fn($a)=>$a/*
nu         /
(l
$l
a,
).
=.
>.
a$
ra
r)
a/
y*
_
m
a
p
(*/

Try it online!
Transposed (space padded):
fn($a)=>array_map(
null,...$a)/*    *
(                /
$
a
)
=
>
$
a
/
*/

Try it online!

Japt, 2 bytes
ÕU

Try it | Transposed
ÕU     :Implicit input of string/array U
Õ      :Transpose U
 U     :Original U
       :Implicit output

Õ\nU     :Implicit input of string/array U
Õ        :Transpose U
 \n      :Reassign to U
   U     :Newly transposed U
         :Implicit output

Brain-Flak (BrainHack), 382 375 337 bytes
No comments!
  ( <( <>)<> ><>) ({})  {}{}   {( )()<({}<{}<><>>{}<><>{}) ( <>) ({}<><( [ ]({}<{}( )<({}()<{}<><>>){} ><><{}<< ><> ( [ ]( <>)<>)>{}<>>>)){}>)> ( ){ {}[]} <>[]{
(({}({}  ( ))   <>( ))[( [ ])])({}[ ] [ ](   )  (   ) < ><>{}  <>(   ){{}()<( )( ({} {  [ ](   )   } <>)  (  (())  {{}()<{}    >}  )  ) >}    )}[] {} ( ){} ( ){}({}<>)<>([])}<>

Try it online!
For the input the first two numbers are the dimensions of the matrix and the remainder is the contents of the matrix.  Output is given in the same format.
Transposed
Brain-Flak (BrainHack), 465 bytes
 (
 (
({
 }
<(
({
 }
<
>
)(
<
>)
 )
>
<
>
)<
 >
((
{
})
))
 [
 (
{
}[
{
}]
 )
 ]
 )
{(
({
 }
)[
(
)]
<
([
{
}]
<(
{
}
<
>)
<
>
>(
{
}
<
>)
<
><
{
}>
)<
 >
({
 }
<
>
)<
 >
((
{
}
<
>)
<{
({
 }
[(
 )
]<
((
{
})
<(
{
}(
({
 }
)
<{
(
{
}[
(
)]
<(
{
}
<
>)
<
>
>
)}
{
}<
 >
>)
<
>
<(
{
}
<(
<(
 )
>)
<
>
 {
({
 }
[(
 )
]<
({
 }
<
>
)
<
>>
)}
>
{
})
<
>
>)
>
)>
)}
{
}
>
)
>)
 }
([
 ]
)
{{
 }
{
}(
[
])
}{
 }
<
>(
[
])
{{
 }
 (
 {
 }
 <
 >
 )
 <
 >
 (
 [
 ]
 )
 }
 <
 >

Try it online!

Charcoal, 19 bytes
Ａ¿⁰«
‖⁰¿
↗⁰
¿⁰
⁰¿
«

Try it online! Takes input as an array of strings. Explanation: Ａ implicitly prints the explicit input, while ¿⁰ is a conditional, with 0 as the condition, which is therefore always false. « then starts a block of meaningless Charcoal code which never gets executed. (It might be possible to remove some of those bytes but in that case I'm not sure whether Charcoal would parse the program correctly.) Transposed, 17 bytes:
Ａ‖↗¿⁰«
¿⁰⁰⁰¿
⁰¿
«

Try it online! Explanation: Much the same as the previous program, except for the addition of the transpose command ‖↗.
I have an alternative solution where both the original and transposed program are 18 bytes:
Ａ⊞υ”y
‖υ⁺y
↗⁺
⊞⁺
υ

Try it online! Explanation: Ａ as above; ⊞υ pushes a value to the predefined empty list (which doesn't affect the output); ”y begins an arbitrary string (ends at end of program or matching ”). Transposed:
Ａ‖↗⊞υ
⊞υ⁺⁺
υ⁺
”y
y

Try it online! Explanation: Ａ‖↗ as above; ⊞υ as above; the minor difference here is that I'm pushing concatenations of smaller strings, since I don't want to repeat the ”.

Haskell, 153 144 bytes
(thanks, Sriotchilism O'Zaic)
f
 [
 ]=
   [
   ];
    f(
     x:
      l)
       =(
        :)
         x l
-- :   z $
-- f   i f
-- [   p
-- ]   W
--     i
--     t
--     h

Try it online!
Try it transposed!

Here is a 144 byte version while maintaining your structure. (Transposed).

Here is a 70 byte version that is still similar but with some structural changes. (Transposed).

Thanks. The second version lacks the central idea though (re-using the foldr recursion for both versions), don't like that.

You know, this challenge and your username kinda contradict each other, since your code did turn counterclockwise in that transposed version. ;p

Ruby, 35 bytes
#-sz##
->hip{
 hip  }
#{f
#ht*
#..h

Try it online!
Hip to be square! (Almost)
Accepts ruby matrices as input (arrays of arrays)

APL (Dyalog Unicode), 7 bytes
{⍵
⍉
⍵}

Try it online!
Transposed:
{⍉⍵
⍵ }

Probably a rather boring answer, but anyway here it goes.
The inline function definition {...} can span multiple lines. In this case, each line is sequentially executed, but any line without an assignment ← immediately returns its computed value. So the first function returns ⍵ while the second returns ⍉⍵.
Even more boring answer would be the comment abuse:
APL (Dyalog Unicode), 4 bytes
⍝⍉
⊢

No TIO is necessary, I guess...

Wolfram Language (Mathematica), 13 bytes
#&(*
 *)
\

Try it online! / Transposed

05AB1E, 4 bytes
øø
q

Try it online.
øq
ø

Try it transposed.
Explanation:
Unlike some of the other languages, newlines are simply ignored in 05AB1E, so I don't think a 2-byter is possible (although I'd love to be proven wrong).
ø    # Transpose the (implicit) input
 ø   # Transpose it back
  q  # Stop the program (and output the top of the stack implicitly as result)

ø    # Transpose the (implicit) input
 q   # Stop the program (and output the top of the stack implicitly as result)
  ø  # No-op, since the program has already stopped

That's 4 bytes, not 3...

@Steffan Fixed. I think I might have misread the rule about trailing spaces not counting, as all whitespaces not counting instead. But it's been a while, so not sure why I put it as 3 bytes anymore; could also just have been a typo.

Clean, 64 bytes
//i$
//mp
$ p=p
//ot
//rr
//ta
// n
//Ss
//tp
//do
//Ls
//ie
//b

Try it online!
//$//////////
// //////////
import StdLib
$p=transpose
  p

Try it transposed!

Runic Enchantments, 88 bytes
vrlril1-{)?\:',=4*?~r0[
i! '${U [0r/?*7̸0l{$
$ka6 ̹\!$,'/;? =  ̹
'              ̸

$

Try it online!
Try it transposed!
Input is space separated for each value and comma separated for each row (newlines are optional) and supports both strings and (non-zero) numbers. This makes parsing the input easier as input is automatically broken by spaces and newlines. So for example, the input:
1 2 3 , 4 5 6 , 7 8 9

Would be represented in nested array form as [[1,2,3],[4,5,6],[7,8,9]]. Minimal support for jagged arrays (only the last one can be short), but as inputs are expected to be rectangular, this satisfies that requirement.
Output is represented in the same format (transposed version outputs with newlines, but its zero bytes different to use a space instead). Normal version has a trailing space, transposed version has a trailing comma and newline (due to the difficulty of determining when there is no more data to print).
Normal version does have modifier characters in weird places (eg. 7̸0), but this is due to needing them in the right place when the source is transposed and the normal execution only utilizes the leftmost column of instructions.
Explanation
Explanation of the transposed source will be in a non-transposed form. Arrows will represent IP directionality at the entrance and exit of various blocks.
→rlril1-{)?\:',≠4*?~r0[    Initial position. Read and parse input.
           ↓               Input loop exit and direction

The input is read, and when a , character is found, a new substack is pushed. This allows each stack to hold each row separately in memory. Enters next section from the top.
           ↓
.. '${̹L [0r/?*7≠0l{̹$       When no more input:
      ↑    ↓

[0 (executed leftwards) sets up a an empty stack to act as a boundary between the first row and the last row and then rotates to the first stack ({̹) and starts printing elements and rotating stacks. The i! is not executed and {̹L [0r is only executed once. When a zero-size stack is found, the loop exits.
      ↑    ↓
$ka6  \!$,'/;?             Row separation formatting

When the empty-stack is found, a , and newline are printed, and value loop is re-entered. Execution order (mirrored for readability) where . is an un-executed command: \',$!.6ak$?....../. Changing ak to '<space> would print spaces instead of newlines.
Execution halts when the program attempts to write from an empty stack; this is why only last-row jagginess works correctly and why there is a trailing , in the output: the comma has already been printed before the program knows that there's no more data.

Vyxal, 2 bytes
#∩

Try it online or try it online transposed.
Receives a list of lists (a list of strings will work too).
-2 bytes thanks to lyxal

Why not just comment then tranpose?

Cjam, 13 bytes
qo
~
z
`

Try it online!
Transposed version:
q~z`
o

Try it online!
Input format
The input format is the standard CJam array format: [[1 2] [3 4]]
No crash version, 12 bytes
The normal version crashes after printing the array. A version which doesn't crash would be:
qo{
~
z
` };

Try it online!
or transposed:
q~z`
o
{  };

Try it online!
There are probably a few extra bytes that can be saved, i accidentaly worked on the transposed version first, which led to a few extra linebreaks and it's been a long time since i last used CJam. Any improvements welcome.

Zsh, 75 bytes
  <<<${(F)@}
fa<
o[<
r+$
 +{
si(
;]F
i+)
==a
&$}
&s
r[
ei
p+
e1
a]
t

$
#
s

TIO: Normal Transposed
The garbage below the main print is harmless, it prints an error when encountering a newline after fa< and exits. 86 bytes to remove that error.
The transposed version is here. After printing it errors on seeing < at the end of a line and exits.
 for s;i=&&repeat $#s
 a[++i]+=$s[i+1]
<<<${(F)a}
<
<
$
{
(
F
)
@
}

Python 3, 118 95 bytes
Input and result are lists of tuples.
f=lambda i:i;"""
=              "
l              "
a
m
b
d
a

i
:
[
*
z
i
p
(
*
i
)
]
;
"
"
"""

Try it online!

Pyth, 10 bytes
CCQ "
Q

"

Try it online!
Transposed
CQ "
C
Q

"

Try it online!
Explanation
The program transposes the input twice, returning the original input. The transposed version only transposes once.


text:
Convert a string of digits from words to an integer
Convert a string containing digits as words into an integer, ignoring leading zeros.
Examples

"four two" -> 42.
"zero zero zero one" -> 1.

Assumptions
Submissions can assume that:

The input string is comprised of space-separated digit words.
All words are valid (in the range "zero".."nine") and lowercase. Behaviour for empty input is undefined.
The input string always represents an unsigned number within the range of int and is never an empty string.

Scoring
Answers will be scored in bytes with fewer bytes being better.

Welcome to the site. There are a couple of things that we usually expect from questions that are missing here.  The most important would be an objective scoring criterion which all challenges must have.

Aside from that this question is very sparse on specification.  You should specify exactly what is required of submissions without ambiguity.  One sentence and an example just isn't up to our clarity standards for challenges.

@SriotchilismO'Zaic the code-golf tag is enough?

On top of what has been said already, we have a sandbox where users can post their challenges before posting them to main. That way you will miss less information when making posts. If you look at other recent posts on the site with a reasonably positive reception I think you will see that both your question and solution aren't quite in line with what we do here.

To handle the scoring criterion it would be the absolute minimum.  You really should put a sentence in the body of the question though.  E.g. "Answers will be scored in bytes with fewer bytes being better".  There is technically more than one way to score [tag:code-golf], but bytes is overwhelmingly the most popular.

What behavior is expected on leading zeros for example should zero zero one output  001, 1, or are both allowed?  Also what should be done with the empty string?  Does it count as 0 or is it not a valid input?

At the risk of being pedantic, I'd like to point out that the range "zero".."nine" is not fully specified.

Annoyingly, the builtin Interpreter@"SemanticNumber" does exactly this in Mathematica—except that it fails on strings starting with zero zero .

I have troubles parsing the title. Shouldn't it be written in the usual way, "I ... the source code, you .. the input!" ?

What's unclear here? Why the VTCs? The only potential issue I see is the one raised by @UnrelatedString above.

Can we assume the input is all uppercase, rather than all lowercase?

Possible duplicate of Convert English to a number without built-ins or libraries

@OlivierGrégoire it's a different challenge to that one - this one is only the digits rather than the ordinal number in English (i.e. "four two" here "fourty two" there) this makes quite a difference.

PHP, 74 bytes
foreach(explode(' ',$argn)as$w)$n.='793251_8640'[crc32($w)%20%11];echo+$n;

Try it online!
Tried to get a solution which doesn't copy existing answers. I get cyclic redundancy checksum polynomial of 32-bit lengths (crc32) for each word and then do a mod 20 and mod 11 on it to get mixed up unique values from 0 to 10 (missing 6) for each digit. Then using that unique value I find the actual digit.
| Word  | CRC32      | %20 | %11 | Equivalent digit |
|-------|------------|-----|-----|------------------|
| zero  | 2883514770 | 10  | 10  | 0                |
| one   | 2053932785 | 5   | 5   | 1                |
| two   | 298486374  | 14  | 3   | 2                |
| three | 1187371253 | 13  | 2   | 3                |
| four  | 2428593789 | 9   | 9   | 4                |
| five  | 1018350795 | 15  | 4   | 5                |
| six   | 1125590779 | 19  | 8   | 6                |
| seven | 2522131820 | 0   | 0   | 7                |
| eight | 1711947398 | 18  | 7   | 8                |
| nine  | 2065529981 | 1   | 1   | 9                |

Another 74 bytes CRC32 alternative using %493%10: Try it online!
Another 74 bytes CRC32 alternative using %2326%11: Try it online!

PHP, 74 bytes
foreach(explode(' ',$argn)as$w)$n.=strpos(d07bfe386c,md5($w)[21]);echo+$n;

Try it online!
Another alternative with same length, takes 22nd character in the md5 of the word (only character which gives a unique value for each word) and then uses that character to map to a digit.

This is a cool answer

Python 2,  71  70 bytes
-1 thanks to ovs (use find in place of index)
lambda s:int(''.join(`'rothuvsein'.find((w*3)[6])`for w in s.split()))

Try it online!

JavaScript (ES6),  70 67 66  62 bytes
Saved 3 bytes thanks to @ovs
s=>+s.replace(/\w+ ?/g,s=>'2839016547'[parseInt(s,36)%204%13])

Try it online!

'2839016547'[parseInt(s,36)%204%13] is 3 bytes shorter.

Python 3, 107, 91, 77, 90, 73 bytes
-16 bytes by Sriotchilism O'Zaic
+13 bytes to remove leading zeroes
-16 bytes using find and a more clever indexing, but now it's basically a rip-off of the Python 2 version...
lambda s:int(''.join(str('rothuvsein'.find((w*3)[6]))for w in s.split()))
Try it online!

It's shorter if you just use the first two characters

Nice one! That way, I can even drop the delimiter completely :)

With the updates to the challenge this is no longer valid since it includes leading zeros. :(

Yep, fix is expensive.

Here is a slightly better fix

@movatica Your fix is incorrect. The lstrip method strips every character in the string which is given as it's argument, so "eight two" becomes "ight two", as "e" gets stripped. Also, "zero zero zero" should print out "0", not give out an error.

You're both correct. lstrip does not work, I switched to a lambda instead

My version was not just to fix lstrip it is also 7 bytes shorter.

https://tio.run/##ZY/BDoIwDIbvPkVv2xICCd5IfBL0gKGTGuzIWhn68sjg6KVN/3z9/3b66BD4vPrLdR27173vQBpitcaUz0BsRaM1XwysSQcfPAkJIjGZkrjHxaa2qW@uqmrnQ4QExCClTCOpdc6tWZQstptLDKYAExhzyyPs5U/YSSiMD@8ImvYtJkZAegwKgjNuKbSApxnhoIaImNnsdhjcmhNMMT/jrWyn/AA

Jelly,  19  17 bytes
Ḳµ7ị“*;nÄƲ]³Ṙ»i)Ḍ

A monadic Link accepting a list of characters which yields an integer.
Try it online!
Pretty much a port of my Python 2 answer.

Previous
ḲŒ¿€i@€“©¥q£½¤MÆÑ‘Ḍ

Try it online!
There is quite possibly a shorter way, but this is a way that first came to mind.

Removing zero from the enklact string to avoid decrementing, because not found is zero anyhow... clever!

Ah I see you did the same method, nice.

C (gcc), 89 bytes
i,n;f(char*w){for(i=n=0;n=*w%32?n^*w:(i+=n-2)&&!printf(L"8 0  72 3  59641"+n%17),*w++;);}

Try it online!
Thanks to @Ceilingcat smartest tricks :
- printf instead of putchar.
- !printf instead of printf()&0.
- And wide char !

Perl 6, 35 32 bytes
{+uniparse 'SP'~S:g/<</,DIGIT /}

Try it online!
Explanation
{                              }  # Anonymous block
                S:g/<</,DIGIT /   # Insert ",DIGIT " at
                                  # left word boundaries
           'SP'~  # Prepend 'SP' for space
  uniparse  # Parse list of Unicode names into string
 +  # Convert to integer

05AB1E, 18 16 bytes
#ε6è}.•ƒ/ÿßÇf•Åβ

Try it online.
Explanation:
#                 # Split the (implicit) input-string on spaces
 ε  }             # Map each string to:
  6è              #  Get the character at 0-based index 6 (with automatic wraparound)
     .•ƒ/ÿßÇf•    # Push compressed string "rothuvsein"
              Åβ  # Convert the characters from custom base-"rothuvsein" to an integer
                  # (after which the top of the stack is output implicitly as result)

See this 05AB1E tip of mine (section How to compress strings not part of the dictionary?) to understand why .•ƒ/ÿßÇf• is "rothuvsein".

16 without rothuvsein

05AB1E, 17 16 bytes
•D±¾©xWÄ0•I#HèTβ

Try it online!
Perfect tie with the other 05AB1E answer, but using a completely different approach.
•D±¾©xWÄ0•               # compressed integer 960027003010580400
          I#             # split the input on spaces
            H            # convert each word from hex (eg "one" => 6526)
             è           # index (with wrap-around) into the digits of the large integer
              Tβ         # convert from base 10 to integer

x86 machine code, 46 bytes
Hexdump:
57 53 33 c0 33 ff f6 01 0f 75 15 6a 0a 5b 99 f7
f3 6b ff 0a 03 fa 33 c0 38 01 75 0f 97 5b 5f c3
69 c0 26 2b aa 6e 32 01 c1 e8 02 41 eb d8

It's a fastcall function - receives a pointer to the string in ecx, and returns the result in eax.
The hashing function multiplies by a magic number 1856645926, does a XOR with input byte, and shifts right by 2 bits.
Saving and restoring noclobber registers (edi and ebx) took 4 bytes, but I didn't find a more efficient way to implement this. Storing the constant 10 in ebx was particularly annoying!
Disassembly with corresponding code bytes:
57                   push        edi  ; edi = result
53                   push        ebx  ; we use ebx to store the constant 10
33 C0                xor         eax,eax
33 FF                xor         edi,edi
    myloop:
F6 01 0F             test        byte ptr [ecx],0Fh  ; check for end of word
75 15                jne         myhash
6A 0A                push        0Ah
5B                   pop         ebx
99                   cdq              ; prepare 64-bit dividend in edx:eax
F7 F3                div         eax,ebx  ; find the remainder of division by 10
6B FF 0A             imul        edi,edi,0Ah
03 FA                add         edi,edx  ; update the result
33 C0                xor         eax,eax  ; reset the hash temporary variable
38 01                cmp         byte ptr [ecx],al  ; check for end of input (here al=0)
75 0F                jne         mycontinue
97                   xchg        eax,edi  ; set the return register
5B                   pop         ebx  ; restore registers
5F                   pop         edi  ; restore registers
C3                   ret
    myhash:
69 C0 26 2B AA 6E    imul        eax,eax,6EAA2B26h  ; hashing...
32 01                xor         al,byte ptr [ecx]  ; hashing...
C1 E8 02             shr         eax,2  ; hashing...
    mycontinue:
41                   inc         ecx  ; next input byte
EB D8                jmp         myloop

Equivalent C code:
int doit(const char* s)
{
    int result = 0;
    unsigned temp = 0;
    while (true)
    {
        int c = *s++;
        if ((c & 15) == 0)
        {
            temp %= 10;
            result = result * 10 + temp;
            temp = 0;
            if (c == 0)
                break;
            else
                continue;
        }
        temp *= 1856645926;
        temp ^= c;
        temp >>= 2;
    }
    return result;
}

How did you find the magic numbers?

I did a search using my C code - tried all 32-bit numbers and all shifts. There are only a few possibilities - the code found only one in the range up to 2000000000.

you can use edx instead of edi (push edx before the idiv, pop eax after it, imul with ebx, add eax to edx) to save one byte.

Retina 0.8.2, 46 45 bytes
\w+
¶$&$&$&
%7=T`r\ot\huvs\ein`d`.
\D

^0+\B

Try it online! Link includes test cases. Explanation:
\w+
¶$&$&$&

Put each word on its own line and triplicate it.
%7=T`r\ot\huvs\ein`d`.

Transliterate the 7th character of each line using @UnrelatedString's string.
\D

Delete all remaining non-digit characters.
^0+\B

Delete leading zeros (but leave at least one digit).
Previous 46-byte more traditional solution:
T`z\wuxg`E
on
1
th
3
fi
5
se
7
ni
9
\D

^0+\B

Try it online! Link includes test cases. Explanation:
T`z\wuxg`E

The words zero, two, four, six and eight uniquely contain the letters zwuxg. Transliterate those to the even digits.
on
1
th
3
fi
5
se
7
ni
9

For the odd digits, just match the first two letters of each word individually.
\D

Delete all remaining non-digit characters.
^0+\B

Delete leading zeros (but leave at least one digit).

Ruby, 63 bytes, 52 bytes, 50 bytes
p $*.map{|d|'rothuvsein'.index (d*3)[6]}.join.to_i

-2 thanks to value ink's tip

Welcome to Code Golf! In Ruby, $* is an alias for ARGV, so feel free to use that to save extra bytes.

ARM Thumb-2 (manual rothuvsein, no div, no libc) 70 bytes
Machine code:
b5f0 2100 2420 f000 f816 0032 18c5 3b03
bf18 f1c3 0303 5cc4 a004 f000 f80c 240a
fb01 3104 1c68 2a00 d1ec bdf0 6f72 6874
7675 6573 6e69 f07f 0300 1c5b 5cc6 b10e
42a6 d1fa 4770

Assembly:
        .syntax unified
        .arch armv6t2
        .thumb
        .globl _strtoint
        .thumb_func
_strtoint:
        push    {r4-r7, lr}
        movs    r1, #0
.Lstrtoint_loop:
        movs    r4, #' '
        bl      _strfind
        movs    r2, r6
        adds    r5, r0, r3
        subs    r3, #3
        it      ne
        rsbne   r3, #3
        ldrb    r4, [r0, r3]
        adr     r0, .Lrothuvsein
        bl      _strfind
        movs    r4, #10
        mla     r1, r1, r4, r3
        adds    r0, r5, #1
        cmp     r2, #0
        bne     .Lstrtoint_loop
.Lstrtoint_loop_end:
        pop     {r4-r7, pc}

        @ naturally 4-byte aligned
        @ note: this is not null terminated - we blindly assume a match
.Lrothuvsein:
        .ascii "rothuvsein"
        @ naturally 2-byte aligned
        .thumb_func
_strfind:
        movs    r3, #-1
.Lstrfind_loop:
        adds    r3, r3, #1
        ldrb    r6, [r0, r3]
        cbz     r6, .Lstrfind_loop_end
        cmp     r6, r4
        bne     .Lstrfind_loop
.Lstrfind_loop_end:
        bx      lr

Explanation
Yet another port of the rothuvsein method, but this seems to be the first one in assembly. It is also done manually without the support of libc or fancy useless CISC instructions like repne scasb. Just plain, barebones RISC. That means that it is longer than other assembly languages.
Unlike my previous entries, I am a little more flexible with the calling convention.
While the input string (null terminated) is in r0 just like it would be in C, the output is a 32-bit integer in r1 instead of the traditional r0.
It can still be wrapped in C like so, since r1 is still used for 64-bit integers:
extern uint64_t _strtoint(const char *str);
uint32_t strtoint(const char *str)
{
    return (uint32_t)(_strtoint(str) >> 32);
}

Regardless of whether I care about the calling convention, I am going to have to do something with the link register so I can call my subroutine, so might as well push the callee-saved registers and remain mostly in line with the calling convention.
        .globl _strtoint
        .thumb_func
_strtoint:
        push    {r4-r7, lr}

Initialize our accumulator/output variable to 0.
        movs    r1, #0

Call our internal subroutine to find the end of the word.
r3 will have the length of the word, and r6 will have the last byte read. I will explain _strfind later.
.Lstrtoint_loop:
        movs    r4, #' '
        bl      _strfind

We save a copy of the last byte read for later to tell if we reached the null terminator.
        movs    r2, r6

Put the pointer to the string (advanced to the space) in r5.
        adds    r5, r0, r3

Here is the trickiest part: One does not simply str+str+str in assembly. We need to find the index.
Specifically, if we plot it out:
oneoneone
      ^
fourfourfour
      ^
sevensevenseven
      ^

We can turn it into this:
switch (strlen(str)) {
case 3: return str[0];
case 4: return str[2];
case 5: return str[1];
}

It can be done as 6 % strlen(str), but that is division. I can do better.
I could do a lookup table, but there is a better solution than that:
Remember that r3 is essentially strlen(str).
We can do this:
        subs    r3, #3
        it      ne
        rsbne   r3, #3 @ note: rsb = Reverse SuBtract

The equivalent C:
if ((len -= 3) != 0)
{
    len = 3 - len;
}

This works perfectly:
3 - 3       = 0
3 - (4 - 3) = 2
3 - (5 - 3) = 1

Now, we load the byte from the string at our offset...
        ldrb    r4, [r0, r3]

...then call _strfind with the rothuvsein lookup table to find it.
        adr     r0, .Lrothuvsein
        bl      _strfind

Now, we add the length to our accumulator times 10;
        movs    r4, #10
        mla     r1, r1, r4, r3 @ r1 = r1 * 10 + len

Take the copy of the string we made in r5, advance it past the space, and put it in r0 for the next iteration.
        adds    r0, r5, #1

Then, loop if we are not at a null terminator:
        cmp     r2, #0
        bne     .Lstrtoint_loop

Finally, return in r1 by popping the link register holding the return address into the program counter (along with restoring the other registers I saved).
.Lstrtoint_loop_end:
        pop     {r4-r7, pc}

_strfind subroutine
_strfind is the real workhorse here.
C users will find it similar to strcspn or strchr.
It is called with the null terminated string to search in r0 and the byte to find in r4.
It will return the index of the match (or null terminator) in r3 and the last byte read in r6.
First, initialize our counter at -1.
_strfind:
        movs    r3, #-1

On each iteration, increment the counter..
.Lstrfind_loop:
        adds    r3, r3, #1

Then, load str[counter] into r6
        ldrb    r6, [r0, r3]

Then loop unless r6 is \0 or if it matches r4.
        cbz     r6, .Lstrfind_loop_end
        cmp     r6, r4
        bne     .Lstrfind_loop

When we find it, return back to _strtoint.
.Lstrfind_loop_end:
        bx      lr

Kotlin, 83 bytes
fun String.d()=split(' ').fold(""){a,b->a+"rothuvsein".indexOf((b+b+b)[6])}.toInt()

+1 byte if you wanna support longs with toLong()
Same rothuvsein trick as the others, saving some precious bytes thanks to kotlin's nice toInt() and fold(). I just can't shake the feeling that some more bytes can be shaved off though...

C++ (gcc), 478 218 142 bytes
-(a lot) thanks to Jo King
int f(string s){char c[]="N02K8>IE;6";int i=0,n=0;while(s[i]){n=n*10-1;while((s[i]^s[i+1])+47!=c[++n%10]);while(s[i++]!=' '&&s[i]);}return n;}

Try it online!

127 bytes

Jelly, 20 18 17 16 bytes
Ḳ7ị“"c tẠ;Ḅ»iƲ€Ḍ

Try it online!
-2 bytes from running "rothuvsein" through user202729's string compressor.
-1 byte from stealing Jonathan Allan's zero-free enklact string, and putting it in a marginally differently structured program.
-1 byte because I actually kind of understand Jelly's dictionary-based string compression now
Ḳ                   Split the input on spaces,
             Ʋ€     for each word
            i       find the first 1-based index (defaulting to 0)
   “"c tẠ;Ḅ»        in "othuvseine"
 7ị                 of the element at modular index 7,
               Ḍ    and convert from decimal digits to integer.

I must admit, I'm disappointed I couldn't get a length reduction from othuvseinfeld.

Japt, 13 bytes
¸mg6 ì`Î¨uv

Try it
Looks like everyone else beat me to the same idea - could've saved myself the hassle of writing a script to brute force the optimal string for compression, only to find that, up to index 1,000,000 (it was early, I hadn't had my caffeine yet!), "rothuvsein" is the only possible string!
¸mg6 ì`...     :Implicit input of string
¸              :Split on spaces
 m             :Map
  g6           :  Character at index 6 (0-based, with wrapping)
     ì         :Convert from digit array in base
      `...     :  Compressed string "rothuvsein"

The compressed string contains the characters at codepoints 206, 168, 117, 118, 160 & 136.

...did you really try up to 1000000? The lcm of the lengths of the digit names is 60, so there's no point trying beyond that (60 is equivalent to 0, 61 to 1, etc).

@Grimy, it was early, I hadn't had my caffeine yet! Plugging a million into the script I wrote to generate all possibilities was as easy as any other number and saved me doing the maths on the LCM.

sed -re, 78 bytes
s/three/3/g;s/five/5/g;s/\w\w(\w)\w*/\1/g;s/ //g;y/eouxvgnr/12467890/;s/^0*//

T-SQL, 110 bytes
SELECT 0+STRING_AGG(CHARINDEX(LEFT(value,2),'_ontwthfofisiseeini')/2,'')
FROM STRING_SPLIT((SELECT*FROM i),' ')

Line break is for readability only.
Input is taken via table \$i\$, per our IO rules. I could have saved 14 bytes by pre-populating a string variable, but that's only allowed if the language has no other input methods.
Explanation:

STRING_SPLIT takes the input string and separates it at the spaces
CHARINDEX takes the first 2 characters and returns the (1-based) position in the string '_ontwthfofisiseeini'. 'ze' for zero is not in the string and returns 0 for "not found". The underscore ensures we only get multiples of two.
Divide by 2 to get the final numeral
STRING_AGG smashes the digits back together with no separator
0+ forces an implicit conversion to INT and drops any leading zeros. 1* would also work.

Scala, 66 64 62 bytes
_.split(" ").map("rothuvsein"indexOf _.*(3)(6)).mkString.toInt

Try it online!
This is the "rothuvsein" approach in Scala. The 7th character of each (repeated) number string is extracted via (numberString*3)(6). The position of this character in "rothuvsein" is then used as the correct numerical digit. The toInt conversion does the rest (e.g., dealing with leading zeros).
2 times 2 bytes saved thanks to @user by

an even more abused use of syntactic sugar :)
simply using toInt conversion rather than BigInt constructor

Nice answer! You can get 64 bytes with an underscore and more infix syntax.

Make that 62 if you use toInt instead of BigInt.

Perl 6, 45 bytes
+*.words>>.&{+(1...*.uniname.comb(.uc))}.chrs

Try it online!

Clean, 88 bytes
import StdEnv,Text
$s=toInt{#i\\n<-split" "s,c<-:"rothuvsein"&i<-['0'..]|c==(n+n+n).[6]}

Try it online!
Heavily based on Jonathan Allan's answer.
Uses a comprehension for indexing instead of indexOf / elemIndex.

J, 38 bytes
('b\e~mjPxw['i.[:u:70+1#.15|3&u:)&>@;:

Try it online!

VBA, 160 bytes
Function e(s)
s = Split(s, " ")
For i = LBound(s) To UBound(s)
s(i) = Int((InStr("ontwthfofisiseeini", Left(s(i), 2)) + 1) / 2)
Next
e = Val(Join(s, ""))
End Function

Matches the first two characters in a string, zero excluded.

(1/3) Great approach here, but it looks like you failed to count the newlines as bytes, and that you can get the bytecount way down if you use some tricks. Namely, there is no need to decaler the " " in the Split as that is the default value, Lbound(s) will always be zero and you can drop (...)+1 if you add a space to the beginning of the InStr data. Asside from that, you are better off using either a string or variant to handle holding the data coming out of the InStr statement as you dont need to use (i) or Join(s,""). Oh and Int(a/b) is the same as a\b.

(2/3) Using these, and a for each loop you can get your function down to 101 bytes as Function G(x):For Each c In Split(x):G=10*G+InStr(" ontwthfofisiseeini",Left(c,2))\2:Next:End Function or 101 bytes as a sub thet implicitly prints the output to the debug window as Sub F(x):For Each c In Split(x):v=10*v+InStr(" ontwthfofisiseeini",Left(c,2))\2:Next:Debug.?v:End Sub. If you restrict your answer you can even get it to 81 bytes as a Excel VBA immediate window function as For Each c In Split([A1]):v=10*v+InStr(" ontwthfofisiseeini",Left(c,2))\2:Next:?v.

(3/3) I highly recommend that you go take a look at our Tips for golfing in VBA Page for more info on these approaches. Cheers

Charcoal, 19 bytes
Ｉ⍘⭆⪪Ｓ §ι⁶rothuvsein

Try it online! Link is to verbose version of code. Port of @KevinCruijssen's 05AB1E answer. Explanation:
    Ｓ               Input string
   ⪪                Split on spaces
  ⭆                 Map over words and join
       ι            Current word
      §             Cyclically indexed
        ⁶           Literal `6`
 ⍘       rothuvsein Custom base conversion
Ｉ                   Cast to string for implicit print

PowerShell, 48 bytes
+-join($args|%{'rothuvsein'.indexof(($_*3)[6])})

Try it online!
Uses the same rothuvsein trick as others, thanks to Jonathan Allan. Expects input arguments via splatting, which on TIO manifests as separate command-line arguments.

Windows Batch, 169 bytes
@setlocal enabledelayedexpansion
@set z=zeontwthfofisiseeini
:a
@set b=%1
@for /l %%c in (0,2,18)do @if "!b:~0,2!"=="!z:~%%c,2!" set/aa=a*10+%%c/2&shift&goto a
@echo %a%

APL (Dyalog Extended), 26 bytes
10⊥'rothuvsein'⍳7⊢/⍤⍴¨≠⍛⊆⍨

Try it online!
A simple function which checks the first two letters of each word.
-30 bytes from Adám using Kevin Cruijssen's idea.
Explanation(old)
     {⍕2÷⍨1-⍨(2↑⍵)(⍸⍷)'zeontwthfofisiseeinite'} inner fn:
             (2↑⍵)                              take first two letters
                  (⍸⍷)'zeontwthfofisiseeinite'} find index of the letters in hardcoded string
       2÷⍨1-⍨                                   subtract 1, divide by 2
      ⍕                                         stringify
{⍎⊃,/{⍕2÷⍨1-⍨(2↑⍵)(⍸⍷)'zeontwthfofisiseeinite'}¨' '(≠⊆⊢)⍵} ⍵ → input
                                                ' '(≠⊆⊢)⍵  split input on spaces
   ,/                                                      join output of inner fn
 ⍎⊃                                                        execute it

42

26 using this algorithm.

Python 3, 85 bytes
I put two versions of my explanation just for fun :)
Split the input i into words and loop over it using list comprehension.
For all the words find the location of the first 2 letters in a lookup table ("zeontwthfofisiseeini"), making sure to divide by two - with // for floor division, finally use "".join( to combine into a string and int( to convert to integer and remove leading zero(s).
lambda i:int("".join([str("zeontwthfofisiseeini".find(x[:2])//2)for x in i.split()]))

Try it online!

lambda i: lambda function instead of using a def function
[for x in] use list comprehension to check through the input
i.split split the input at spaces (default delimiter)
"zeontwthfofisiseeini".find(x[:2]) find the location of the first two characters of x in a lookup list
//2 floor divide output of .find because it's checking the first 2 chars
str() convert position to string
"".join() combine output of list comprehension to a string
int() convert string to int and remove leading zero(s)

Also, this is accidentally similar to this answer but I made mine before looking at the other answers.

K (ngn/k), 27 bytes
10/"rothuvsein"?(*|7#)'" "\

Try it online!
Another port of Kevin Cruijssen's 05AB1E answer.

" "\ split input on spaces
(*|7#)' take the last character of each word (repeated to be of length seven)
"rothuvsein"? find index of character in "rothuvsein" (i.e. the seventh character of "zero" repeated is "r", which is at index 0)
10/ convert from a list of digits to a decimal number

Vyxal, 63 bitsv2, 7.875 bytes
⌈ƛ₀ʁ∆ċḟ;ṅ⌊

Try it Online!
Bitstring:
110010010001010010110111001001001001010010011010110111110111010

⌈ƛ₀ʁ∆ċḟ;ṅ⌊
⌈           # split on spaces
 ƛ     ;    # map over each
      ḟ     # their index in the list
  ₀ʁ∆ċ      # 0-9 as words
        ṅ⌊  # convert back to number

Created with the help of Luminespire.

BaCon, 83 72 bytes
Assuming the string is provided in w$, this code looks up the index in "zeontwthfofisiseeini" using a regular expression based on the unique first 2 characters of each word. The index is then divided by 2 providing the correct result.
FOR x$ IN w$:r=r*10+REGEX("zeontwthfofisiseeini",LEFT$(x$,2))/2:NEXT:?r

AWK, 76 64 bytes
More of the same, but with a pinch of AWK sparkling magic.
Edit: at first, I didn't looked for the answers, and my result was actually similar to some of them. I'm mesmerized by all these ingenious solutions.
{i=OFS=e;for(;NF>i++;)$i=index("othuvsein",substr($i$i$i,7,1))}1

Try it online!
{
i=OFS=e;     # We start setting the _i_ variable and the
             # Output Field Separator as the _e_ variable, which is
             # just empty, for never being assigned anything,
             # so _e_ is both evaluated as zero for _i_ and null for _OFS_
             # (thanks Brian Kernighan for that!)
for(;
    NF>i++;  # the looping goes on until _i_ reaches the Number of Fields (NF).
   )         # also, _i_ is incremented by 1 each turn.

     $i=                          # $i is each field text
        index("othuvsein",        # we get this magic Klingon and locate the
              substr($i$i$i,7,1)  # 7th letter of the input concatenated 3 times
             )                    # this has the same effect as looking
                                  # for the second to last letter on the word.

}
1            # finally, we print all the $i together
```

Perl 5 -p, 55 bytes
for$b(z,on,w,th,u,iv,x,v,g,ni){s/$b/@a/eg;$#a++}s/\D//g

Try it online!

Bash (pure), 85 83 bytes
r=rothuvsein
for j in $@
do
s=$j$j$j
t=${r%${s:6:1}*}
((i=i*10+${#t}))
done
echo $i

Try it online!
Literally just the same as every other rothuvsein entry. Concatenates three times and gets it at index 6.
First version which uses no string concatenation: (85 bytes)
r=rothuvsein
for j in $@
do
t=${r%${j:$((6%${#j})):1}*}
((i=i*10+${#t}))
done
echo $i

Try it online!
Pass the string as command line arguments. Expects $i to be unset.
Ungolfed version:
# Default value is zero
val=0
# declare our lookup table
lut=rothuvsein
# loop through command line arguments
for word in $@
do
    # The index is at 6 % len(word) (see my Thumb submission)
    idx=$(( 6 % ${#word} ))
    # chr = word[6 % len(word)]
    chr=${word:$idx:1}
    # Find a substring using a modified technique from the linked SO post
    substr=${lut%$chr*}
    # Add the length to val * 10
    (( val = val * 10 + ${#substr} ))
done
# Echo the result
echo $val

How to check if a string contains a substring in Bash - Stack Overflow

Pyth, 21 20 bytes
ssm`x."evt8†À‘"@d6c
Try it online!
Translates literally to print(int("".join(map(lambda d: str("rothuvsein".index(d[6%len(d)])), eval(input()).split())))) in Python 3.

Lua (110 bytes)

A translation to Lua of the rothuvsein trick, sorry. Note that we use 7 instead of 6 because Lua counts from 1, as sane humans do.
function x(s)z=""for w in s:gmatch("%a+")do z=z..(("rothuvsein"):find(w:rep(3):sub(7,7))-1) end return z+0 end

Swift, 135 128 91 bytes
let f={Int(.init(($0+"").split{$0<"0"}.map{[_]("2839016547")[Int($0,radix:36)!%204%13]}))!}

This is pretty much a port of @Arnauld's JavaScript answer.

Kotlin, 64 bytes
{split(" ").fold(0){a,b->10*a+"rothuvsein".indexOf((b+b+b)[6])}}

Improving upon this answer.
Try it online!