Logic problem?

This is a discussion on Logic problem? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I was wondering I any of you could help me with these two problems. 1. A contractor estimated that one ...

  1. #1
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765

    Question Logic problem?

    I was wondering I any of you could help me with these two problems.

    1.
    A contractor estimated that one of his two bricklayers would take 9 hours to build a certain wall and the other 10 hours. When the two bricklayers worked together, however, 10 fewer bricks got laid per hour. With both men working on the job it took exactly 5 hours to build the wall. How many bricks did it contain?

    I think this one doesn't have an answer. It's impossible to calculate.

    2.
    You have a can with four balls of different colors. Randomly you draw two at a time, then paint the first ball to match the second. What is the expected number of drawings before all balls are the same color?

    This one...I don't know

  2. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    This sounds like homework. I'll set up the equations for you for the first one.
    Code:
    Let 1 wall = n bricks
    1st guy's rate:
       R1 = 1 wall / 9 hours = n bricks / 9 hours
    2nd guy's rate:
       R2 = 1 wall / 10 hours = n bricks / 10 hours
    So they built a wall in 5 hours together with a combined rate of 10 fewer bricks/hour
       1 wall = n bricks = (R1 + R2 - 10) * 5 hours
    Okay you solve it:
    btw, the answer is 900 bricks.

    For the 2nd problem, just draw out the probability chart and add them up.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  3. #3
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    The thing about n0. 2 is that I don't actually understand it.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    For the second question, assuming, (you don't say), that after painting the ball you place both back in the can, the answer is based in probablility and has no fixed answer. Consider, if you are drawing randomly, you might always pick the same two balls, therefore they would never all be the same. (Although presumably in that case, the accumulated layers of paint would eventually make the balls too big to go back in the can).
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    Ha-Ha!!! that's quite true Thanx for the help

  6. #6
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    Originally posted by adrianxw
    For the second question, assuming, (you don't say), that after painting the ball you place both back in the can, the answer is based in probablility and has no fixed answer. Consider, if you are drawing randomly, you might always pick the same two balls, therefore they would never all be the same. (Although presumably in that case, the accumulated layers of paint would eventually make the balls too big to go back in the can).


    Umm, I think you should go with c-shot's answer.


    Probability is the key-Probability says you will NOT always pick the two same balls.

    4 balls, pick 2 out, paint them............its not that difficult to work the rest out.


    There is a correct answer. (thank god i did probability in UNI last year)
    Such is life.

  7. #7
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Lemme demonstrate it for the 3 ball case.

    Code:
    3 balls of different colors initially.
    
    After:
    1 draw:
    2 same color, 1 different color
    Probability = 1/1
    3 same color
    Probability = 0/1
    
    2 draws:
    2 same color, 1 different color
    Probability = 2/3
    3 same color
    Probability = 1/3
    
    3 draws:
    2 same color, 1 different color
    Probability = 2/3
    3 same color
    Probability = 1/3
    .
    .
    .
    n draws:
    2 same color, 1 different color
    Probability = 2/3
    3 same color
    Probability = 1/3
    Simply add them all up and you get the expected number of draws to get all 3 balls the same color.

    # draws = 1 draw * prob of 0 + 2 draws * prob of 1/3 + 3 draws * prob of 2/3 * prob 1/3 + ...

    # draws = 1*0 + 2*1/3 + 3*2/3*1/3 + 4*(2/3)^2*1/3 + ... + n*(2/3)^(n-2)*1/3

    You get the idea. You do know how to add this up don't you
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  8. #8
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    As I said...

    >>> the answer is based in probablility and has no fixed answer.

    ... and this holds true, it is inprobable, but possible...

    >>> you might always pick the same two balls,

    ... therefore I would state again that there is no fixed answer to this problem, only a probability distribution.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  9. #9
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    As I said...

    >>> the answer is based in probablility and has no fixed answer.

    ... and this holds true, it is inprobable, but possible...

    >>> you might always pick the same two balls,

    ... therefore I would state again that there is no fixed answer to this problem, only a probability distribution.
    Wrong!

    Add up the equation above and it'll converge to a number.

    Perhaps you will be able to see this with a simpler example. If a person flips a coin, what is the expected number of flips he must make in order to get heads?(assuming it's not a trick coin )

    The answer is 2! It is true he may flip tails forever until the day he dies. But you can always solve for the expected number in cases like this. Here's how.

    The odds he will do it in 1 flip is:
    1/2 * 1 = (1/2)^1 * 1
    (50% chance of getting heads in 1 flip)

    The odds he will do it in 2 flips is:
    1/2 * 1/2 * 2 = 1/4 * 2 = (1/2)^2 * 2
    (50% of getting tails in 1st flip, 50% chance of getting heads in 2nd flip = 25% chance he'll get heads on the 2nd flip and not the first)

    The equation will come out to be:
    Expected Number of flips =
    1/2*1 + 1/4*2 + 1/8*3 + ... + (1/2)^n * n

    as n->infinity the equation will converge to 2. Trust me, I'm right on this. Punch it in your calculator if you must.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  10. #10
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>>
    If a person flips a coin, what is the expected number of flips he must make in order to get heads?
    <<<

    The "expected" ... hmmm, as I was saying, a probability exercise. Try the real experiment, tell me if every time you flip a coin twice that you get at least one head.

    >>>
    It is true he may flip tails forever until the day he dies. But you can always solve for the expected number in cases like this.
    <<<

    Errm, yes, as I said, the answer is a probability. I do not believe we are disagreeing. The thought experiment as proposed by the author will, if repeated enough times, tend to an average value, (there will be a probability distribution with a mean), however, any discreet "run" of the experiment could have a wide range of values, and as such, there is no "fixed" answer to the question as posed. (Indeed - as posed, he does not say he will put the balls back in the can after painting them, if he does not, then after the first draw, there are two different coloured balls in the can one gets painted, there are now no balls in the can and two pairs of differently coloured balls outside).

    I'm being a bit picky because a favourite "cheat" of lecturers is to pose a seemingly simple question and watch as all the students get the answer wrong because they have not interpretted the question correctly and assumed more than they should - Stats classes abound with this.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  11. #11
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    I'm not saying that if he flips a coin twice he will get one head. I agree with what you're saying but the expected number can be calculated. It's a terminology used often in probability. Perhaps it is different in your country.

    Just like the probability of getting heads is 50%, the expected number also has a value. Whether it happens in experiment, is irrelevant. Notice the term "expected". It's not the same as asking a question like: "Will Paul get one head if he flips the coin twice?"

    >> Indeed - as posed, he does not say he will put the balls back in the can after painting them,
    Yea I noticed this too. But I'm taking that biosninja wouldn't like my answer if I assumed that.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  12. #12
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    Originally posted by adrianxw
    As I said...

    >>> the answer is based in probablility and has no fixed answer.

    ... and this holds true, it is inprobable, but possible...

    >>> you might always pick the same two balls,

    ... therefore I would state again that there is no fixed answer to this problem, only a probability distribution.


    Errm yes, I think you are agreeing-just. It is the wording used I think. In the context of the question there IS a 'fixed' answer-ie statistically.

    Not in the 'real world' though. Then there would be NO fixed answer.

    Just draw up a probability tree or something, you will get your fixed answer.
    Such is life.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Logic
    By LordBronz in forum C++ Programming
    Replies: 6
    Last Post: 05-23-2006, 05:41 PM
  2. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  3. Replies: 5
    Last Post: 11-07-2005, 10:34 PM
  4. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  5. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21