5156
2017-06-27 14:44:58
0
from random import shuffle
a = [1, 2, 4, 3, 7, 5, 6, 8]
b = [8, 3, 7, 1, 4, 6, 5, 2]
idx1 = 4
idx2 = 7
unfixed_a = a[:idx1] + a[idx2:]
unfixed_b = b[:idx1] + b[idx2:]
shuffle(unfixed_a)
shuffle(unfixed_b)
offspring1 = unfixed_a[:idx1] + a[idx1:idx2] + unfixed_a[idx1:]
offspring2 = unfixed_b[:idx1] + b[idx1:idx2] + unfixed_b[idx1:]