Free2Code
 
Time: 2008-12-04, 10:03pm
Problem Solving 2
Subject: Problem Solving 2  ·  Posted: 2004-05-30, 05:58am
Rank: ? (1200)
Member #: 12930

ABCD * 4 = DCBA

Find the numbers:
A
B
C
D
. Is there a a general rule for that? What do you do with :

ABCDE * 4 = EDCBA

?

So... How is life?
 
  Reply to this ·  Post link ·  Top
Subject: Re: Problem Solving 2  ·  Posted: 2004-06-03, 03:21pm
Rank: ? (4)
Member #: 15695
are any of the numbers the same or are they all different?

Aaron D Francis
 
  Reply to this ·  Post link ·  Top
Subject: Re: Problem Solving 2  ·  Posted: 2004-06-03, 04:43pm
Rank: ? (1200)
Member #: 12930
All different

So... How is life?
 
  Reply to this ·  Post link ·  Top
Subject: Re: Problem Solving 2  ·  Posted: 2004-06-03, 06:03pm
Rank: Unregistered
A 2
B 1
C 7
D 8

 
  Reply to this ·  Post link ·  Top
Subject: Re: Problem Solving 2  ·  Posted: 2004-06-03, 06:04pm
Rank: ? (4)
Member #: 15695
that was me, not used to this new forum and wasnt logged in

Aaron D Francis
 
  Reply to this ·  Post link ·  Top
Subject: Re: Problem Solving 2  ·  Posted: 2004-06-04, 09:32pm
Rank: ? (21)
Member #: 4335
ABCDE * 4 = EDCBA => A=2, B=1, C=9, D=7, E=8;

It does seem to form a pattern--the outter numbers seem to stay the same but you have to figure out the one number inside. Anyways, there are two ways to figure this out:

1. Since A * 4 = E, it means that A = 1 or 2; but since E * 4 mod 10 = A, A has to be an even number, so A is 2. E is either 8 or 9 because of 2 * 4 + whatever comes from B * 4, but since only 8 * 4 can result in a 2 in the unit digit, E = 8. B * 4 < 10 because the next digit is 2 * 4 = 8, which means that B is also 1 or 2, and since (D * 4 + 3) mod 10 = B, B has to be an odd number, so B = 1. D * 4 + 3 = 10 * (something) + 1 => D = 2 or 7; 1 * 4 + whatever from C * 4 = D => D > 4 and thus D = 7. So 7 * 4 + 3 = 31, which means that C * 4 + 3 = (7 - 1 * 4) * 10 + C, solve the equation and C = 9.

2. We are on a programming forum more or less... so here comes the rather easy (& cheesy) way.
Code:
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int a = 0, b = 0, c = 0, d = 0, e = 0;
  5.     for (a = 0; a < 10; a++)
  6.         for (b = 0; b < 10; b++)
  7.             for (c = 0; c < 10; c++)
  8.                 for (d = 0; d < 10; d++)
  9.                     for (e = 0; e < 10; e++)
  10.                         if ((10000 * a + 1000 * b + 100 * c + 10 * d + e) * 4 ==
  11.                             (10000 * e + 1000 * d + 100 * c + 10 * b + a))
  12.                             printf("%i, %i, %i, %i, %i", a, b, c, d, e);
  13.     return 0;
  14. }


 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons