Check if two blocks of bits dovetail perfectly.
A block of bits is a fixed sequence of 8 bits just like this for example : 11110101.
For simplicity we refer to
0bits but they can be everything capable of representing those two states in a clear, well defined and consistent way, for example :
>0 / <0
0 / !0
What does it mean dovetail perfectly?
1's bits of one block can fit only into 0's of the other block or outside it.
You can shift an entire block left or right but you cannot modify a block nor reverse it.
The resulting block must contain all 1's of both inputted blocks and only those.
There must not be any 0's between 1's while there can be any trailing and leading 0's.
The resulting block can be more than 8 bits long.
Input : [ 10010111, 01011010 ] 10010111 ↓ ↓ ↓↓↓ 01011010 <- shif by 2 result 0111111111 => dovetails perfectly
Input: two blocks of bits.
- You don't need to handle empty blocks (all 0's).
Output: your solution have to clearly state if input blocks can dovetail perfectly as described above or not.
- the resulting block won't be a valid answer.
00000000, 00000000 | you don't 00000000, ... | need to ... , 00000000 | handle these 11111111, 11111111 -> True 11111111, 10000000 -> True 11110000, 00101000 -> False 00101000, 10100000 -> True 10000000, 00111000 -> True 00110011, 11001100 -> True 00010000, 11101010 -> False 10000100, 10111101 -> True 01111010, 01011111 -> True 10010101, 00001101 -> False 01010011, 10110000 -> True 00000111, 00010011 -> False 00000011, 00000101 -> False
- Input/output can be given by any convenient method.
- You can print it to STDOUT, return it as a function result or error message/s.
- Either a full program or a function are acceptable.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.