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.119 tracks/python/exercises/binary/example.py
trackler-2.2.1.118 tracks/python/exercises/binary/example.py
trackler-2.2.1.117 tracks/python/exercises/binary/example.py
trackler-2.2.1.116 tracks/python/exercises/binary/example.py
trackler-2.2.1.115 tracks/python/exercises/binary/example.py
trackler-2.2.1.114 tracks/python/exercises/binary/example.py
trackler-2.2.1.113 tracks/python/exercises/binary/example.py
trackler-2.2.1.111 tracks/python/exercises/binary/example.py
trackler-2.2.1.110 tracks/python/exercises/binary/example.py
trackler-2.2.1.109 tracks/python/exercises/binary/example.py
trackler-2.2.1.108 tracks/python/exercises/binary/example.py
trackler-2.2.1.107 tracks/python/exercises/binary/example.py
trackler-2.2.1.106 tracks/python/exercises/binary/example.py
trackler-2.2.1.105 tracks/python/exercises/binary/example.py
trackler-2.2.1.104 tracks/python/exercises/binary/example.py
trackler-2.2.1.103 tracks/python/exercises/binary/example.py
trackler-2.2.1.102 tracks/python/exercises/binary/example.py
trackler-2.2.1.101 tracks/python/exercises/binary/example.py
trackler-2.2.1.100 tracks/python/exercises/binary/example.py
trackler-2.2.1.99 tracks/python/exercises/binary/example.py