2

Here I have a problem in understanding the optimal testing strategy.

In a scenario, You have been given two laptop batteries and a testing device. The testing device will make the battery connected to it (one battery can be connected at a time) deliver x mA, where x is an integer. The testing device is constructed in such a way that the battery will always explode if there’s any risk of explosion at that current.

Now we want a program that receives inputs. Input consists of multiple lines, one line per case (at most 200 test cases). Each line contains a single positive integer n between 1 and 4711 inclusive, giving the current at which the battery is known to explode. Input is terminated by a line containing 0, which should not produce any output.

And produce Output, where for each case, print one line containing the worst-case number of tests to perform when using an optimal testing strategy.

|-----------------|------------------|
|  Sample Input   |  Sample Output   |
|--------- -------|------------------|
    1                0
    2                1
    10               4
    23               7
    0    

This was a programming contest question marked as an easy question. but I do not get the definition of the optimal testing strategy. What can be the boundaries? Generally what this question means?

Amir-Mousavi
  • 268
  • 2
  • 13

2 Answers2

4

in my opinion, The designer of this question just wanted to make a famous algorithm problem a bit complicated but made it totally nonsense.

This is the famous two egg problem where

You are given two eggs and access to a 100-story building. Both eggs are identical. The aim is to find out the highest floor from which an egg will not break when dropped out of a window from that floor. If an egg is dropped and does not break, it is undamaged and can be dropped again. However, once an egg is broken, that’s it for that egg.

Amir-Mousavi
  • 268
  • 2
  • 13
-1

The question is badly posed, either because the person posing the question isn't very good at writing English, or because you copied or paraphrased it badly. As asked, we have no idea what "an optimal strategy" is or what it is supposed to be. The crux of the problem is in "giving the current at which the battery is known to explode" instead of "giving a current at which the battery is known to explode". And of course "will always explode if there’s any risk of explosion at that current" is more than problematic.

In the "two egg problem" the optimal strategy is obviously one that minimises the number of stairs that I need to climb, which is likely to invalidate most answers that you find.

In case of the battery, I'd investigate how long it takes until the battery explodes, how much money the tester is paid per hour, and what the cost of an exploding battery is, and determine the optimum strategy from this information.

gnasher729
  • 32,238
  • 36
  • 56