Given two binary numbers in string format, get the sum of them.
Anonymous
Enumerate through the reversed binary string; using the index, perform a bitwise shift for every "1". var result = 0 for (index, char) in binaryString.reversed().enumerated() { if char == "1" { result += 1 << index } } print(result)
Check out your Company Bowl for anonymous work chats.