Problem Statement  
A Zcurve is a path that traces through all the points in a twodimensional square grid in such a way that the four quadrants are visited in order: first the upper left, then the upper right, then the lower left, and finally the lower right. If those quadrants contain more than 1 cell, these cells are visited recursively, in the same manner. A Zcurve of order N is a path through a 2^N by 2^N grid. A Zcurve of order 1 is a simple Zshape through a 2by2 grid, as shown below.
Here is a diagram of a Zcurve of order 2.
Notice the order each quadrant was visited:  upper left quadrant: 0, 1, 2, 3  upper right quadrant: 4, 5, 6, 7  lower left quadrant: 8, 9, 10, 11  lower right quadrant: 12, 13, 14, 15 You will be given a value N and coordinates r and c denoting the row and the column in a 2^N by 2^N grid. Coordinates range from 0 to (2^N)1 inclusive, with the upper left corner at coordinates (0,0). Assuming you start from the upper left corner and the points are traversed in the order specified by a Zcurve of order N, determine how many steps it takes to reach the point at coordinates (r,c).  
Definition  
 
Constraints  
  N is between 1 and 15, inclusive.  
  r and c are between 0 and 2^N1, inclusive.  
Examples  
0)  
 
1)  
 
2)  
 
3)  
 
4)  
 
5)  
