#๐ bitwise XOR
37 messages ยท Page 1 of 1 (latest)
@vagrant cosmos
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
can you elaborate on what you actually need help with?
we are given a= 6 , b =12
and an equation
a^x + b^x
it is asked for any given value of 'x' what will be the minimum answer for the equation
i.e. a^x + b^x
is "+" an "or" in this case?
plus
okay, then what is the equation?
sum of two XOR operation
it's just a term, not an equation (equal sign is missing ๐ )
what will be the minimum value of the term a^x + b^x and for what x , if there are multiple value of x then wirte any of them
0.0
Forget about the decimal number and just think in individual bits
sorry i dont copy
for a = 6 and b=12 the minimum value occurs at x =4
6^4 + 12^4 = 10
apparently 10 is also 6^12
Instead of 6 and 12 think 0110 and 1100
And look at the individual bits
0110
1100
^
?
```Both have to be `xor`'d by the same number (again think in bits). Say you look at the digit pointed to by `^`, what happens if `?` is 1/0? Does it matter here? When does it matter, and what do you do to minimize the sum of that digit then?
0110^0100 + 1100^0100
ohh i think i got it
so we have to neutral the second 1
right?
1100^0100 = 1000```
since the third bit is the only one common
right?
Well for each bit pair, there's basically only 3 cases: both are 1/0 or 1110, and there's a best bit to xor for each case
Then you can construct x bit by bit, or do some smart stuff and come up with a formula
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.