Pages:
Author

Topic: This message was too old and has been purged - page 3. (Read 6056 times)

legendary
Activity: 2646
Merit: 1137
All paid signature campaigns should be banned.
I love puzzles and work is slow right now.  Speaking of work, got a meeting, be back later.
newbie
Activity: 3
Merit: 0
I'm with BurtW on this.  BTW.. way more than $200 worth of effort in this thread already  Shocked
legendary
Activity: 2646
Merit: 1137
All paid signature campaigns should be banned.
Why on Earth do you have a mod 2^32-1 and not mod 2^32?

The result of mod 2^32-1 (on an integer) gives you results from 0x00000000 to 0xFFFFFFFE

Seems pretty worthless.  Are you SURE that is the correct formula for the allowed mod operator?

Please double check this because your description of what the allowed mod operator does:

"chop off the bits above 32 bits"

would indicate that the allowed operator is really mod 2^32.

mod 2^32-1 does not "chop off all the bits above 32 bits".

Scaling by 2^32-1 would work (as shown above) but what a total PITA.
legendary
Activity: 1512
Merit: 1036
I think I can solve this using the initial terms, but it will have to be later today.
"Allowed operators: powers, *, /, + and -. Also modulo (2^32-1) is allowed."

The mod rule is not a hindrance if we were given infinite precision, as x % 2^32 can be obtained by x *((2^32-1)/(2^32)) % (2^32-1), but I assume this would not be allowed due to some computing platforms with limited float precision (it works in python to 53 sig figs):

def mod32(r):
   r = float(r)    
   return ((r/2.0**32.0 * (2.0**32.0-1.0)) % (2.0**32.0-1.0)) * 2.0**32.0 / (2.0**32.0-1.0)

>>> print mod32(1), 1 % 0x100000000
1.0 1
>>> print mod32(0xffffffff), 0xffffffff % 0x100000000
4294967295.0 4294967295
>>> print mod32(0x100000000), 0x100000000 % 0x100000000
0.0 0



If not, it will have to be via math->logic, as in all bits are set : (x-(x%(2^32-1)))/(2^32-1)

legendary
Activity: 1260
Merit: 1168
This message was too old and has been purged
legendary
Activity: 1260
Merit: 1168
This message was too old and has been purged
legendary
Activity: 1512
Merit: 1036
Just a pointer ... it might be sufficient to find a representation of the AND operator ;-)

I have not yet proven it, but I think that A XOR B = A+B-2(A AND B)

For individual bits using and, multiplication, and inversion:


(I'll keep adding)
The truth table for xor is:
ABX
000
011
101
110

Your truth table:
ABX
000+0-2(0)=0
010+1-2(1)=1
101+0-2(1)=1
111+1-2(1)=0
although if you can use a logic operation, why can't we just use the correct one?
legendary
Activity: 1512
Merit: 1036
I can put the int functions in the right place for float.

I think the OP has made a non-solvable challenge. The solution of shifting left and shifting right to truncate to one bit at a time is as elegant as it is going to get.

If mod is the only function that can be used, but unlimited variables can be used, you could discover the bits with maths.
legendary
Activity: 1260
Merit: 1168
This message was too old and has been purged
legendary
Activity: 2646
Merit: 1137
All paid signature campaigns should be banned.
If there is a python operator to throw away the fraction after each divide can you modify your python to apply that on the two divides in your sript so we can make sure it works?
legendary
Activity: 1512
Merit: 1036
I found the python problem. I didn't have a constant 231 in the middle, and it now seems to work when only using the integer function and of course passing integers. (stupid edits, I found my goof independently...)

I would think a mathematics computing and simulation platform would have no concept of int data types presented to the user though, you would have to call an int() function.
legendary
Activity: 2646
Merit: 1137
All paid signature campaigns should be banned.
Yes, my solution is pure integer math - not floating point math.

The operation of "choping off everything above 32 bits" is mod 2^32 not mod 2^32-1, mod 2^32-1 makes very little sense as an operation for any purpose so perhaps you really mean that you are doing bitwise AND with 2^32-1 which is the same thing as mod 2^32?

If doing this with floating point then you need to throw away the fractional part of every divide.  

To answer the question why your python does not work you are multiplying by the wrong thing it is always 2^31 you have 2^(31-n)
member
Activity: 118
Merit: 10
E-K can you look at my latest submission on the first page of this thread and tell me what's wrong with it?

Thanks.
legendary
Activity: 1260
Merit: 1168
This message was too old and has been purged
legendary
Activity: 1512
Merit: 1036
The first challenge in this thought exercise is how do you extract the value of a bit using only formulas, and not int or mod?

I give you two numbers, 0b0101 = 5 or 0b0111 = 7. Tell me if the 2 bit is set. Allowed operators: powers, *, /, + and -.
legendary
Activity: 1512
Merit: 1036
legendary
Activity: 1260
Merit: 1168
This message was too old and has been purged
legendary
Activity: 1260
Merit: 1168
This message was too old and has been purged
full member
Activity: 182
Merit: 100
Most good calculators will accept hex numbers exactly as shown in my post.  At any rate all the constants can be converted to decimal if needed.  The formula is correct and satisfies the rules.

Did I win?

Touche, I believe you do win, congrats either way. I just had a quick skim and it looked more like some C++ code at first, but now I see it is indeed purely mathematical.
legendary
Activity: 1260
Merit: 1168
This message was too old and has been purged
Pages:
Jump to: