# Printing criss cross of two strings

Given a set of two strings guaranteed to be the same length, print their criss cross.

The criss cross of two strings is obtained as follows.

1. Yield the second character of the second string, then the first character of the first string.
2. Yield the first character of the second string, then the second character of the first string.
3. Discard the first character of each string.
4. If the strings have more than one character each, go back to step 1.

For example, if the two strings are

Truck
Tower


the criss cross is

oTTrwroueuwcrcek


as illustrated in the following diagram. Each color represents a different iteration of criss-crossing. The numbers show the corresponding character's indices in the output.

• You shouldn't accept an answer until at the very least around a week has passed, it might be beaten at any time. – Pavel Jul 2 '17 at 6:26
• @Phoenix okay I'll keep that in mind next time (this was my first question on this stackexchange) – K Split X Jul 2 '17 at 19:52

# Jelly, 10 8 bytes

żṚj@¥2\U


Try it online!

### How it works

żṚj@¥2\U  Main link. Arguments: s, t (strings)

Arguments:    "Truck", Tower"
ż         Ziphwith; create all pairs of corresponding characters.
Return value: ["TT", "ro", "uw", "ce", "kr"].
2\   Reduce each pair of adjacent strings by the quicklink to the left.
¥       Combine the two links to the left into a dyadic chain.
Ṛ            Reverse the left string.
j@          Join the second string, using the previous result as separator.
Map:          "TT", "ro" -> join("ro", "TT") -> "rTTo"
"ro", "uw" -> join("uw", "or") -> "uorw"
etc.
Return value: ["rTTo", "uorw", "cwue", "kecr"]
U  Upend; reverse each string.
Return value: ["oTTr", "wrou", "euwc", "rcek"]
(implicit) Flatten and print.

• Wow thats pretty amazing – K Split X Jun 30 '17 at 22:53
• Explanation, please? – Shaggy Jun 30 '17 at 23:24
• @Shaggy I've edited my answer. – Dennis Jun 30 '17 at 23:38

## JavaScript (ES6), 51 bytes

f=([G,...O],[L,...F])=>O?F+G+L+O+f(O,F):''


f=([G,...O],[L,...F])=>O?F+G+L+O+f(O,F):''

console.log(f("Truck", "Tower"))

# Python 3, 56 bytes

f=lambda s,t:s[1:]and t+s+t+s+f(s[1:],t[1:])


Try it online!

Crossed out 44 is still 44

[_]#_=""
(a:b)#(x:y)=y!!0:a:x:b!!0:b#y


Slightly less golfed / maybe a little more readable:

[_]      # [_]      = ""
(a:b:bs) # (x:y:ys) = y:a:x:b:((b:bs) # (y:ys))

• Fun Fact: On my browser at least, crossed out 44 is no longer 44 in the header :o – HyperNeutrino Jun 30 '17 at 23:42

# PHP>=7.1, 64 bytes

for([,$a,$b]=$argv;$c=$b[++$i];)echo$c,$a[$i-1],$b[$i-1],$a[\$i];


PHP Sandbox Online

# C++14, 115 112 bytes

As unnamed lambda, parameters should be like std::string:

#define P putchar(
[](auto A,auto B){for(int i=0;++i<A.size()&&i<B.size();P B[i]),P A[i-1]),P B[i-1]),P A[i]));}


Ungolfed and usage:

#include<iostream>
#include<string>

using namespace std;

#define P putchar(
auto f=
[](auto A,auto B){
for(int i=0;
++i<A.size() && i<B.size();
P B[i]),
P A[i-1]),
P B[i-1]),
P A[i]));
}
;

int main(){
string A="Truck",B="Tower";
f(A,B);
}