PHP, 68 Bytes
I assume you're prohibited to use any comparison operators. So <
or >
are included.
The idea is to use bitwise XOR. In different languages this operator has different syntax - I'll show an example for PHP. There it's available with ^
. Unfortunately, its behavior with strings isn't as good as it could be, so you'll need to check string length before. That is because in PHP, xor will strip the longer string down to the length of the shorter string.
Next thing is to work with strings properly, because a single xor
will not produce a result, available for further operations in PHP. That's why unpack()
was used. So, the code would be:
return !(strlen($a)^strlen($b)) & !array_filter(unpack('c*', $a^$b))
It's longer than option with <
/ >
but it won't use them. Also, the important thing is about PHP type juggling (so empty array will be cast to false
). Or maybe there's a simpler way to check if an array contain non-zero members (Edit: while I've been typing this, there's a good catch with trim()
in another answer, so we can get rid of array operations)
But I believe there are languages, where we can do just a ^ b
- literally, getting the result. If it's 0
(treated from all resulted bytes) - then our strings are equal. It's very easy and even more simple than <
or >
stuff.