Created
May 18, 2017 10:36
-
-
Save rhysd/f73833a3f126955a2cac7b72d318ae60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
func main() { | |
arr := []int{5, 4, 3, 2, 1} | |
l := len(arr) | |
for i, e := range arr[:l/2] { | |
j := l - 1 - i | |
arr[i] = arr[j] | |
arr[j] = e | |
} | |
for i, e := range arr { | |
if e != i+1 { | |
panic("oops") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment