Jump to content
BrainDen.com - Brain Teasers

bubbled

Members
  • Posts

    93
  • Joined

  • Last visited

  • Days Won

    2

Everything 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 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 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. 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 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. Well done. The amazing thing is I've NEVER seen an NFL coach do this! These teams are worth billions and each win must be worth millions to them, but they can't make a simple decision that might get them an extra win every few years.
  5. 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.
  6. 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.
  7. 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.
  8. 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/
  9. 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.
  10. 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:
  11. 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.
  12. @bubbled, Nice job. Would love to see the code. Actually I'm trying to learn python. @araver, belatedly your gold star! 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.
  13. 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:
  14. 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.
  15. This is what I get with about 1M simulations.
  16. 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.
  17. Hmm. Maybe this is trivial, but I have a counterexample. 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.
  18. Hmm. Maybe this is trivial, but I have a counterexample. 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.
  19. I think there is a simple strategy that should work every time, though a proof is beyond me. 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: 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
  20. 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. With this order of events: I fill the jars the way I want them Because the jars are not transparent my opponent has no clue about their contents My opponent picks one I know which one he picked, either because I was watching or because I now have access to all the remaining jars and marbles. I re-fill the jars the way I want them. I am blindfolded The jars are shuffled 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?
  21. 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.
  22. <script type='text/javascript' src='http://brainden.com/utilcave_com/inc/tb.php?cb=23-13?template=orig'></script>
×
×
  • Create New...