Your task is to accept as input two gene sequences, and a sequence of "cross over points", and return the gene sequence that results from the indicated cross overs.
What I mean by this is, say you have the sequences [A, A, A, A, A, A, A] and [Z, Z, Z, Z, Z, Z, Z], and cross over points of 2 and 5. The resulting sequence would be [A, A, Z, Z, Z, A, A], because:
Cross Here: V V
Indices: 0 1 2 3 4 5 6
Genes 1: A A A A A A A
Genes 2: Z Z Z Z Z Z Z
Result: A A Z Z Z A A
^ ^
Note that while I'm using letters here for clarity, the actual challenge uses numbers for genes.
The result is the first sequence until a cross over point is encountered, then the result takes from the second sequence until another cross over point is encountered, then the result takes from the first sequence until a cross over point is encountered...
Input:
Input can be any reasonable form. The two sequences can be a pair, with the points as the second argument, all three can be separate arguments, a single triplet of
(genes 1, genes 2, cross-points), a map with named keys...The cross points will always be in order, and will always be inbounds. There won't be duplicate points, but the list of cross over points may be empty.
Gene sequences will always be the same length, and will be non-empty.
Indices can be 0 or 1 based.
Genes will always be numbers in the range 0-255.
It doesn't matter which argument is "genes 1" or "genes 2". In the case of no cross over points, the result can either be either entirely "genes 1" or "genes 2".
Output
Output can be any reasonable form that isn't ambiguous. It can be a array/list of numbers, an array of string numbers, a delimited string of numbers (some non-numeric character must separate the numbers)...
It can be returned or printed to the std-out.
Entries can by full programs or functions.
Test Cases (genes 1, genes 2, cross points) => result:
[0], [1], [0] => [1]
[0, 1], [9, 8], [1] => [0, 8]
[0, 2, 4, 6, 8, 0], [1, 3, 5, 7, 9, 1], [1, 3, 5] => [0, 3, 5, 6, 8, 1]
[1, 2, 3, 4], [5, 6, 7, 8], [] => [1, 2, 3, 4]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 2, 3, 6, 8] => [1, 1, 0, 1, 1, 1, 0, 0, 1, 1]
This is Code Golf.