package main import "fmt2" func shuffle(nums []int, n int) []int { for i := 0; i < n; i++ { nums[i*2] = (nums[i]&1023)<<10 | nums[i*2] } for j := n; j < len(nums); j++ { nums[2*(j-n)+1] = (nums[j]&1023)<<10 | nums[2*(j-n)+1] } for i, _ := range nums { nums[i] = nums[i] >> 10 } return nums } func main() { var nums = []int{2, 5, 1, 3, 4, 7} var n = 3 fmt2.Println(shuffle(nums, n)) }