Your task is simple. Determine if one string equals the other (not address, the value) without the use of equality operators (such as ==
, ===
, or .equal()
) or inequality (!=
, !==
) anything similar for other languages. This means anywhere! You may not use these operators anywhere in the code. You may however, you use toggles such as !exp
as you're not directly comparing the exp != with something else
.
In addition, you may not use any functions such as strcmp, strcasecmp, etc.
As for comparison operators (>=
, <=
, >
, <
), they are also disallowed. I realize that some answers include this, but I'd really like to see more answers that don't borderline the equality operator.
An example using PHP is shown:
<?php
$a = 'string';
$b = 'string';
$tmp = array_unique(array($a, $b));
return -count($tmp) + 2;
Simply return true or false (or something that evaluates in the language to true or false like 0 or 1) to indicate if the strings match. The strings should be hardcoded seen in the above example. The strings should not be counted in the golf, so if you declare the variable before hand, don't count the declaration.