Ajinkya And Punctuality

All submissions for this problem are available.
Problem description.
Ajinkya is a sincere and a punctual student. He always wants to reach the lecture hall well before the scheduled class timings. As the distance between the hostel and lecture hall is too long , he travels using a bicycle. He likes to ride straight and doesn’t like to turn the bicycle as it reduces his speed, so he always chooses a path which has the least number of turns from hostel to lecture hall. The college is a modeled as R X C grid of points (1<=R,C<=100). It consists of roads which are depicted by “.” and bushes are depicted by “ *”. Obviously Ajinkya can’t ride through the bushes and only has to take the roads. The hostel is denoted by “H” and lecture hall is denoted by “L”. Help Ajinkya to choose a path to minimize the number of turns.
Input
Input description.
The first line contains two spaced integers ‘R’ and ‘C’ which are the no of rows and columns in college map. Next R lines each contains C characters depicting the map of the college.
Output
Output description.
Print the minimum number of turns which Ajinkya takes on his ride.
Note: There is always a path from hostel to the lecture hall.
Example
Input: 8 7 ....... ......L ......* *****.* ....*.. ....*.. .H..*.. ....... Output: 3
Explanation
Example case 1.
There are many paths which result in minimum number of turns.
One path contains
First Turn > (8,2),
Second Turn > (8,6) and
Third Turn > (2,6).
Author:  varunsekar94 
Tags  varunsekar94 
Date Added:  26012015 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions