Created
July 5, 2016 20:12
-
-
Save romainmenke/e13d763cb218fa41308ee837f84c39f2 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
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