Jump to content
BrainDen.com - Brain Teasers

EventHorizon

VIP
  • Posts

    578
  • Joined

  • Last visited

  • Days Won

    8

Posts posted by EventHorizon

  1. I had thought a while about trying to figure out how adding more towers would affect the number of steps needed.

    It turned out to be an interesting answer (I love it when answers involve Pascal's triangle (represented in the answer by nCr))....though I don't know why it is as it is......yet.

    I wrote some c++ code that given the number of towers and disks it would do breadth first search to find the least number of moves to move all the disks from one tower to another. It reports the number of steps and gives the sequence of states/moves.

    I altered it later to just go halfway (till the biggest disk is moved) since the rest is fairly obvious.

    I included some code.....just no comments on how bad/cryptic/not fault tolerant/not robust it is ;)

    I included some text files that shows the output I looked at to come up with my solution. I basically ran the code till it would crash because of integer overflow/out of memory and included the results. I may rewrite it by taking a different approach to allow larger numbers for the amount of towers and disks....later.

    In the text files the state is listed as position of the disks going from smallest to biggest...

    so it starts at 0 0 0 0 0 for 5 disks....which mean all disks are on tower 0.

    The second state may be 1 0 0 0 0....which means all the disks but the smallest are on tower 0, and the smallest is on tower 1.

    hanoi.zip

    first, nCr(x,y) = x!/((x-y)!y!), which is the number of combinations of pool of x objects taken y at a time.

    So here is a method to determine how many steps it will take to move d (>0) disks where there are t (>2) towers. Sorry for not being more clear.....but this isn't all that simple.

    Step 1 - dcount = 0;

    Step 2 - steps = 1;

    Step 3 - increment = 2;

    Step 4 - group = 1;

    Step 5 - tochange = nCr(t-2+group,group);

    Step 6 - dcount = dcount + 1;

    //If (dcount == d) You are done....steps holds the number of steps needed!

    Step 7 - steps = steps + increment;

    Step 8 - tochange = tochange - 1;

    Step 9 - If (tochange != 0) go to Step 6;

    Step 10- increment = increment * 2;

    Step 11- group = group + 1;

    Step 12- tochange = nCr(t-2+group, group);

    Step 13- go to Step 6

    So the increment is always a power of 2. You add the increment a number of times based on pascal's triangle to the total, and then double the increment.

    Notice that for 3 towers that nCr always results in 1....so the increment is always doubled. Also notice that for 4 towers that nCr increases by 1 each time.

    Here's a quick run through for 4 towers

    disks,steps,increment to next

    1,1,2

    2,3,2

    3,5,4

    4,9,4

    5,13,4

    6,17,8

    7,25,8

    8,33,8

    9,41,8

    10,49,16

    11,65,16

    12,81,16

    13,97,16

    14,113,16

    ...

    Hopefully that made some sense.......any comments? Errors?

  2. Assume that 1% of the members of a particular sports league use a particular proscribed drug. It is decided to test all of the members of the league to find these villains out. The test used has a only a 1% chance of failing to identify an actual drug user and also has only a 1% chance of misidentifying a non-drug user as a drug user. Tom tests positive -- what are the chances that, despite the results of this highly accurate drug test, he is innocent.

    Lets see how rusty my Bayesian reasoning is....

    1% of the population takes the drug

    P(!drug) = .99

    P(drug) = .01

    1% error on tests

    P(+|drug) = .99

    P(-|drug) = .01

    P(+|!drug) = .01

    P(-|!drug) = .99

    P(!drug|+) = P(+|!drug)P(!drug)/P(+)

    = P(+|!drug)P(!drug) / ( P(+|!drug)P(!drug) + P(+|drug)P(drug) )

    = .01 * .99 / ( .01*.99 + .99*.01 )

    = .5

    So there is a 50% chance that tom is doping given that his test came out positive.

  3. did anyone use math to solve this one? i mean break down the stuff. I came up with this

    x^4 - x^2 - 31x - 116

    however my math is a bit old so i could not figure out how to solve for x. but 4 seems to satisfy my equation.

    you could use the quartic formula (not recommended), or just plot it on a calculator and then use synthetic division to remove roots that you find.

    According to brhan's post (first on page 3) your equation is right.

  4. Exactly :P

    oh and I was wrong about my formula. It's obviously not

    2x+2y+2z-8 when you think about it for a second. It's all 6 faces, minus the shared strips

    so that's

    2xy+2yz + 2xz - shared strips

    one sec on the shared strips ;D

    Expand (x-2)(y-2)(z-2) (the unshaded cubes) and subtract it from x*y*z (total).

    Thats the way I started the 2d one.

  5. hi, im new. allow me to ask the dumb questions for a while

    Certainly. I'm fairly new to this site too, but like to explain things to people.

    There are no dumb questions so long as you learn from them.

  6. Why can we not use rectangles with a width of 1? there is an infinite amount of answers this way .. (1x2,1x3....1x4761) did i miss something?

    Lets say the rectangle is 1Xx. Then there are x total squares, and all of which are shaded (all on the border). There are no unshaded squares. Therefore the number of shaded squares are not equal to the number of unshaded squares.

    So rectangles of this sort will not work.

  7. DrHim,

    That would make the soldier to return to his original position. But the soldier's new location is different (actually 50m away) from his original one.

    He would need to go 50 + x backwards to reach his original position.

    50-x would be the distance the soldier would need to go _forward_ after delivering the letter to be where the leading soldier will be once the platoon moved 50m.

  8. It would still be 100m. 50 + x (where x is the distance the platoon moved while he was running to the front) and 50 - x as he returned to the back of the platoon. As long as his speed is constant both ways and the platoon speed is constant he will save as much distance returning as he had to go extra to get to the front. :D

    To get to where he will need to eventually be, he would need to move 50m.

    From there, he needs to move x more to reach the leader.

    He then needs to move x back....not 50-x.... to get back into position.

  9. There is a 50m long army platoon marching ahead. The last person in the platoon wants to give a letter to the first person leading the platoon. So while the platoon is marching he runs ahead, reaches the first person and hands over the letter to him and without stopping he runs and comes back to his original position. In the mean time the whole platoon has moved ahead by 50m. The question is how much distance did the last person cover during that time?

    You may assume that he ran the whole distance with uniform speed, and of course the platoon were marching at a uniform speed.

    let x be the distance covered by the first person in the platoon until the time the letter is given to him.

    The last person (the one with the letter) needs to cover 50+x while the first needs to cover x.

    Over the total time it takes to get back into position, the last person covers 2x+50 while the first covers 50.

    The ratios of these need to be equal since their speeds are constant.

    Cross multiplying results in 2x^2+50x = 50x + 2500.

    2x^2 = 2500

    x^2 = 1250

    x = 25 * sqrt(2)

    So the total distance the soldier covers is 2x+50 = 50 * sqrt(2) + 50.

    This is approximately 120.71m

  10. yes, but I was simply finding the values could be substituted for the width and length to fulfill the "number of shaded squares equals the number of squares in the center." 0X0 can be argued not to be a rectangle, but it is still a degenerate case of a rectangle. So I guess I should have said "degenerate case" instead of "trivial answer." I still believe it could/should be included.

    Too bad my edit time expired...so here's a new post. Any degenerate case of a rectangle (either dimension is 0) will work.

    So....how about in 3 dimensions....where each border cube is "shaded"?

  11. Here's another riddle, I just thought this one up:

    3.

    In base x, a number is 10101. The same number is 273 in base x+6

    What is x? (ie, the base of the first number)

    x=4

    273 (decimal) in base 4 is 10101

    the difference in bases between base 4 and decimal is 6.

    edited to remove any confusion with bases

  12. EventHorizon, 0x0 wouldnt be a rectangle ;D it would be a single point. Like how 1x0 rectangle is actually a line.

    A 0x3x3 rectangular prism isnt actually a 3d rectangular prism as one of its dimensions is 0- it's a 2-dimensional object, as geometry goes. If a dimension is 0 then it's not counted as a dimension in geometry- it has to have some value to extend the axis in that direction. We don't say that a square has 5 dimensions if its 0x0x0x2x2, know what i mean?

    yes, but I was simply finding the values could be substituted for the width and length to fulfill the "number of shaded squares equals the number of squares in the center." 0X0 can be argued not to be a rectangle, but it is still a degenerate case of a rectangle. So I guess I should have said "degenerate case" instead of "trivial answer." I still believe it could/should be included.

  13. It would appear that you used the Pythagorean theorem to solve for the lengths of the sides. That only works for right triangles.

    They are right triangles. I guess I should have posted a picture too....I thought aatif's would be sufficient.

  14. since the animals need to be able to be split into 5 groups or 8 equal groups, the number of animals needs to be a multiple of 40.

    If there are 40 animals, there would need to be 13 2/3 cows to get 285 bucks.....nope.

    If there are 80 animals, there would need to be 8 1/3 cows to get 285 bucks.....still not a whole number.

    If there are 120 animals, there would need to be 3 cows. It worked!

    If there are 160 animals, there would need to be -2 1/3. Hmm . ..negative cows.

    So there must be 120 total animals, 3 of which are cows. the other 117 are pigs and sheep but there isn't enough information (since their cost is the same) to determine the exact amounts of those.

  15. perimeter = 12 * sqrt(41)

    I first set one side of the field to the length of the other side of the field

    x + y = a + b

    then put everything in terms of x

    x + sqrt(x^2 + 17^2 - 20^2) = sqrt(20^2 - x^2) + sqrt(13^2 - x^2)

    after (a whole lot of) simplification this becomes

    0 = 3649x^4 - 979600x^2 + 64000000

    Solving for x results in...

    x = sqrt(6400/41)

    One side length then equals

    sqrt(13^2 - (6400/41)) + sqrt(20^2 - (6400/41))

    = 23/sqrt(41) + 100/sqrt(41) = 123/sqrt(41) = 3*sqrt(41)

    Multiplying by four gives 12 * sqrt(41).

  16. You are going to be off by one card because the last card goes to the dealer. But that's the solution deal from the bottom, starting at dealer going counter-clockwise.

    Ahh....I didn't think the dealer was another player.

  17. Though it's always possible that this is not the solution you are thinking of, this is one way I've seen it done.

    The position pointed to on the first magazine suggested is indicative of the right one.

    If it is pointed to in the center, then the center one is right. If pointing to the bottom center of the magazine, then the bottom center one is correct. If pointed to in the top right corner, then the magazine in the top right is the one. etc.

  18. The puzzle went something like ....

    "Queen XXXXXX (can't remember her name) of atlantis said that at least one man was cheating on his wife in atlantis. It was common knowledge that all wives know about whether or not other men were faithful, but not about their husband. She said that once you know your husband cheats, then shoot him at midnight. After 49 nights of silence, gunshots were heard. How many men were cheating? What was Queen XXXXXX's great accomplishment?"

    Obviously not verbatim, but that's the gist of it.

    As for your follow-up...

    Since no one got off on the fifth stop, everyone "knows" there are at least 6 people with soot on their faces. At the sixth stop, everyone with clean faces will get off and wash their faces because they see 5 dirty faces and know there is a sixth (, and the ones with dirty faces will be confused/daydreaming?)

    Though the commotion would probably make them all think that someone wasn't paying attention to their logic.

×
×
  • Create New...