programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# strings and lighter[easy]

Arjunkumar Shastry
Ranch Hand
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?

Sameer Jamal
Ranch Hand
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 ]

 With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.