#๐Ÿ”’ bitwise XOR

37 messages ยท Page 1 of 1 (latest)

vagrant cosmos
#

for given a and b
a^x +b^x has to be minimum for any given x.
there has to some property of XOR that will be used here

visual heartBOT
#

@vagrant cosmos

Python help channel opened

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.

mint niche
#

can you elaborate on what you actually need help with?

vagrant cosmos
#

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

mint niche
#

is "+" an "or" in this case?

vagrant cosmos
#

plus

mint niche
#

okay, then what is the equation?

vagrant cosmos
#

sum of two XOR operation

mint niche
#

it's just a term, not an equation (equal sign is missing ๐Ÿ˜‰ )

vagrant cosmos
#

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

rugged ferry
#

Forget about the decimal number and just think in individual bits

vagrant cosmos
#

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

rugged ferry
vagrant cosmos
#

aah

#

answer for all cases is a^b , but don't understand how tho?

rugged ferry
#

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?
vagrant cosmos
#

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?

rugged ferry
#

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

vagrant cosmos
#

ohh thankyou

#

so for

1100^1100 = 0000```
#

is this correct ? , 1100 is x

visual heartBOT
#
Python help channel closed

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.