Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 193133

Submitted on 18 Jan 2013 by Alfonso Nieto-Castanon

Correct

26Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
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 =
     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