Introduction
You may remember sudoku, where there can only be one of each number in each row, column and block of nine. The general idea is that if the array contains but one element, you can submit that as a deterministic solution. If there are already filtered arrays (by rows, columns and 3×3 blocks) the remainder can still be deterministic. Where
- a=[1,2];
- b=[1,3];
- c=[2,3];
- d=[1,2,3,4]
d should be reduced to [4] as it apparently cannot be anything else.
Challenge
Provide a sniplet that compares n arrays. For every X, if only X numbers appear at least once in a set of X arrays, then all those X numbers should be removed from each array not in the set. The elements are integer numbers ranging [1, n].
Winning criterion
Lowest character count.
"I'm too young to die" version
9 arrays at most, 9 elements at most.
Test Cases
[1,2]; [2,3]; [1,3]; [1,2,3,4]
[1,2,3]; [2,3,4]; [1,5,6]; [2,3]; [1,4]; [1,2,3,4,6]Test outputs
[1,2]; [2,3]; [1,3]; [4]
[1,2,3]; [2,3,4]; [5]; [2,3]; [1,4]; [6]
n
arrays in the input, and their union is exactly[1,2,...,n]
? Also, I don't really understand the challenge. What should the output be in your example? \$\endgroup\$