my dog learned polymorphism
The moose likes Programming Diversions and the fly likes strings and lighter[easy] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "strings and lighter[easy]" Watch "strings and lighter[easy]" New topic

strings and lighter[easy]

Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
You are given two strings of length X each and one lighter.Burning of each string completely takes 60 minutes.Burning time is not necessarily proportional to length,means its not necessary that in 30 minutes exactly half of the string will get burned.
Now you want to count 45 minutes.How will you do it?

Namma Suvarna Karnataka
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
Put the two strings apart from each other. Light both ends of first string and one end of second string. When the first string is completely burned out, exactly 30 min have been passed, which means that the second string has exactly 30 min left to burn. Light the other end of the second string. It will now burn out twice as fast in exactly 15 min. The total burning time is 45 min.

Am I missing something.
[ October 17, 2005: Message edited by: Sameer Jamal ]
I agree. Here's the link:
subject: strings and lighter[easy]
It's not a secret anymore!