Wednesday, August 6, 2008

2 Maths problem

I. Find the acute angle between the minute and hour needle of a clock for a given time H:M?

Minute needle angle, m = M * (360/60) = 6M
Hour needle Angle, h = H * (360/12) + M * ( (360/12) / 60) = 30H + M/2

Solution 1:
Acute Angle = arccos(cos(h-m))

Hint: Cos() will bring all angle from -1 to 1 range and arccos() will bring that to 0 to 180(pi)

Solution 2:
Difference in angle, d = |h-m|
or
d = (h-m)%360
Opposite angle, od = 360 - d
Acute angle = 180 - x
Obtuse angle = 180 + x
where x = |(od - d)/2| = |180 - d|
i.e, Acute Angle = 180 - |180-d|

II. Given a circular queue of size n (0..n-1). Other variables are front and rear of the queue. Find a formula to find number of elements in queue from n, front and rear?

Solution:
number of elements = (rear - front) % n

That is the magic of mod operator.

Monday, August 4, 2008

Amina Books

On Friday 1st August, I visited Amina book shop in Thrissur. Its a one room shop opposite to Chettiyangadi mosque in Post Office Road. I had been there before and purchased one book in Sufi literature - "Arifakulude thathwashasthram". I didnt get a chance to go through that book.
I had a chat with the proprietor, Mr.Hamza. I enquired, if there is any other book apart from Ihya' ulum al-din in Sufi literature that is translated to Malayalam. And to his knowledge these are the 2 books. I have purchased full volume Ihya' ulum al-din from there. It costed me Rs.2300. There are 2 low price edition of the same book for Rs.600 and Rs.1200. I preferred the better one, because I thought this book may be useful for my entire life and to the next generation rather than one-time reading. Mr.Hamza had taken my contact number so that he can inform me about any new arrival in this genre.

I checked with him if people are buying Ihya. He said eventhough people buy this book, most selling book is the one recommended in a Jeevan TV programme hosted by a Moulavi. Matter of fact that book is written by him on prayers and ways to solve petty problems in life. Solutions are like to read so and so chapter of Quran for n number of times. Absolute crap!

Linux Command Line and Shell Scripting Bible

 Linux Command Line and Shell Scripting Bible, 4th Edition, by Richard Blum and Christine Bresnahan is a complete guide for software profess...