You are not logged in.

- Topics: Active | Unanswered

Pages: **1**

**soorejmg****Member**- Registered: 2006-01-20
- Posts: 24

U have two numbers ..u must find a method to find a third number from this two numbers such that afterwards only the 3rd number is provided u should get back the first two number..One more thing to easy the work...the two numbers is in limit 0 to 255 .CAN ANY ONE?????

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,654

C = A + B×256

To get A and B from C:

B = int(C/256) ...note: int() means take only the integer, or whole number, part

A = C - B×256

Try it:

A=52, B=2

C = A + B*256 = 50 + 2×256 = 564

C = 564

B = int(564/256) = int(2.203125) = 2

A = C - B×256 = 564-2×256 = 564-512 = 52

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**soorejmg****Member**- Registered: 2006-01-20
- Posts: 24

HI..It was nice...But would u mind me putting one more constrain??

The NEW NUMBER FORMED C SHOULD NOT BE GREATER THAN 255.CAN U?

TRY IT.Best of LUCK...

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,654

Not if they must be whole numbers (I assumed whole numbers by the nature of your question).

If C can be a real number, but A and B are whole numbers:

C = A/256 + B

B = int(c)

A = (C-B)×256

Offline

**soorejmg****Member**- Registered: 2006-01-20
- Posts: 24

NOOOOOOOOOOOOOOOOOOOOOOOOOOOOO...............The C being real number is not atall acceptable..U CAN DO ANY OPERATION LIKE IN BINARY OPERATIOBS AND CONVERTION ALL>..Can any one.....Its very challenging...

Offline

**mathsyperson****Moderator**- Registered: 2005-06-22
- Posts: 4,900

I would say that with those conditions, it's impossible.

There would be 65536 different combinations for A and B (Yay for having powers of 2 committed to memory!), but only 256 different possibilities for C.

There's probably some trick that I'm missing though.

Why did the vector cross the road?

It wanted to be normal.

Offline

**soorejmg****Member**- Registered: 2006-01-20
- Posts: 24

MathdIsFun .....are u getting any idea about it/????

Offline

**soorejmg****Member**- Registered: 2006-01-20
- Posts: 24

Dnt u have any idea like in puzzles some tricks are there to find out number by special operations all....any idea like that in this case?

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,654

If there are only 256 values for C, then you can only reconstruct 256 cases. If A and B can have 256 independent values each, then there are 65536 cases (as mathsy said) and I so it cannot be done.

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,654

Also discussed here

Offline

**irspow****Member**- Registered: 2005-11-24
- Posts: 457

Poor MathsIsFun has to go running around stitching together cross-forum forays by posting links to far flung fragments of desperation.

I, for one, applaud your tenacity.

Offline

**Ricky****Moderator**- Registered: 2005-12-04
- Posts: 3,791

C = A + B×256

Nicely done. I'm assuming you, MathsIsFun, know why this works, but for an explanation on why it works, all you need to know is bit shifting. Bit shifting is the way all multiplication works. If you shift all the bits in a number:

01000100

10001000

By one place, you multiply it by 2. If you do so by 2, you multiply it by 4. 3, 8. 4, 16. And so on. There are 8 bits in a char (which is [0, 255]) and 2^8 = 256. So multiplying it by 256 shifts it 8 bits. So for example:

00000000 01000100 (space is there just for readability)

Becomes:

01000100 00000000

Adding another 8 bit (again, [0, 255]) value:

01000100 00000000

+00000000 01100100

-------------------------

01000100 01100100

And thus, it is just like putting each number side by side.

Dnt u have any idea like in puzzles some tricks are there to find out number by special operations all....any idea like that in this case?

I can prove through the use of the pigeon hole principle, that it is not possible if the function must be onto (valid for every value of C). Once you prove something impossible, there are no such tricks.

"In the real world, this would be a problem. But in mathematics, we can just define a place where this problem doesn't exist. So we'll go ahead and do that now..."

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,654

irspow wrote:

Poor MathsIsFun has to go running around stitching together cross-forum forays by posting links to far flung fragments of desperation.

I may have created a loop!

Offline

**soorejmg****Member**- Registered: 2006-01-20
- Posts: 24

Ricky wrote:

C = A + B×256

I can prove through the use of the pigeon hole principle, that it is not possible if the function must be onto (valid for every value of C). Once you prove something impossible, there are no such tricks.

please proove it

Offline

Pages: **1**