Two coastal beacon towers each transmit a nightly count of light flashes. Because a beacon can only be lit or unlit at every tick, each tower's count is recorded directly as a binary string -- the tower's flash tally in base two, with no leading zero unless the tally itself is zero. Given the two towers' flash-tally strings, compute the binary string representing the combined total number of flashes from both towers, again written with no leading zero unless the total is zero.
Line 1: a binary string a, the first tower's flash tally.
Line 2: a binary string b, the second tower's flash tally.
A single line containing the binary string for a + b.
a, length of b <= 10000a and b consists only of the characters 0 and 1.a nor b has a leading zero, unless the string is exactly "0".Example 1
Input
101 110
Expected
1011
Explanation
Tower one recorded 5 flashes (binary 101) and tower two recorded 6 flashes (binary 110); their combined total is 11 flashes, written in binary as "1011".
Example 2
Input
111 1
Expected
1000
Explanation
7 flashes plus 1 flash is 8 flashes, written in binary as "1000".
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →