Sha256: 6eafbfb12068c458f878d62238faf0699a4600f6dee1eb8cdda03fac4c4c4ccc

Contents?: true

Size: 217 Bytes

Versions: 396

Compression:

Stored size: 217 Bytes

Contents

def parse_binary(digits):
    if set(digits) - set('01'):
        raise ValueError("Invalid binary literal: " + digits)
    return sum(int(digit) * 2 ** i
               for (i, digit) in enumerate(reversed(digits)))

Version data entries

396 entries across 396 versions & 1 rubygems

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