Skip to content

Instantly share code, notes, and snippets.

@romainmenke
Created July 5, 2016 20:12
Show Gist options
  • Save romainmenke/e13d763cb218fa41308ee837f84c39f2 to your computer and use it in GitHub Desktop.
Save romainmenke/e13d763cb218fa41308ee837f84c39f2 to your computer and use it in GitHub Desktop.
func Options(set int, options *[]int) {
var shift uint = 0
for set >= (1 << shift) {
if (1 << (shift + 1)) > set {
enum := (1 << shift)
*options = append(*options, enum)
set = set - enum
shift = 0
continue
}
shift++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment