Posts

Showing posts with the label Algomaniac

The Old Saint And Three Questions Problem Code: THREEQ

Image
  The Old Saint And Three Questions Problem Code: THREEQ Once upon a time, there was a hero and an old saint. And like in any story with a hero and an old saint, the old saint asked the hero — three questions! But here's the twist: each question was a binary question, which means that the answer to each must be either a 'Yes' or a 'No', not none, not both. Our hero, who was not so wise in the ways of science, answered them arbitrarily and just hoped he is correct. The old saint, being so old, does not remember which answers were correct. The only thing that he remembers is - how many of them were 'Yes', and how many of them were 'No'. Our hero will pass the test if the old saint cannot distinguish his responses from the set of correct answers i.e. if the number of 'Yes' and 'No' in the responses matches that in the correct answers, regardless of their order. You are given the answers to each of the three questions, and the responses o...

Say No To Drugs Problem Code: NODRUGS

Image
  Say No To Drugs  Problem Code:  NODRUGS There are  N N  people participating in a race. The  N t h N t h  participant is your friend, so you want him to win. You are not a man of ethics, so you decided to inject some units of a Performance Enhancement Drug (don't ask where that came from) in your friend's body. From the charts, you came to know the speed of every player. Formally, for a player  i i , his speed is denoted by  S i S i . The change in speed with one unit of the drug is  K K  units. Note that  K K  can be negative, which means the drug has more side effects than benefits. Of course, there will be a drug test before the race, so your friend will be caught if the number of units of the drug in his blood is greater than or equal to  L L . You need to determine whether you can help your friend to win the race (with or without drugs), without getting caught. Note:  A player wins the race if he has the m...