Skip to main content

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.

PHP

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.

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.

added 38 characters in body
Source Link

PHP

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, it'sits behavior with strings isn't as good as it maycould 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 nornot 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 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 may bemaybe there's more simplea 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.

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 example for PHP. There it's available with ^. Unfortunately, it's behavior with strings isn't as good as it may be, so you'll need to check string length before. That is because in PHP, xor will strip longer string down to length of shorter string.

Next thing - is to work with strings properly, because single xor will nor produce 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, important thing is about PHP type juggling (so empty array will be cast to false). Or may be there's more simple way to check if array contain non-zero members (Edit: while I've typing this, there's 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 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.

PHP

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.

added 123 characters in body
Source Link
Alma Do
  • 161
  • 3

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 example for PHP. There it's available with ^. Unfortunately, it's behavior with strings isn't as good as it may be, so you'll need to check string length before. That is because in PHP, xor will strip longer string down to length of shorter string.

Next thing - is to work with strings properly, because single xor will nor produce 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, important thing is about PHP type juggling (so empty array will be cast to false). Or may be there's more simple way to check if array contain non-zero members. (Edit: while I've typing this, there's 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 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.

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 example for PHP. There it's available with ^. Unfortunately, it's behavior with strings isn't as good as it may be, so you'll need to check string length before. That is because in PHP, xor will strip longer string down to length of shorter string.

Next thing - is to work with strings properly, because single xor will nor produce 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, important thing is about PHP type juggling (so empty array will be cast to false). Or may be there's more simple way to check if array contain non-zero members.

But I believe there are languages, where we can do just a ^ b - literally, getting 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.

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 example for PHP. There it's available with ^. Unfortunately, it's behavior with strings isn't as good as it may be, so you'll need to check string length before. That is because in PHP, xor will strip longer string down to length of shorter string.

Next thing - is to work with strings properly, because single xor will nor produce 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, important thing is about PHP type juggling (so empty array will be cast to false). Or may be there's more simple way to check if array contain non-zero members (Edit: while I've typing this, there's 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 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.

Source Link
Alma Do
  • 161
  • 3
Loading