Messy Kevin V
After messing up syncing the server logs, messing up analysing the log messages, and messing up indexing files on his company's servers, Kevin was unceremoniously fired.
As he packs up his belongings on his desk, he grabs his digital clock and looks at it. It has a seven-segment display, and he ponders how it works internally, from a programming perspective.
Each of the seven segments could be represented by a bit, indicating whether that segment is on or off. For example, a bit sequence 1001111
maps to the seven segment display showing the number .
Below is an image that shows all mappings of digits from to
.
His clock is a bit broken though, so sometimes, some segments do not light up. Kevin ponders some more, and wonders if he took two seven-segment digits (working or otherwise) and overlaid them on top of each other, would he be able to display a valid digit?
Input
The first and second line each contain strings of length that contain only
0
and 1
, the state of each digit of the display when read from left to right. It uses the same mapping scheme shown above.
Output
If it's possible to form a valid digit then output the digit itself, otherwise output .
Example
Input 1
0111111
1000000
Output 1
8
The first seven-segment digit is , while the second one is a fragment that only has the middle segment lit up. However, when overlaying one on top of the other, you get all segments lit up, forming the number
.
Input 2
0000000
1001001
Output 2
-1
A valid digit is not formed.
Comments