Jump to content
BrainDen.com - Brain Teasers

James33

Members
  • Posts

    38
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by James33

  1. By not run forever, do you mean that we must be able to fix a time at which the algorithm will certainly have terminated by? If you mean that it just has to end at some point then

    Just generate a random binary number with the same number of digits as n, if the result is higher than n then discard and repeat. It is inevitable that this will end but there is no upper bound on the time taken.

    This seems like it would work. There is only one issue I can see that that might come up. Although it is unlikely, there is a small chance that all of the random binary numbers could be 0. Either there should be a check to discard it or have 1 added before comparing it to n.

    True, I was just giving an outline of what I would do because I don't think it is what the OP as it has no upper bound on time taken.

  2. Suppose there is such algorithm.

    Then there exists an integer k such that computing rand(3) is guaranteed to use binary generator at most k times.

    Let m be an integer <=k and let's assume that the algorithm uses binary generator exactly m times.

    Effectively binary generator generates a binary sequence of length m.

    Since there is no other randomness in the algorithm except the binary generator,

    each such sequence determines the final result of rand(3).

    Therefore we can assign to each sequence the result of rand(3), which is an element of the set {1, 2, 3}.

    Since we have 2^m sequences and 2^m is not divisible by 3, there has to be a result of rand(3)

    that is assigned to more sequences than some other result.

    But each sequence is equally probable, so some result will occur more frequently that some other result.

    This is true for any integer m <=k.

    This proves that such an algorithm cannot exist.

    I don't think that the logic there quite works. Certain results could be ignored (conditional on what has been generated) to make everything divisible by 3.

  3. By not run forever, do you mean that we must be able to fix a time at which the algorithm will certainly have terminated by? If you mean that it just has to end at some point then

    Just generate a random binary number with the same number of digits as n, if the result is higher than n then discard and repeat. It is inevitable that this will end but there is no upper bound on the time taken.

  4. I'm tired so my reasoning is probably flawed:

    Send a message to get any instant response, the time this is recieved will give you t1+t2.



    Send a message requesting the time, this will give the time as (actualy time)-t2

    Send a message requesting the error in the recieved time, say this message is sent at actual time=T, so the time sent will be T-t2, this will be recieved as T+t1-t2 and at actual time T+t1 so the server can calculate the error as t2 (since the server has all information required).

    The server can then send t2 as a message and this can be used to calculate t1 and the actual time can easily be worked out from there.

  5. 1. sqrt(9)-(sqrt(9)!/sqrt(9))



    2. (sqrt(9)+sqrt(9))/sqrt(9)

    3. sqrt(9)+sqrt(9)-sqrt(9)

    4. sqrt(9)+(9/9)

    5. sqrt(9)+(sqrt(9)!/sqrt(9))

    6. sqrt(9)!+9-9

    7. 9-(sqrt(9)!/sqrt(9))

    8. 9-(sqrt(9)/sqrt(9))

    9. 9+9-9

    10. 9+(sqrt(9)/sqrt(9))

    11. 9+(sqrt(9)!/sqrt(9))

    12. 9+9-sqrt(9)!

  6. An idealized basketball falling from a height h bounces from the floor to a height h/2.

    Tell us two things:

    1. The ball is dropped from a height of 1m.

      Does it come to rest (stop bouncing) in finite time?

    2. Xavier, in shows us that after 9.31 seconds, the ball comes to rest.

      We now specify that the ball is

      blue initially and on each bounce it changes color,

      alternating between

      blue and red. After the ball comes to rest, it ceases to change color.

      Question 2: what is its color after coming to rest?

    As the bouces quicken, it changes between blue and red quicker and quicker so when it stops bouncing it is changing between them infinitly quickly so its clolour will be purple.

  7. this obviously only applies to invertible functions and since invertible functions have exactly one inverse, I claim 1/x is the only such function.

    For starters,

    f^-1(f(x)) = x

    but you told us that:

    f^-1(f(x)) = 1/f(x)

    putting these together,

    f(x) = 1/x

    Other than tricky ones, to me seems to be the only such function... Thinking of tricky ones now ...

    I think the OP means that f^-1(x)=1/f(x).

    One group fo solutions would be ones of the form (ax+b)/(cx+d) for appropriate a,b,c,d.

  8. Flip the coin 1+floor(log(base2)(n)) times, record a 1 for each heads and a 0 for each tails to get a binary number, also assign each person a number between 1 and n. The person you choose is the one with the number which is equal to the binary number once it has been converted into decimal.

  9. Thought about it some more I I think I have an algorithm that would do it more efficiantly

    Suppose at some stage in this proccess we have k people.



    If k is even, split the group in 2, asign each a side of the coin and flip it, discard the incorrect group (how you split into 2 and choose who is heads is irrelivent since the coin toss randomises it whatever the case).

    If k is odd remove someone from the group and do the same as above to the remaining even-numbered group, for the additional person flip the coin to determain where they are discarded or not. This is fair on everyone as each individual has a 50/50 chance of being discarded.

    Eventually there will only be 1 person remaining.

  10. One way would be to flip the coin once of each person, on a heads that person moves into group 1, on a tails that person moves into group 2. Repeat this for everyone on group 1, with people getting tails moving to group 2. If no-one in group 1 gets a head just ignore that round and go again. Eventually there will only be 1 person in group 1 which is the one who gets a free meal. I'm certain this is equal for everybody although there could be an unlimited number of coin flips.

×
×
  • Create New...