As it turns out, Python allows for 1j for
to be compressed to 1jfor
. However, jfor
sounds like xnor
. Since all similar-phonic phrases have something in common, there must be some property shared between jfor
and xnor
.
If we look at the ASCII representation of the first two characters of jfor
in binary, we see:
j: 1101010
f: 1100110
j&f: 1100010
Notice that the bitwise AND of j
and f
has a streak of 1
s at the beginning, then some 0s
, then a single 1
.
Definition: A pair of numbers meets the JFor property iff their bitwise AND in binary meets the following regex (excluding leading 0s): /1+0+1+0*/
(1 or more 1
s, followed by 1 or more 0
s, followed by 1 or more 1
s, followed by 0 or more 0
s)
Do the ASCII codes for x
and n
meet the JFor property?
x: 1111000
n: 1101110
x&n: 1101000
Yes! So my hunch was correct; jfor
and xnor
sound similar, and they share a property (This means, of course, that odor
must have that property too).
Task
Given a pair of numbers, determine if they meet the JFor property.
The two numbers may not be distinct, but they will both be integers from 0
to 255
respectively.
Output may follow your language's conventions for Truthy and Falsey, or you may choose any two consistent, distinct values to represent truthy and falsey respectively.
Your program/function may take input in any reasonable format to represent an ordered pair of integers/bytes.
Test cases
# Truthy:
106 102
110 120
42 26
17 29
228 159
255 253
# Falsey:
85 170
228 67
17 38
255 255
38 120
21 21
(Bounty: 50 rep to the shortest answer on July 24 if it somehow uses a XOR or XNOR operation; please mention if your submission qualifies)
102&70=70 -> 1000110
- isn't that truthy? \$\endgroup\$21 21
. \$\endgroup\$102 70
test case to21 21
\$\endgroup\$