You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jim Infield
783f1ca1f1
|
3 years ago | |
---|---|---|
src | 3 years ago | |
.gitignore | 3 years ago | |
Cargo.lock | 3 years ago | |
Cargo.toml | 3 years ago | |
README.md | 3 years ago |
README.md
Ones and Zeros
Given an array of ones and zeroes, convert the equivalent binary value to an integer.
Eg:
[0, 0, 0, 1]
is treated as0001
which is the binary representation of1
.
Examples:
Testing: [0, 0, 0, 1] ==> 1
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 0, 1] ==> 5
Testing: [1, 0, 0, 1] ==> 9
Testing: [0, 0, 1, 0] ==> 2
Testing: [0, 1, 1, 0] ==> 6
Testing: [1, 1, 1, 1] ==> 15
Testing: [1, 0, 1, 1] ==> 11
However, the arrays can have varying lengths, not just limited to 4.