permuting two arrays python solution