Binary List to Decimal

Published by Mubashir Hassan in

In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system. Given a list of ones and zeroes of a binary number, return the equivalent decimal value.

Examples

binary_to_decimal([0, 0, 0, 1]) ➞ 1

binary_to_decimal([0, 0, 1, 0]) ➞ 2

binary_to_decimal([1, 1, 1, 1, 1, 0, 1, 1, 0, 1]) ➞ 1005

Notes

N/A

Watch a quick demo on how Edabit works.