Number of steps required to reach point ( x , y ) from ( 0 , 0 ) using zig | Function to return the required position ; Driver Code
< ? php function countSteps ( $ x , $ y ) { if ( $ x < $ y ) { return $ x + $ y + 2 * ( ( $ y - $ x ) / 2 ) ; } else { return $ x + $ y + 2 * ( ( ( $ x - $ y ) + 1 ) / 2 ) ; } } $ x = 4 ; $ y = 3 ; echo ( countSteps ( $ x , $ y ) ) ; ? >