Sha256: a5f2b4dc9dccd46a92b3d1367eaf4d6e988fbd932098381f480714300984acc0

Contents?: true

Size: 579 Bytes

Versions: 91

Compression:

Stored size: 579 Bytes

Contents

gestures = ['wink', 'double blink', 'close your eyes', 'jump']


def handshake(code):
    actions = [gestures[i] for i in range(len(gestures))
               if (code >> i) % 2 == 1]
    return actions if code < 16 else list(reversed(actions))


def secret_code(actions):
    actions = [a for a in actions if a in gestures]
    result = sum(1 << i for i, action in enumerate(gestures)
                 if action in actions)
    if len(actions) > 1 and (gestures.index(actions[0]) >
                             gestures.index(actions[1])):
        result += 16
    return result

Version data entries

91 entries across 91 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.179 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.178 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.177 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.176 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.175 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.174 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.173 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.172 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.171 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.170 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.169 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.167 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.166 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.165 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.164 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.163 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.162 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.161 tracks/python/exercises/secret-handshake/example.py
trackler-2.2.1.160 tracks/python/exercises/secret-handshake/example.py