Wednesday, January 13, 2016

Hybrid puzzles - Layering and Tiling 
In the previous post on puzzle category named Layering we introduced a category of puzzles with an outcome as an overlay of the outcomes of individual puzzles. In another category called Tiling we introduced a category of puzzles that aggregated the results of each puzzle as tiles on a horizontal plane. 
  
Today we combine the layering and the tiling to create a new category called hybrid where the tiles in the plane can be colored as per the color-coding clues given to reveal a part of the picture and the tiles can be rearranged to form a collective picture in that layer. The layers can then be overlaid one on top of the other to reveal the whole composite picture. 
  
This requires the solver to order the tiles horizontally and the layers vertically to reveal the final big picture.  She starts out with unraveling the individual tiles and finishes with the final full and detailed picture Since the tiles need not be square and can even be jig saw pieces, the solver doesn’t necessarily have to interpret the picture revealed in each tile. 
  
We have seen examples of Tiling and Layering in puzzles other than coloring such as  Samurai Sudoku puzzles where two different forms of Sudoku are overlaid one over the other such that the overlap of a common set of tiles help solve both the layers. The example I used however is one which uses color your own jig saw pieces puzzle.

#codingexercise  Find Minimum scalar product of two vectors with co-ordinates x and y respectively.
for eg
     v1 =  1 3 -5
     v2 = -2 4 1
-5 1 3
-2 1 4
Coordinates can be rearranged to form new vectors
    minimum scalar product = -25

int GetMinimumScalarProduct(List<int> v1, List<int>v2)
{
assert (v1.Length == v2.Length); // or pad
v1.Sort();
v2.Sort();
int productsum = 0;

while(v1.Length > 0)
{
// pick one
int vi = v1.First();
if (Math.abs(v1.First()) < Math.abs(v1.Last()))
{
vi = v1.Last();
v1.RemoveAt(v1.Length -1);
}
else
{
    v1.RemoveAt(0);
}

// pick other
if ( vi * v2.First()<= vi* v2.Last())
{
productsum += vi*v2.First();
v2.RemoveAt(0);
}
else
{
productsum += vi*v2.Last();
v2.RemoveAt(v2.Length-1);
}

//repeat
}
return productsum;
}
-3 1 5
-2 1 4

No comments:

Post a Comment