Skip to content

Instantly share code, notes, and snippets.

@rhysd
Created May 18, 2017 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhysd/f73833a3f126955a2cac7b72d318ae60 to your computer and use it in GitHub Desktop.
Save rhysd/f73833a3f126955a2cac7b72d318ae60 to your computer and use it in GitHub Desktop.
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