32 lines
553 B
Go
32 lines
553 B
Go
|
package secret
|
||
|
|
||
|
// Handshake converts an integer into a string slice
|
||
|
// of the code
|
||
|
func Handshake(code int) []string {
|
||
|
if code < 0 {
|
||
|
return nil
|
||
|
}
|
||
|
var ret []string
|
||
|
if code&1 == 1 {
|
||
|
ret = append(ret, "wink")
|
||
|
}
|
||
|
if code&2 == 2 {
|
||
|
ret = append(ret, "double blink")
|
||
|
}
|
||
|
if code&4 == 4 {
|
||
|
ret = append(ret, "close your eyes")
|
||
|
}
|
||
|
if code&8 == 8 {
|
||
|
ret = append(ret, "jump")
|
||
|
}
|
||
|
if code&16 == 16 {
|
||
|
var revRet []string
|
||
|
for len(ret) > 0 {
|
||
|
revRet = append(revRet, ret[len(ret)-1])
|
||
|
ret = ret[:len(ret)-1]
|
||
|
}
|
||
|
ret = revRet
|
||
|
}
|
||
|
return ret
|
||
|
}
|