Jump to content

A-B=C


fredreload

Recommended Posts

Alright, so I think I solved this algorithm, I call it the shrink ray, I got the idea from Minions. Pretty much with any number of A-B in binary, you can reverse engineer A and B from C alone knowing how many 1's and 0's there are for A and B.

 

For example:

 

1010 A (two 1's, two 0's)

-0101 B (two 1's, two 0's)

--------

0101 C

 

Note: I've only tested the condition for A>B, not negative numbers

Now you reverse engineer A and B from C, you know C is 5 and A and B are bigger, so you can have A=6 B=1, A=7 B=2, A=8 B=3, A=9 B=4, A=10 B=5, A=11 B=6, A=12 B=7, A=13 B=8, A=14 B=9, A=15, B=10. Now with all these conditions available, the only set that holds true with A having two 1's and B having two 1's are A=10 and B=5. So that's the solution. I think you can reverse engineer any A and B with C and the bits information on A and B.

 

If A and B are 32 bits each, it only takes 6 bits each to store the bit information since the largest possible sum is 32, so I think it's pretty good in terms of shrinking the size down, check the math for me will ya Strange?

Edited by fredreload
Link to comment
Share on other sites

Well it's easy to bypass this exception, since you only need one set of value, A or B, so set both bit count to zero(they might not be zero but this means A and B are the same) and set C to either A or B

Edited by fredreload
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.