7
1
There exists a brain game called Enumerate (which I made, based on Takuzu). Your challenge is to play this game.
Task
Solve a game of 4x4 Enumerate/Takuzu.
- Receive a starting grid via STDIN or command line.
- Output the solved grid via STDOUT or writing to file.
Rules
A game is characterized by a 4x4 board, made up of red and purple cells.
There must be the same number of red and purple cells in each row and column (2 red and 2 purple in each).
There must be no identical rows or columns.
Input
The starting grid will be given as a 16 character/byte string consisting of only 0
, 1
, and 2
. Here is an example:
0001100002001200
1
represents a red cell and 2
represents a purple cell. All input boards will be solvable.
Note: If your language does not support string literal input, you may take input as an array of integers. Please state in your answer that this is the case. So there is no confusion, this is what said array should look like:
[0, 0, 0, 1, 1, 0, 0, 0, 0, 2, 0, 0, 1, 2, 0, 0]
No nested arrays are allowed.
Output
The solved board should be output in the same format as above; a 16 character/byte string, consisting of only 1
and 2
. Here is the solution for the input above:
2121112222111212
Again, 1
represents a red cell and 2
represents a purple cell.
Bonuses
A -25 byte bonus is offered for any answer that outputs the solved board as an ASCII grid. Here is an example of the previously mentioned board.
2|1|2|1
-+-+-+-
1|1|2|2
-+-+-+-
2|2|1|1
-+-+-+-
1|2|1|2
A -50 bytes bonus is offered for any answer that outputs the solved board in color. This can be output as an image or colored text.
If colored text is chosen, the output should look like this:
2121
1122
2211
1212
However, if an image is the chosen output method, the resulting file should be 20x20 pixels, where each cell is a colored 5x5 pixel block. Here is an example:
Here are the color codes:
Red - #a73cba OR (167, 60, 186)
Purple - #f94a32 OR (249, 74, 50)
Samples
In: 0020010100000100
Out: 1221212112122112
In: 0010000200121000
Out: 2211112221121221
In: 1000100102000000
Out: 1122122122112112
1
This puzzle is known as Takuzu, incidentally.
– Doorknob – 2016-01-06T01:35:16.007Thanks! I didn't know there was a formal name for it. Added that to the intro :) @Doorknob – Zach Gates – 2016-01-06T01:37:15.463
Can we take the input as an array of
0
,1
, and2
? What about a two-dimensional array? – lirtosiast – 2016-01-06T01:40:08.070Only if your language doesn't support string literal input (if there are any). I'll add that to the question. @ThomasKwa – Zach Gates – 2016-01-06T01:41:29.103
Huh. I thought this game was called Unruly
– quintopia – 2016-01-06T02:51:01.223@quintopia So did you also think Solo wasn't Sudoku, and Keen wasn't KenKen? :P – Doorknob – 2016-01-06T03:09:36.210
@Doorknob Solo is just an abbreviation of Sudoku, and I thought Keen was Kakuro or something like that. I thought Unruly was original to the puzzle pack, unlike those, but like several others. (I think Unruly is a better implementation though.) – quintopia – 2016-01-06T03:16:06.020
All input boards will be solvable. Just 1 solution or could be more than 1? (Input
0000000000000001
) – edc65 – 2016-01-06T11:59:42.2031You can assume that there will be enough cells provided in each input to yield a single solution. @edc65 – Zach Gates – 2016-01-06T12:43:20.083
If the language supports strings, is it mandatory to use string input, or can numeric input be chosen? – Luis Mendo – 2016-01-06T12:58:42.857
String input is mandatory if the language supports it. @LuisMendo – Zach Gates – 2016-01-06T13:00:16.943
For the -25% bonus, does the ASCII grid need to be output with the
+-1
symbols? Or can it be just the 4x4 grid of numbers? – Luis Mendo – 2016-01-06T16:00:02.260Has to include the symbols @LuisMendo – Zach Gates – 2016-01-06T16:01:24.327
This is just begging for a Piet solution! – Rohan Jhunjhunwala – 2016-07-09T21:26:31.867