The confused twister
Japt, 63 bytes
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Twisted:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;
Test it online: Original, Twisted
How it works
I hadn't posted yet on the original twisting challenge, but the shortest answer I could come up with is 31 bytes:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
The untwisting algorithm I came up with is a lot shorter:
Uy m@XsV=Y%Xl)+X¯V}R y;
However, this won't work very well when intertwined with the other program. Fortunately, there's a way to make the two more similar:
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy m@XsV=(Y*Xl +Y %Xl)+X¯V}R y;
Now all that's different between the two is the +
/-
, which is already properly aligned to switch places when twisted!
Uy m@XsV=(Y*Xl -Y %Xl)+X¯V}R y;
Uy // Transpose rows and columns in U.
m@ }R // Map each item X and index Y in the result, split at newlines, to:
Y*Xl -Y // Take Y times X.length and subtract Y.
%Xl) // Modulate the result by X.length.
XsV= // Set V to the result of this, and slice off the first V chars of X.
+X¯V // Concatenate this with the first V chars of X.
y; // Transpose the result again.
// Implicit: output *last* expression