Jump to content
BrainDen.com - Brain Teasers

Prime

Members
  • Posts

    871
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by Prime

  1. In the example of 8x8 grid, and equal speeds George and Lennie must each make 7 steps before they can collide. The probability of collision would be as following:

    ((7C0)2 + (7C1)2 + (7C2)2 + (7C3)2 + (7C4)2 + (7C5)2 + (7C6)2 + (7C7)2)/214 ~ 0.21

    Where 7C0 are all paths, where George moves only to the right and Lennie only down (just one path like that for each). The 7C1 represents the number of paths where George moves 1 step up and 6 steps to the right, which should be multiplied by the same number of paths for Lennie, where he moves 1 square to the left and 6 squares down. Etc..

    214 represents all possible combinations of 7-step paths between the two travelers.

  2. Not only I forgot about half dollar coin in my previous post, I also made few arithmetic errors in calculating probabilities.

    Although, the answer who has a better probability is the same.

    The tables of all coin collections with their respective weights are as following.


    15 COINS:
    PENNY NICKEL DIME QUARTER HALF WEIGHT
    10 3 0 1 1 60060
    10 0 4 0 1 15015
    5 9 0 0 1 30030
    10 1 1 3 0 60060
    5 7 1 2 0 1081080
    5 4 5 1 0 3783780
    0 13 1 1 0 210
    5 1 9 0 0 30030
    0 10 5 0 0 3003
    DIME PROBABILITY 0.268674895

    19 COINS
    PENNY NICKEL DIME QUARTER HALF WEIGHT
    15 2 0 1 1 46512
    10 8 0 0 1 831402
    15 0 1 3 0 15504
    10 6 1 2 0 23279256
    10 3 5 1 0 46558512
    5 12 1 1 0 2116296
    10 0 9 0 0 92378
    5 9 5 0 0 23279256
    0 18 1 0 0 19
    DIME PROBABILITY 0.205359807

    15 coins still looks better.
  3. “Simple” is a relative term. To me it would be a simple programming code, if it was feasible to traverse all variations. Alas, I am not going to live long enough to see my laptop running through 419 possible arrangements of coins. (My laptop is old and slow.)

    Nonetheless, I’ll go beyond the OP question and give the exact probability.

    The following are the tables of all variations to make a dollar with 15 and 19 coins. (Unless, I missed some.) The likelihood of each collection is different, hence the weight must be figured into the probability calculation.



    For 15 coins:
    PENNY NICKEL DIME QUARTER WEIGHT
    10 1 1 3 6651216
    5 7 1 2 279351072
    5 4 5 1 2933186256
    0 13 1 1 162792
    5 1 9 0 116396280
    0 10 5 0 11639628
    DIME PROBABILITY 0.252480672

    For 19 coins:
    PENNY NICKEL DIME QUARTER WEIGHT
    15 0 1 3 15504
    10 6 1 2 23279256
    10 3 5 1 46558512
    5 12 1 1 2116296
    10 0 9 0 92378
    5 9 5 0 23279256
    0 18 1 0 19
    DIME PROBABILITY 0.207250786

    So, 15-coin collection offers higher probability of randomly drawing a dime out of your pocket. Although, I must note, there is no random drawing of a dime, since coins are of different distinguishable size.

    Oops, I forgot about 50-cent coin. Back to the drawing board.

  4. Maybe I am misinterpreting the OP, but...

    Upon entering the chat room the very first two questions directed to the same person must draw spiteful responses. Therefore, ask U:


    1) Do you love V?
    2) Do you love W?

    And what is a spiteful response in this situation, but lying?
    This way we establish love/hate relations between U, V, and W. Thereafter, we could just ask the one who loves U about the true identity of U -- and the mystery is solved.
  5. ...

    Very nice Prime, as usual.

    And no, I don't think anything is messed up - nothing I see suggests that 10.2070 is incorrect.

    It would be interesting to see your code's four payoff values for 10 9 7 and 10 9 8 when the first two cards are above and below 14. The code would have to be modified from "search" mode to where 10 9 are given, and results sorted into two categories with respect to 14. I think I see how to calculate it directly, at least the EV for 10 9. The EV contribution for the third draw, in the two cases is a little complicated, and I didn't finish it last night.

    Thanks.

    I am not clear on the calculation you've requested. In the case of (10,9,7) the first two cards add up to 19. We don't need an aid of a computer to calculate the average payoff of the 4th draw in case of (10,9,7). It is (364-10-9-7)/49 ~ 6.9, meaning we must stay on (10,9,7) and even more so -- on (10,9,8).

    However, that's a moot point, since the recursive function comes back to the case of (10,9) with the value of the draw of ~8.5653, whereupon it "decides" it is better to stay on (10,9) and discards the value of the draw. Later on the function comes back to the case of (10) with the value of the draw of ~9.5431 and again discards it in favor of 10 in hand.

    Conversely, in the case of the first card of (9), the function returns the average payoff for the draw with the best strategy of ~9.5818, meaning that drawing is better.

    Actual program that I ran spills out into Excel spreadsheet optimal payoffs for all first two card combinations, all first card draws, and the final result. Also showing best staying card in each case.

  6. To calculate the payoff for the best dynamic strategy, we need a computer program, which traverses all variations choosing optimal path.

    In this case such program is relatively simple, while variations aren’t that many. Thus the payoff for the best strategy is found. To produce a formulation of the strategy complicates matters a little bit. However, in this case with the maximum of only 4 card draws, the best strategy can be expressed in simple terms as well.

    The average draw with the best strategy is 10.2070. With the given game set up that translates into a payoff of $10.2070 - $10 = +$0.2070 (or less than 21 cent per each shuffle on average.)

    The best strategy is like so:

    1). On the first card draw always stay on 10 or higher and draw otherwise.

    2). On the second card draw always stay on 9.

    3). On the third card draw:

    a) if the first two cards add up to 14 or more – stay on 7;

    b) if the first two cards add up to less than 14 – stay on 8

    Was this result calculated?

    The first two cards didn't seem to have that much effect in simulations.

    For 20 million simulations of four different cases: All values +/- 0.0003:

    Cards 1+2 < 14 Cards 1+2 >= 14 Average

    10 9 7 10.2047 10.2048 10.2048

    10 9 8 10.2069 10.2063 10.2066

    10 9 8 seems always preferable to 10 9 7.

    The code calculates the exact probability for the average payoff with the best strategy (unless I messed up.)

    Both simulation and code must take into account the cards leaving the deck. Also, must discard invalid (in terms of strategy) variations. E.g., a draw like (13, 13, 8).

    The criteria for the staying card on the third turn can be established analytically (see the spoiler.)

    The criteria for the staying card on the third turn can be established analytically:

    Initially all cards in the deck add up to 364 for the average draw of 364/52 = 7. Let’s say we drew (1, 1, 7). Now the average draw for the fourth turn becomes: (364-1-1-7)/49 ~ 7.24, which is better than 7, meaning we must draw. If we drew (9, 8, 7), the average of the fourth draw would be (364-9-8-7)/49 ~ 6.94, meaning we should stay on 7 and not go for the fourth draw.

    Whereas to find the second and first turn staying criteria and corresponding average payoff, I resort to writing a program.

    The code essentially relies on a recursive (one that invokes itself) function DrawCard(Deck(), Probability, DrawTurn) and looks somewhat like the following:

    ' Initialize deck with 4 cards of each value.

    For i = 1 To 13 Step 1

    deck(i) = 4

    Next i

    AvgPayoff = DrawCard(deck(), 1, 1)

    End

    '****************************

    ' The recursive function**

    '****************************

    DrawCard(deck(), Probability, DrawTrun)

    Rpay = 0 ‘ Accumulator for the average pay in this routine instance.

    ' Go through the cards from King=13 down to Ace=1,

    ' while finding stay/draw strategy and accumulating the average payoff.

    For c = 13 To 1 Step -1

    wkprob = Probability * deck( c ) / (53 - DrawTurn) ' deck( c ) is how many of this card is left in the deck; 53 - DrawTurn is the number of cards in the deck

    If DrawTurn < 4 Then

    For i = 1 To 13 ‘ make a work copy of the deck to pass down to the next level of the DrawCard() function.

    wkdeck(i) = deck(i)

    Next i

    wkdeck( c ) = wkdeck( c ) – 1 ‘ remove card from the deck

    drawpay = DrawCard(wkdeck(), wkprob, DrawTurn + 1)

    If drawpay > wkprob * c Then ' Drawing pays more

    Rpay = Rpay + drawpay

    Else ' Staying pays more, or same

    Rpay = Rpay + c * wkprob

    End If

    Else

    Rpay = Rpay + c * wkprob ‘ The last 4th draw

    End If

    Next c

    Return Rpay

    End

    Note, this code should find the optimal path and produce the average payoff for that path. It does not show what the optimal path is. To reveal the optimal path, you need to do some tweaking with the code.

  7. To calculate the payoff for the best dynamic strategy, we need a computer program, which traverses all variations choosing optimal path...

    The average draw with the best strategy is 10.2070. With the given game set up that translates into a payoff of $10.2070 - $10 = +$0.2070 (or less than 21 cent per each shuffle on average.)

    The best strategy is like so:

    1). On the first card draw always stay on 10 or higher and draw otherwise.

    2). On the second card draw always stay on 9.

    3). On the third card draw:

    a) if the first two cards add up to 14 or more – stay on 7;

    b) if the first two cards add up to less than 14 – stay on 8

    Since we have such a small portion of the total deck in play, do you really think that the values of the first 2 cards really significantly impact the values of the remaining cards [enough to influence the strategy]?

    Cards leaving the deck must be accounted for. Whether the difference between the exact and an approximate strategy is significant depends on how you view extra few $$ gained after thousands of games played. (See my next post.)

  8. To calculate the payoff for the best dynamic strategy, we need a computer program, which traverses all variations choosing optimal path.

    In this case such program is relatively simple, while variations aren’t that many. Thus the payoff for the best strategy is found. To produce a formulation of the strategy complicates matters a little bit. However, in this case with the maximum of only 4 card draws, the best strategy can be expressed in simple terms as well.

    The average draw with the best strategy is 10.2070. With the given game set up that translates into a payoff of $10.2070 - $10 = +$0.2070 (or less than 21 cent per each shuffle on average.)



    The best strategy is like so:
    1). On the first card draw always stay on 10 or higher and draw otherwise.
    2). On the second card draw always stay on 9.
    3). On the third card draw:
    a) if the first two cards add up to 14 or more – stay on 7;
    b) if the first two cards add up to less than 14 – stay on 8
  9. You can not beat me at this game, because after finding the best strategy, I will only play for the winning side.

    That said....


    A simple easily evaluated winning strategy is to stop when you hit "9" or higher.
    The probability of not finding "9" or higher in the first 4 cards is: (32/52)* (31/51)* (30/50)* (29/49) ~ 0.1328. Correspondingly, the probability getting one of those cards would be 1 – 0.1328 = 0.8672.
    Each "high" card value has the same probability (don’t feel like proving this formally.) The average payoff in $$ for the cases when hitting "9" or higher is (-1 + 0 + 1 + 2 + 3)/5 = $1.
    All other cards have the same probability of being in the 4th position when “9” or higher was not found. (Don’t feel like proving that one either.) Thus average payoff for those cases is (-2 – 3 – 4 - 5 – 6 – 7 – 8 – 9)/8 = -$5.50.
    Making the overall payoff: $1*0.8672 + -$5.50*0.1328 = +$0.1366.


    You also end up ahead when you stop only if you get “10” or higher as well as “8” or higher. The entire payoff table is as following:

    Stop only if you get
    King or higher ...... -$1.6718
    Queen or higher ... -$0.7593
    Jack or higher ...... -$0.1942
    “10” or higher ...... +$0.0857
    “9” or higher ........ +$0.1366
    “8” or higher ........ +$0.0084
    “7” or higher ........ -$0.2551
    “6” or higher ........ -$0.6163
    “5” or higher ........ -$1.0437
    “4” or higher ........ -$1.5119
    “3” or higher ........ -$2.0017
    “2” or higher ........ -$2.50

  10. I am referring to "riffle shuffles". The random riffle shuffle is modeled by cutting the deck binomially and dropping cards one-by-one from either half of the deck with probability proportional to the current sizes of the deck halves.

    How many shuffles must be done, to where every possible card configuration is possible?

    I came to know that shuffle by the name “perfect shuffle.” Of course, you should start dropping the cards from the top half, so that the top card does not end up in the same position after the shuffle.

    I wouldn't call that shuffle “random.” For a deck of 52, it takes 26 perfect shuffles to put it in exact reverse order and 52 shuffles total to return the deck to its original state.

    For the powers of 2, the number of perfect shuffles required to return a deck into its original state is logarithm base 2.

    E.g., a popular Russian game Proferans (“preference”) is played with a deck of 32 cards. Thus it takes only 5 perfect shuffles to return it to the starting order. I've met some gamblers who spent years practicing (while serving their jail sentences) to be able to make that shuffle every time.

    In your favorite spreadsheet application, fill column “A” with numbers 1 through 52. Fill 52 cells in column “B” with formulas: =A27, =A1, =A28, =A2,... and so on. Select column “B” and drag it over the next 51 columns. You got all 52 permutations of perfect shuffles for a deck of 52 cards. If you know the starting order and the number of shuffles, you can tell the exact sequence of cards. What randomness is in that?

    Conversely, I've read somewhere that you need at least 7 riffle shuffles to randomize the deck.

  11. The house must be a regular rectangle, per OP.

    For those who's never seen Baba Yaga's hut, copy and paste this: домик бабы-яги картинки (or you could go with "Baba Yaga's hut") into Google's image search.

    With such house construction, the dog's freedom is limited by the length of the leash until the time Baba Yaga gets hungry...

  12. Your house used to belong to Baba Yaga – an old witch who lived deep in the forest in a hut standing on chicken legs. The dog leash is tethered to one of the legs, and there is enough clearance for the dog to run freely under the house.

  13. He can touch the pieces and the clock (touch move rule is also observed) ..he can imagine them in 3D like the blindfolded Rubik cubes solver.

    In that case, it could be anything at all. After all, the man is blind, and there is nothing in the OP to suggest he can see two moves ahead.

    However,

    He could grab the pawn on c6 first, then put his Knight there.

    that would be illegal

    By what rules? I haven't played in any official tournament in awhile. Have the rules changed recently? From what I remember, if you touch your opponent's piece first, strict adherence to "touch move" would require capturing that piece if possible.

  14. He can touch the pieces and the clock (touch move rule is also observed) ..he can imagine them in 3D like the blindfolded Rubik cubes solver.

    In that case, it could be anything at all. After all, the man is blind, and there is nothing in the OP to suggest he can see two moves ahead.

    However,

    He could grab the pawn on c6 first, then put his Knight there.

  15. a. nxp ck b. nxn

    b. qb8 !! ---bishop 8---

    that would be illegal

    if i am currently at queen 6, then my queen can go to king 7 and end at bishop 8. what am i missing?

    You are using a different notation. Other people here use algebraic notation, where columns are numbered "a" through "h" from left to right (on the White's side); and rows are numbered 1 through 8 from White's side to Black's. Your notation is called "descriptive". When you say qb8!!, it could be confused with algebraic Qb8. In descriptive notation correct designation of the move you suggest would be: Q-QB8?? (Queen to Queen's Bishop 8).

    After which White loses his Queen: BxQ. (The Black's Bishop on g4, or in descriptive notation, the Bishop on KN5 (King's Knight 5) takes the White Queen.)

  16. do you mean Re5?

    I'm sure, he meant R x d5 checkmate.

    However, there are many people out there who do not need a chessborad with pieces to play chess, and those people don't have to be actually blind.

    The answer is

    none.

    Blind man does not play by moving his pieces, he simply announces his moves.

    Whether his next move would be N x c6 to make the checkmating combination as found by Witzar is another question. The position is strange. Looks like both sides must have made some random moves leading to this point in the game. So anything is possible.

    And after looking closer at other posts, I see Witzar has already given that answer.

  17. I never know when to use Q.E.D. vs Without loss of generality, is there a difference or is it just a style thing?

    All numbers that are prime relative to 2 and 3 are of the form 6n ± 1, where n is an integer.

    All prime numbers greater than 3 must be prime relative to 2 and 3 and must be of the form 6n ± 1.

    (6n + 1)2 + 11 = 36n2 + 12n + 12, divisible by 12.

    (6n - 1)2 + 11 = 36n2 - 12n + 12, also divisible by 12.

    Q.E.D.

    "Q.E.D" means "which had to be demonstrated" and typically refers to the concluding statement(s) of a proof.

    "WLOG" points to a relation between statements/formulas. Like, if it is good for Goose than without loss of generality it must be good for Gender. Or, let's say, in an induction proof: if the rule holds for a randomly chosen number WLOG it must hold for any other number. Q.E.D.

  18. The labels on these boxes of candy got so mixed up that none of the boxes is labeled correctly.

    3 chocolates
    3 cremes
    2 chocolates 1 creme

    What is the least number of candies you must taste test, and from which box(es), to determine which box has what?

    I don't see a stipulation that each box truly corresponds to one of the labels. (A box could contain 2 creams and 1 chocolate, or nuts and bolts.)

    With that stipulation, the problem would be exactly as http://brainden.com/forum/index.php/topic/484-truth-in-packaging/?hl=%2Btruth+%2Bpackaging as well several other similar topics.

    Here Paralogic has given the answer.

×
×
  • Create New...