Problems

here I will put different little exercices I find.

6th grade problem:
find all integral numbers which after substraction to 9999 give the same number without the last digit. for example:
abcde - 9999 = abcd
damn, it must be easy

Comments

  1. solution:

    let the number be like this:
    xn..x2x1x0y
    where xn .. x2, x1, x0 are the number digits

    Sum (xi * 10^i) + 9999 = Sum (xi * 10^(i+1)) + y, where i = 0..n

    this gives:

    9 * Sum(xi * 10^i) + y = 9999

    now, y can be 0,1,2, .. 9
    which means that

    Sum(xi * 10^i) = 9999 / 9, 9998 / 9, 9997 / 9, ... 9990 / 9

    but Sum must be integer since xi is integer also, hence

    999z / 9, z = 0..9 must be integral

    so we need to check all 9 ratios

    ReplyDelete
  2. actually its simpler(aratare!) if u divide
    9 * Sum(xi * 10^i) + y = 9999
    by 9

    and u get
    Sum(xi * 10^i) + y/9 = 1111

    y can be 0 or 9 ;)

    ReplyDelete
  3. Problem #2:

    The bridge
    Three people (A, B, and C) need to cross a bridge. A can cross the bridge in 10 minutes, B can cross in 5 minutes, and C can cross in 2 minutes. There is also a bicycle available and any person can cross the bridge in 1 minute with the bicycle. What is the shortest time that all men can get across the bridge? Each man travels at their own constant rate.
    I didn't solve this problem.

    Hint: if you know that d = v * t then everything is easy :|

    ReplyDelete
  4. Solution to problem #2
    ----------------------

    The bicycle can be left at any place on the bridge and can be used in both directions on the bridge.

    The steps are:
    B and C walk by foot and A take the bicycle.
    A at one place (y) can leave the bicycle and finish the way by foot.
    C can take the bicycle, drives it back to a point (x), leaves it and continues to walk by foot.
    B takes the bicycle and drives it all the way.

    The equations are:
    A: 1*y + 10*(1-y)
    B: 5*x + 1*(1-x)
    C: 2*y + (y-x) + 2*(1-x)
    The system becomes:
    10 - 9y = -3x + 3y + 2 = 4x + 1
    Solve each equality:
    10 - 9y = -3x + 3y + 2 -> 3x - 12y = -8
    10 - 9y = 4x + 1 -> 4x + 9y = 9

    After solving the equations:
    x = 12/25, y=59/75.

    It meas that it takes 73/25 = 2.92 minutes to cross the bridge.

    A speed = 1/10
    B speed = 1/5
    C speed = 1/2
    (bicycle speed is 1)

    ReplyDelete
  5. Problem #3:

    You have 2 buckets with water, 7 and 4 litre.

    How can you measure 1 litre using these buckets ?

    ReplyDelete
  6. Solution to problem #3
    ----------------------

    Fill the 4 litre bucket then fill the 7 litre bucket with it completely.
    Now you have 3 litre left in the 7 litre bucket.

    Again, fill the 4 litre bucket and fill the remaining 3 litre from the 7 litre bucket.
    What you have left in the 4 litre bucket is 1 litre.

    ReplyDelete
  7. problem #4:

    exchange 2 variables without using any intermediate value.

    ReplyDelete

Post a Comment

Say something nice please.

Thank you.

Popular posts from this blog

IconFont2Code, my open-source tool in order to view icons in font files and create C# class with the glyph constants

Xamarin.Forms XmlnsDefinition attribute: All of your namespaces become one