Jump to content
BrainDen.com - Brain Teasers

bubbled

Members
  • Posts

    93
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by bubbled

  1. I agree with bubbled about Jasen's statement:

    Hidden Content

    Bubbled, I agree that you have to recognize that bullets disappear, but I disagree that you have to simulate each second; merely calculate collision timestamps

    Hidden Content

    I agree with bubbled about Jasen's statement:

    Hidden Content

    Bubbled, I agree that you have to recognize that bullets disappear, but I disagree that you have to simulate each second; merely calculate collision timestamps

    Hidden Content

    OK, I'm trying to wrap my head around you statement of calculating collision times, without simulating the the actual firing of the bullets. How would you calculate the result of this 4-bullet sequence. b_0 = v 0.9;  b_1 = v 0.1;  b_2 = v 0.2;  b_3 = v 0.99. Unless you account for the firing of the bullets and the timing thereof, it might appear that b_3 annihilates b_2 and b_0 and b_1 survive. But taking into account the firing phase, b_2 annihilates b_1, and later b_3 annihilates b_0. 

  2. I agree with bubbled about Jasen's statement:

    Hidden Content

    Bubbled, I agree that you have to recognize that bullets disappear, but I disagree that you have to simulate each second; merely calculate collision timestamps

    Hidden Content

    I agree with bubbled about Jasen's statement:

    Hidden Content

    Bubbled, I agree that you have to recognize that bullets disappear, but I disagree that you have to simulate each second; merely calculate collision timestamps

    Hidden Content

    When in doubt, for correctness sake, I try to simulate what actually happens. However, I'm not opposed to using a good insight to make things significantly easier.

    I'd be concerned about an edge case where the fact that a bullet didn't exist yet during a collision we might get an incorrect result, but I've thought about extreme edge cases and think your approach works.

  3. Error! I left out a case: corrected cases are:

    Hidden Content

     20000 samples of this yields 0.371. This is close enough to bonanova's statement of 3/8 being spot on, that I'm looking forward EAGERLY to the simple analytical explanation :-)

     

    CaptainEd, before creating the code above, I also thinking like you, but then I reliaze the question is not that hard.

    Look at again at prop 1 and 2

    1. Every second, a gun shoots a bullet along a straight line.
    2. Each bullet has a random speed between 0 and 1   ----> I guest bonanova means 0 m/s to 1m/s (not 0 to invinity)

    which means that if  V3> v2 > v1 then second bullet will hit first bullet, before third bullet fired.

     

     

    This last statement I disagree with. If v1 is .5 and v2 is .51 and v3 is .99, v3 will annihilate v2 first.

    at time 0: b1 at 0

    at time 1: b2 at 0, b1 at .5

    at time 2: b3 at 0, b2 at .51, b1 at 1.0

    at time 3: b3 at .99, b2 at 1.02, b1 at 1.5

    at time 4:  b1 at 2.0 and b3 and b2 have collided.

  4. Error! I left out a case: corrected cases are:

    Hidden Content

     20000 samples of this yields 0.371. This is close enough to bonanova's statement of 3/8 being spot on, that I'm looking forward EAGERLY to the simple analytical explanation :-)

     

    You need to be careful during the firing phase. I don't think you'll get an accurate result if you just stick the bullets (either 4 or 10) out there with positions and velocities. Some of them may not be there by the time all bullets have been fired. You need to simulate each second of the firing phase to determine which bullets are where as each bullet is fired. 

  5. With the new NFL season about to start, I thought a football logic puzzle would be timely.

    You are the coach of a football team. Your team is down 14 points with a few minutes to go. You are driving and score a touchdown to go down by 8. Should you go for a 2-point conversion or kick a 1-point PAT?

    For simplicity, assume that a kick is 100% and the 2-point conversion is 50%. These numbers are pretty close to reality in the NFL, though the rules have changed for this year and we have yet to see what effect they will have.

    You can also assume the other team won't score again. If this were to happen, it's extremely unlikely that you could win. Also, assume that overtime is a 50-50 proposition.

    Also, try to answer a second part of the question. If you think it's right to kick, please determine at what rate you'd need to covert a 2-point try before you'd consider going for 2. Likewise, if you think it's right to go for 2, how low would your 2-point conversion rate have to be, before you think it would be right to kick. 

  6. dgreening points out that the same can be said if the last bullet is slowest.

    So, would that make the floor 19%? 10% for first bullet fastest, and (.9 X .1) for last bullet slowest and first bullet not fastest.

    If so, that would suggest that total annihilation happens a vast majority of the time, you don't get the first fastest or last slowest.

  7. I followed most of this on first read. Nicely done and clearly commented. Thanks.

    I'd like to compile and run it. What do I need for that?

    I'd strongly suggest you use the Anaconda distribution of Python. Python is open source, which is a huge strength (great packages) and a weakness (hard to keep up with and occasional compatibility issues). Anaconda gathers all the most important packages, like Scikit-Learn (machine learning), Numpy (blazing fast matrix operations), Pandas (R-like statistical and data tools) and many others, makes sure they play nice together and updates them. Those are the packages that are of most interest to me, but there are hundreds. 

    It also includes Spyder which is a really good IDE. You can get all of these packages on your own, but then updating one, might break another. Anaconda takes care of all that for you. You just check to see if there's an update every once in a while, and if there is, it will all come at once and work.

    Anaconda is free and works on Windows, Mac and Linux. I also suggest you use the 2.7x compatible version of Python. It seems to be the more common version.  

    https://store.continuum.io/cshop/anaconda/

  8. It doesn't look iike you allow for a roll where player 1 can win and player 2 can't (the first roll). 

    Your procedure for a game should be this:

    While Winner = 0
          LastValue1 = NewValue1   
          LastValue2 = NewValue2
          NewValue1 = Int((6 * Rnd) + 1)
          NewValue2 = Int((6 * Rnd) + 1)
          If NewValue1 = 6 And NewValue2 = 6 Then Winner = 1
          If NewValue1 + NewValue2 = 7 And LastValue1 + LastValue2 = 7 Then Winner = 2
       Wend

    I have checked back my code, and I think nothing wrong there. Student A still can win even at first roll.

    In your code, can student B win on the first roll? I don't know VBA, but if you try this:

    While Winner = 0
          NewValue1 = Int((6 * Rnd) + 1)
          NewValue2 = Int((6 * Rnd) + 1)
          If NewValue1 = 6 And NewValue2 = 6 Then Winner = 1
          If NewValue1 + NewValue2 = 7 And LastValue1 + LastValue2 = 7 Then Winner = 2

          LastValue1 = NewValue1   
          LastValue2 = NewValue2
       Wend 

    Do you get a different result?

    markweitzman above, derived a rigorous Markov chain proof of the correct answer. If your code is not getting the same answer there must be something wrong.

  9. I took a different approach to the chances that Julie wins an individual game. Given that badminton is a very skillful game, I think the long-run win percentages for Julie vs. John on a given game could range from 1% to 99%, and still satisfy the constraint that both are good players. I defend this assumption by the fact that the 100th best tennis player in the world is a "good player." Yet, he's probably about 1% to beat Djokovic in a match.

    So, I started with Julie having a 1% chance to win a game, and then simulated 100,000 seven game sets and 100,000 nine game sets. Then upped her percentage to 2%, etc. all the way up to 99%. So I simulated 9.9M games for each of 9 game sets and 7 game sets, over a wide range of win percentages.

    I get the same answer as to which is more likely. But very different overall percentages:

     

    Chances of winning exactly 4 out of 7 games: 12.6%

    Chances of winning exactly 5 out of 9 games: 10.1%

    BTW, if Julie is exactly as good as John, I agree that she will win exactly 4 out of 7 game about 27% of the time. 

  10. Simulation by VBA :

    Sub RandomBulletTest()
    Dim Anhilated As Integer
    Dim Bullets As Variant
    Dim AllAnhilated As Single
    Bullets = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
        
        For Cnt = 1 To 500000
            ''random inisial speed between 0 to 1
            For i = 0 To 9
                Bullets(i) = Rnd
            Next i
            
            ' i for front bullet and j for bullet behind i
            ' if speed j > speed i then both bullets anhilated
            ' i assign -2 for anhilated bullets
            For i = 0 To 9
                For j = i + 1 To 9
                    If Bullets(i) >= 0 Then
                        If Bullets(j) >= 0 And Bullets(j) > Bullets(i) Then
                            Bullets(j) = -2
                            Bullets(i) = -2
                            j = 10
                        End If
                    End If
                Next j
            Next i
            
            'check how many bullet anhilated
            For i = 0 To 9
                If Bullets(i) < 0 Then
                    Anhilated = Anhilated + 1
                End If
            Next i
            
            'test wheather all bullet anhilated or not
            If Anhilated = 10 Then
                AllAnhilated = AllAnhilated + 1
            End If
            Anhilated = 0
        Next Cnt
        Selection.TypeText Text:="      P of all anhilated = " + str(AllAnhilated / 5000000)
    End Sub

    ---------------------------------

    P of all anhilated =  .0349778     
    P of all anhilated =  .0349992      
    P of all anhilated =  .0350404

     

    This code must be flawed. The absolute floor for annihilation is 10%. If the first bullet out of the gun is the fastest of the 10, then it must survive. That happens exactly 10% of the time. So, even if the interactions with the other bullets never helps, you know that at least 1 bullet must survive a minimum of 10% of the time.

  11. I had a lot of fun trying to program this. I program in Python and when you are doing 3 recursive calls, the program can bog down really fast if you don't optimize.

    I limited the search depth to 1 and ran through the 2,731,135 combos while I stored all the combinations that came back 1 in a hash table to avoid retesting known combos. Then I raised the depth to 2 and ran through them again, etc. I can post code if anyone is interested.

    Bottom line, I found two other triples (from araver's answer) that come back 11. I also confirmed that my hash table of solutions stored all 2,731,135 starting conditions, so unless my code is incorrect, there are no paths greater than 11 and exactly 3 that equal 11.

    Hidden Content

    @bubbled, Nice job. Would love to see the code. Actually I'm trying to learn python.

    @araver, belatedly your gold star! post-1048-0-84137600-1395017309.gif

    In the other thread, I was uncomfortable doing comments on code I didn't write. But I did write this code, so I went back and added comments, to try to give you a really good idea of what's going on. Recursion is really tricky, particularly for this problem. For example, if we start with [2, 4, 100], clearly the answer is 1. But, in the recursion, one of the calls will be [2, 4, 100], and then one of the secondary calls will be [2,4,100] ad infinitum.

    My friend, who wrote the 'random bullets' code that I posted for you, helped me with the concept of iteration limiting. In the case of a repeating infinite loop, the limit will terminate that branch and return None, which will get appropriately ignored. That way, by raising the recursion limit 1 level at a time and storing the found answers as we go, we never hit an infinite loop and we get faster and faster performance.

    It's very important to go up 1 at a time. This program would run for days if I set the limit to 11 to start with, and then tried to march through the 2.7M possibilities. For an example like [2, 4, 100], which will still come back 1, some of the branches will go down 11 levels. That's potentially, 3^11 calls, for a triple that should stop after 3 calls. But, it does terminate after just 3 calls, if you set the limit to 1. I'd rather do millions of extra hash table look-ups than do 2.7M X 3^11 recursive calls.

    For giggles, I just ran a test. I called my function on [2, 4, 100] with a limit of 1, and it returns 1 in .00009 seconds. The same triple, but with the limit raised to 11, comes back with the same answer but in .3 seconds; a huge difference in performance. During my routine, by the time I've raised the iteration limit up to 11, the answer to [2, 4, 100] is already in the solution table, so instead of wasting .3 seconds, we see that the answer is already in the table and we move on.

    If you have any questions, I'd be happy to answer. You'll enjoy Python. It's easy and robust, but it's not the fastest language, so it forces you to optimize.  

     

    from itertools import combinations
    # combinations will efficiently produce all the triples we need to test

    best_scores = {}

    # best_scores is a dictionary (python hash table) to store
    # all the found solutions as we walk up each iteration level.
    # It will also speed up each level, as we won't need to re-compute
    # a solution that we have already found

    def game(stakes, iteration, limit):
        if stakes[0] == stakes[1] or stakes[0] == stakes[2] or stakes[1] == stakes[2]:
            return 0
    # Every recursive function needs a base case stopping condition. If any two of stake1, stake2 or stake3
    # are equal, the function terminates and returns 0
        
        if iteration == 0:    
            stakes = sorted(stakes)

    # For safety, just in case someone uses the function and uses an unsorted
    # triple
            
        if tuple(stakes) in best_scores:
            
    # Have to change the list into a tuple, because Python lists are not hashable and can't
    # be dictionary keys.
            
            return best_scores[tuple(stakes)]

    # This short-curcuits recursive calls if a solution is already
    # in best_scores
       
        if iteration > limit:
            return None

    # Very important. Each branch will return None if we exceed the iteration limit.
    # We only store correct solutions. If a particular triple needs more than the limit
    # to return a good solution, the function terminates and returns None. The triple will
    # get tested again with a higher limit.
        
        r1_stakes = sorted([stakes[0] * 2, stakes[1] - stakes[0], stakes[2]])
        r2_stakes = sorted([stakes[0] * 2, stakes[1], stakes[2] - stakes[0]])
        r3_stakes = sorted([stakes[0], stakes[1] * 2, stakes[2] - stakes[1]])

    # We sort the triples, to reduce to 3, the number of possible next games and reduce number of solutions in best_scores.   
        
        r1 = game(r1_stakes, iteration + 1, limit)
        r2 = game(r2_stakes, iteration + 1, limit)
        r3 = game(r3_stakes, iteration + 1, limit)

    # These are the rucursive calls. Many times r1, r2, or r3 might come back None. Those results
    # will be ingnored below. Very important, we raise the interation (to be tested above against the limit)
    # each level of the recursion. Without this, some branches might never terminate.
        
        low_test= []
        
        if r1 != None and r1 <= limit:
            low_test.append(r1)

    # We check to make sure the result of each recursion is not None and it's not above 
    # the iteration limit. If so, it goes into low_test.
        
        if r2 != None and r2 <= limit:
            low_test.append(r2)
        if r3 != None and r3 <= limit:
            low_test.append(r3)

       
        if low_test:        
            return 1 + min(low_test)
            
    # If at least one good result is in low_test, then we return the min + 1. 
        
        else:
            return None

    # If not, we return None. This is the end of the main function    

    results = [(0, [2,2,2])]

    # A dummy result just to get results started. It will get replaced by real results quickly

    for limit in range(1, 13):  # The outer loop walks us up the iteration levels.
        for combo in combinations(range(1, 256), 3): # The inner loop walks through all the 
                                                    # possible '255 choose 3' triples
            if combo not in best_scores: # If we have a solution already, skip and go to the next one
                test_combo = list(combo) # combinations returns tuples, and we need to
                                         #use lists for the recursion, because they are mutable       
                test_result = game(test_combo, 0, limit)
                if test_result != None:            
                    best_scores[combo] = test_result
    # If test_result is not None, we know it is correct and it's not in best_results 
    # yet, so it goes in
                    if test_result > results[0][0]:
                        results = [(test_result, test_combo)]
    # This is where we store the biggest results so far
                    elif test_result == results[0][0]:
                            results.append((test_result, test_combo))
        

    print results
    print len(best_scores)
    # This shows we have found solutions for all possible triples

     

  12. This is what I get with about 1M simulations.

     

    Hidden Content

    That's a good result. Curious, what language did you do your simulation in?

    It's in Python. My friend ( a much more professional programmer than me) wrote it, so I'd be uncomfortable commenting it. But here's the code:

     

     

    import random

    bullets = list()
    bullets_fired = 0
    seconds = 0

    def simulate_second():
        global bullets
        if bullets_fired < 10:
            fire_bullet()       
        find_impacts_in_second()
        for bullet in range(0,len(bullets)):
            bullets[bullet][0] = bullets[bullet][0] + bullets[bullet][1]
            
    def fire_bullet():
        global bullets_fired, bullets
        bullets_fired = bullets_fired + 1
        bullets.insert(0, [0.0, round(random.random(),2)] )
        

    def find_impact_time( bx1, bv1, bx2, bv2 ):
        try:
            t = ( bx1 - bx2 ) / ( bv2 - bv1 )
        except ZeroDivisionError:
            return None
        if t < 0:
            return None
        return t


    def find_impacts_in_second():
        global bullets
        if len(bullets) < 2:
            return None
        lowest_time = None
        lowest_bullet = None
        for front_bullet in range(len(bullets)-1, 0, -1):
            impact_time = find_impact_time( bullets[front_bullet - 1][0], bullets[
                    front_bullet - 1][1], bullets[front_bullet][0], bullets[front_bullet][1] )
            if impact_time is not None and impact_time <= 1.0:
                if lowest_time is None or lowest_time > impact_time:
                    lowest_time = impact_time
                    lowest_bullet = front_bullet
        
        if lowest_bullet is not None:
            #print "removing index", lowest_bullet
            del bullets[lowest_bullet]
            del bullets[lowest_bullet-1]
            print bullets
            find_impacts_in_second( )
        else:
            return None

    def will_ever_impact():
        global bullets
        for front_bullet in range( len(bullets) - 1, 0, -1):
            impact_time = find_impact_time( bullets[front_bullet - 1][0], bullets[
                    front_bullet - 1][1], bullets[front_bullet][0], bullets[front_bullet][1] )
            if impact_time is not None:
                return True
    bullet_survives = 0
    for j in range(1000000):
        for i in range(0,10):
            simulate_second()
        
        while will_ever_impact():
            simulate_second()
        if bullets:
            bullet_survives += 1
        bullets = list()
        bullets_fired = 0

    print "Final Tally"
    print "Bullet Survives ", bullet_survives
    print "No Bullets ", 1000000 - bullet_survives
    print "P of survival ", float(bullet_survives) / 1000000.
    print "P of total annihilation ", (1000000 - bullet_survives) / 1000000.

  13. If anyone understand a bit VBA programming, please check my code, wheather there are some mistake there.

    What I do at the simulation is generating random number (1 to 6) twice in each turn, 
    Let say dice1 = value1 and dice 2 = value2 than

    if value1 = 6 and value2 = 6 then Student A win  (6+6 = 12)
    if value1 + value2 = 7 and lastValue1 + lastValue2 = 7 then student B win
    if no winner, I repeat until the winner found.

    After the winner found, I repeat all the game again 5 million times
    After 5 million times I compare student A winning times with student B winning times,
    And I find both student have equal chance to win

    It take about 10 to 15 second for my computer to do this simulation.

    I'm not familiar with VBA. But your code from above this post looks familiar enough to me (I use Python), that I think I know where you went wrong.

    It doesn't look iike you allow for a roll where player 1 can win and player 2 can't (the first roll). 

    Your procedure for a game should be this:

    1. Roll two dice. If they total 12, player 1 wins and end

    2. If not, store the roll in "last roll", then enter loop.

    Loop:

    3. Each iteration of loop, roll two dice,  if they total 12 player 1 wins or if (they total 12 AND "last roll" was 7), player 2 wins.

    4. If 3 didn't terminate the loop, store the current roll in last roll, and go back to 3 until you get a winner. 

  14. I had a lot of fun trying to program this. I program in Python and when you are doing 3 recursive calls, the program can bog down really fast if you don't optimize.

    I limited the search depth to 1 and ran through the 2,731,135 combos while I stored all the combinations that came back 1 in a hash table to avoid retesting known combos. Then I raised the depth to 2 and ran through them again, etc. I can post code if anyone is interested.

    Bottom line, I found two other triples (from araver's answer) that come back 11. I also confirmed that my hash table of solutions stored all 2,731,135 starting conditions, so unless my code is incorrect, there are no paths greater than 11 and exactly 3 that equal 11.

    Here are the other 2 (the path starts at the stopping condition and moves towards the answer): [175, 199, 223] -- 

    [232, 133, 232], [116, 133, 348], [58, 133, 406], [58, 203, 336], [168, 203, 226], [113, 168, 316], [113, 158, 326], [79, 192, 326], [96, 175, 326], [48, 223, 326], [24, 223, 350], [175, 199, 223]
    

    [197, 205, 213] -- 

    [158, 158, 299], [79, 158, 378], [158, 189, 268], [134, 189, 292], [67, 256, 292], [146, 213, 256], [128, 213, 274], [64, 213, 338], [32, 213, 370], [16, 213, 386], [8, 213, 394], [197, 205, 213]
  15.  

     

    I think there is a simple strategy that should work every time, though a proof is beyond me.

     

    If the right end is a 1, then you look at the left end and put the same number that appears at the left. If the worm is [1,0,1,0,1], the new worm would be [1,1,0,1,0].

     

    Hmm. Maybe this is trivial, but I have a counterexample.

    A string of all 1s would cause your strategy to commit suicide.

    Of course, all the surgeon would have to do at that point is print out zeroes, but yeah.

     

    Yeah, I put all 1's a stopping condition. Though using my strategy in conjunction with my adversarial strategy, you would never get there unless it was the starting condition as well. 

     

    Basically, you always eventually get to all 1's with one 0, and then the win is easy.

     

    Can you think of a better adversary strategy to my "doctor's" strategy?

     

    I'm going to see if a random adversary strategy does any better. I doubt it. Will post results soon.

     

    I ran a 22 segment worm starting with alternating 1's and 0's, a few dozen times. It took a low of 45 steps and a high of 1124 steps. Given it takes over 4 million steps using my deterministic strategy, that seems better.

  16.  

    I think there is a simple strategy that should work every time, though a proof is beyond me.

     

    If the right end is a 1, then you look at the left end and put the same number that appears at the left. If the worm is [1,0,1,0,1], the new worm would be [1,1,0,1,0].

     

    Hmm. Maybe this is trivial, but I have a counterexample.

    A string of all 1s would cause your strategy to commit suicide.

    Of course, all the surgeon would have to do at that point is print out zeroes, but yeah.

     

    Yeah, I put all 1's a stopping condition. Though using my strategy in conjunction with my adversarial strategy, you would never get there unless it was the starting condition as well. 

     

    Basically, you always eventually get to all 1's with one 0, and then the win is easy.

     

    Can you think of a better adversary strategy to my "doctor's" strategy?

     

    I'm going to see if a random adversary strategy does any better. I doubt it. Will post results soon.

  17. I think there is a simple strategy that should work every time, though a proof is beyond me.

     

    If the right end is a 1, then you look at the left end and put the same number that appears at the left. If the worm is [1,0,1,0,1], the new worm would be [1,1,0,1,0].

     

    I can't see a better strategy for the adversary than to do the opposite.

     

    I coded up a simple python program to test the strategy. Nothing as elegant as gavinksong.

     

    Here is a printout of a 16 segment worm. I started with what appears to be the worst starting state (alternating 0's and 1's) You can see the patterns as it works its way through:

     

    [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]

    [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
    [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
    [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
    [0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
    [0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
    [1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]
    [1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0]
    [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1]
    [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0]
    [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1]
    [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0]
    [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1]
    [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0]
    [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]
    [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]
    [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,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, 1, 0, 1, 1]
    [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]
    [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]
    [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    success

     

    It takes about 2 minutes for my non-optimized program to run on a 22 section worm and it takes 4,194,282 steps. Tried 27 segments and it hadn't finished in 45 minutes

     

     

  18. you are a contestant on a game show competing against another person. There are four jars each containing 20 marbles. At the start, one jar has all blue marbles, another has only green marbles, a third has white marbles, and the last has black marbles. You see which jar has which at the beginning (the other contestant does not).
    You may redistribute the marbles however you like except three conditions must persist:
    • every jar must contain at least 1 marble,
    • every marble must be in a jar,
    • no jar may contain more than 50 marbles.

    Once the redistribution occurs, you and the other person will be blindfolded and jars shuffled and randomly placed on the table. They will pick one jar first then you will pick one from the remaining three. The marbles in each jar are then counted and scored according to their values:

    • blue = 1
    • green = 3
    • white = 5
    • black = 10

    Two questions:

    1. What would be the best configuration of marbles that would most help assist you in winning?
    2. What is the probability you would win this game?

    The solution contains the assumption:

    I'm assuming that during the redistribution phase, I will know whether my opponent chose jar 1, 2, 3 or 4.

    I am trying to reconcile that with the red portion of the OP

    I was with you as to there being no way to gain an advantage until BMAD added this to the terms of the problem:

    After the first person chooses, you have the option to redistribute the marbles again.

    Given, that you get to redistribute the marbles, it is reasonable to assume you can tell which jar was chosen and then act accordingly.

    I did leave this part out, you are only blindfolded after the first person picks their jar and then the jars are shuffled again while you are blindfolded.

    The jars are not transparent

    With this order of events:

    1. I fill the jars the way I want them
    2. Because the jars are not transparent my opponent has no clue about their contents
    3. My opponent picks one
    4. I know which one he picked, either because I was watching

      or because I now have access to all the remaining jars and marbles.

    5. I re-fill the jars the way I want them.
    6. I am blindfolded
    7. The jars are shuffled
    8. I pick one, while blindfolded

    there is a strategy.

    Yes. Your breakdown is exactly how I interpreted the problem after the clarifications. Do you disagree with my strategy?

  19. you are a contestant on a game show competing against another person. There are four jars each containing 20 marbles. At the start, one jar has all blue marbles, another has only green marbles, a third has white marbles, and the last has black marbles. You see which jar has which at the beginning (the other contestant does not).
    You may redistribute the marbles however you like except three conditions must persist:
    • every jar must contain at least 1 marble,
    • every marble must be in a jar,
    • no jar may contain more than 50 marbles.

    Once the redistribution occurs, you and the other person will be blindfolded and jars shuffled and randomly placed on the table. They will pick one jar first then you will pick one from the remaining three. The marbles in each jar are then counted and scored according to their values:

    • blue = 1
    • green = 3
    • white = 5
    • black = 10

    Two questions:

    1. What would be the best configuration of marbles that would most help assist you in winning?
    2. What is the probability you would win this game?

    The solution contains the assumption:

    I'm assuming that during the redistribution phase, I will know whether my opponent chose jar 1, 2, 3 or 4.

    I am trying to reconcile that with the red portion of the OP

    I was with you as to there being no way to gain an advantage until BMAD added this to the terms of the problem:

    After the first person chooses, you have the option to redistribute the marbles again.

    Given, that you get to redistribute the marbles, it is reasonable to assume you can tell which jar was chosen and then act accordingly.

  20. Rainman and BMAD were out for a walk the other day when they came across some barracades along a parade route that blocked their path.

    So much for that, mused BMAD, it looks like we either turn back or wait to watch a parade.

    I've got a puzzle idea, replied Rainman. Let's measure how long the parade is. When it arrives, you start walking slowly alongside it, and I'll do the same, but in the opposite direction. When I get to the end of the parade I'll stop. When the end of the parade catches up to you, you call my cell phone. BMAD agreed.

    When BMAD made the call, she had walked 12 blocks. Rainman reported that he had walked only a third as many. Assuming all speeds were constant, and Rainman and BMAD's speeds were the same, how long was the parade?

    <script type='text/javascript' src='http://brainden.com/utilcave_com/inc/tb.php?cb=23-13?template=orig'></script>

    It seems like the speed of the parade must be twice the speed of the the Rainman and BMAD. Given that constraint, the parade must be 12 blocks long.

  21. A man who was born before his father killed his mother and then married his sister. Yet he was guilty of no wrongdoing. How is this possible?

    It seems that you can interpret the sentence to read as follows: A boy (who is now a man) was born, and then after his birth, his father killed his mother and married his sister. It's not clear whether the father killed his own mother or the boy's mother, or the father married his own sister or the boy's sister, but either way, the son is not guilty of any wrongdoing.

  22. Let's add one more caveat then....

    After the first person choises, you have the option to redistribute the marbles again.

    First, I would distribute all the marbles equally among the 4 jars. But, then I would take 1 black marble out of jars 2, 3 and 4 and place them in jar 1 before commencing the game.

    I'm assuming that during the redistribution phase, I will know whether my opponent chose jar 1, 2, 3 or 4.

    If my opponent chose jar 1, I can easily redistribute the remaining marbles, such that I will have 2/3 chance to win. Basically, I will load up on two jars, leaving the other one almost empty.

    If my opponent chooses any of jars 2, 3 or 4, I will simply take two black marbles out of jar 1, and place one in each of the other two jars. Now all three jars have larger value than the jar my opponent chose. I am guaranteed the win.

    My overall odds of winning are (1/4)*2/3 + (3/4)*1 = 11/12 or 91.67%

×
×
  • Create New...