Sunday 30 August 2015

strategy - Sink the Submarine


There is submarine somewhere on the number line. Initially (say, at midnight), it is at position $A$, and is moving $B$ units per hour to the right, where $A$ and $B$ are both integers; both $A$ and $B$ are unknown to you. You have an unlimited number of torpedoes. Starting at midnight, and at the top of every hour, you can fire a torpedo somewhere on the number line, sinking the sub if it is there. What strategy can you use to guarantee you eventually sink the sub?



Answer



We are given the following information
P(0) = A

V(t) = B
P(t) = A + Bt


Since we know our current time, we can cycle through all the possibilities of P(t) by cycling through all the combinations of A and B at the current time and we will eventually land on the correct combination of A and B.
NOTE: There are actually an infinite amount of combinations because the set of integers are unbounded. But since we know that A and B are finite numbers, this algorithm will eventually find the answer.


Here is a picture which shows a method for computing all the possible combinations. I'm sure there's probably an actual function out there that is able to compute the unique pair of values given an integer.
enter image description here
NOTE: The image depicted here is not the exact same as the function used in the solution below (it's simply been rotated). To view the actual geometry of the function used, visit the link.


Note that we have to increment t by 1 each time because we are firing the torpedo with respect to the current time (1 hour intervals).


I'll try to come up with a better explanation and maybe an animation if I have the time.


EDIT: (Sketchy) Algorithm for enumerating 2 rational numbers:

Since enumerating 2 rational numbers would essentially require enumerating 4 integers (i.e. integers a,b,c,d correspond to rational numbers a/b and c/d), this is what this algorithm essentially does.


First add 0 (special case that only needs to be considered once)


Then find all permutations where 1 is the biggest



1 1 1 1



Then find all permutations where 2 is the biggest



2 1 1 1
...

2 2 2 2



and so on...


Now for each line we need to enumerate all possible permutations of +/- (2^4 permutations).


No comments:

Post a Comment

Understanding Stagnation point in pitot fluid

What is stagnation point in fluid mechanics. At the open end of the pitot tube the velocity of the fluid becomes zero.But that should result...