A small puzzle for you
This had me stumped for a bit, but I was quite pleased when I came up with a relatively simple solution.
Given several arrays, each of which has elements which are a subset of allowed elements, and given that every allowed element appears at least once in each array, how do I rewrite all arrays such that each element of each array which has an identical value to an element in another array has the same index number in each array, with missing elements being
OK, that was a mouthful. Here's an example which should make it clear:
@a = ( 'b', 'c', 'f' ); @b = ( 'a', 'd' ); @c = ( 'c', 'd', 'e' );
I should have the following when I'm done:
@a = ( undef, 'b', 'c', undef, undef, 'f' ); @b = ( 'a', undef, undef, 'd', undef, undef ); @c = ( undef, undef, 'c', 'd', 'e', undef );
In other words, I'm trying to line up all of those values (because they're going to an HTML table and my $client needed to see the missing values). Once you see the answer to the puzzle, it's actually not too hard.
Post your solutions below!