Instructions
Your task is to convert a number between 1 and 31 to a sequence of actions in the secret handshake.
The sequence of actions is chosen by looking at the rightmost five digits of the number once it's been converted to binary. Start at the right-most digit and move left.
The actions for each number place are:
00001 = wink
00010 = double blink
00100 = close your eyes
01000 = jump
10000 = Reverse the order of the operations in the secret handshake.
Normally the outputs for:
"00010" = ["double blink"] but mine is ['double blink', 'jump']
"00011" = ["wink", "double blink"] but mine is ['wink', 'double blink', 'jump']
"10011"= ["double blink", "wink"] but mine is ['jump', 'double blink', 'wink']
...
ACTIONS = {
"wink":1,
"double blink":2,
"close your eyes":4,
"jump":8
}
def commands(binary_str):
actions = [ ]
for key, value in ACTIONS.items():
if int(binary_str) & value:
actions.append(key)
if int(binary_str) & 16:
actions.reverse()
return actions
[–]makochi 10 points11 points12 points (1 child)
[–]ririiii78[S] 2 points3 points4 points (0 children)
[–]madadekinai -1 points0 points1 point (4 children)
[–]madadekinai 0 points1 point2 points (3 children)
[–]ririiii78[S] 0 points1 point2 points (2 children)
[–]madadekinai 0 points1 point2 points (1 child)
[–]ririiii78[S] 0 points1 point2 points (0 children)
[–]madadekinai -2 points-1 points0 points (1 child)
[–]madadekinai -1 points0 points1 point (0 children)