Finding the shortest path
public class shortestpath { public static void getpath ( String path ) { int x = 0 , y = 0 ; for ( int i = 0 ; i < path . length (); i ++ ) { if ( path . charAt ( i ) == 'E' ) { x += 1 ; } else if ( path . charAt ( i ) == 'W' ) { x -= 1 ; } else if ( path . charAt ( i ) == 'N' ) { y += 1 ; } else if ( path . charAt ( i ) == 'S' ) { y -= 1 ; } } int x2 = x * x ; ...