The Challenge
The game Light Up! is a simple puzzle game where the objective is to light up every cell in an n-by-n array with light bulbs. However, there are blocks in the way that will prevent light from traveling, and no lightbulb can be places such that another lightbulb shines light on it. Each light bulb has light coming from it in only the horizontal and vertical directions.
You must make a program that takes in an array of 5 numbers. Your program must convert each numbers into a 5-bit binary number, which will define at what places in the array there are blocks. If there is a 1, there is a block at the spot, but if there is a 0, there is not a block. Each number converted to binary defines a row, like:
[5,6,5,6,5] -> [00101, 00110, 00101, 00110, 00101] ->
. . B . B
. . B B .
. . B . B
. . B B .
. . B . B
Where B = blocks that block light
Your program must take this array and find the solutions (places where you need to put light) and give it back as an array of 5 numbers.
Example:
Input: [1,5,9,13,17]
Which translates to [00001, 00101, 01001, 01101, 10001]
Making the array:
. . . . B
. . B . B
. B . . B
. B B . B
B . . . B
A solution for this array is
L ~ ~ ~ B
~ L B ~ B
~ B ~ L B
~ B B ~ B
B L ~ ~ B
~ = Light L = Lightbulb
Which gives the binary array of lights [10000, 01000, 00010, 00000, 01000]
And translates back to [16, 8, 2, 0, 8]
Output: [16, 8, 2, 0, 8]
Rules
- Two lightbulbs can not be in the same row or column if there is no block between them.
- A lightbulb's light can only travel horizontally and vertically, and will stop if there is a block in the way
- Your program must take in an array
[a,b,c,d,e]
and output in the same form - If there are no way the array can be solved, your program must not give output or state "No Output."
- This is a [code-golf] challenge, lowest amount in bytes wins!