Cody

# Problem 638. Uniform binary crossover

Solution 148655

Submitted on 15 Oct 2012 by James
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
%% mask = [1 0 0 0 1 1 1 0 0]; parent1 = [0 0 0 1 1 1 0 0 0]; parent2 = [1 1 0 0 1 0 1 1 0]; children = [0 1 0 0 1 1 0 1 0;1 0 0 1 1 0 1 0 0]; assert(isequal(uniform_crossover(mask,parent1,parent2),children))

2   Pass
%% mask = 1; parent1 = 1; parent2 = 0; children = [1;0]; assert(isequal(uniform_crossover(mask,parent1,parent2),children))

3   Pass
%% mask = 1; parent1 = 1; parent2 = 0; children = [1;0]; assert(isequal(uniform_crossover(mask,parent1,parent2),children))

4   Pass
%% mask = [1 1 1 0 1 0 1 1 0 0 0 0 0 1 0]; parent1 = [0 1 1 1 1 0 0 0 0 1 0 0 1 0 1]; parent2 = [0 1 1 0 1 0 1 0 1 0 1 1 0 1 1]; children = [0 1 1 0 1 0 0 0 1 0 1 1 0 0 1;0 1 1 1 1 0 1 0 0 1 0 0 1 1 1] assert(isequal(uniform_crossover(mask,parent1,parent2),children))

children = Columns 1 through 10 0 1 1 0 1 0 0 0 1 0 0 1 1 1 1 0 1 0 0 1 Columns 11 through 15 1 1 0 0 1 0 0 1 1 1