diff --git a/xor/goodie.pl b/xor/goodie.pl new file mode 100644 index 000000000..cb7fa2298 --- /dev/null +++ b/xor/goodie.pl @@ -0,0 +1,16 @@ + +# Takes given numbers and does a bitwise exclusive-or on them. + +if (!$type && $q_check =~ m/^[0-9]+\s*(\s+(xor|⊕)\s*[0-9]+)+\s*$/i) { + + my $num = 0; + my @numbers = grep(!/(xor|⊕)/, split(/\s+(xor|⊕)\s+/, $q_check)); + foreach (@numbers) { + $num ^= ord(chr($_)); + } + $answer_results = qq($num); + if ($answer_results) { + $answer_type = 'xor'; + $type = 'E'; + } +} diff --git a/xor/queries.txt b/xor/queries.txt new file mode 100644 index 000000000..5304c57da --- /dev/null +++ b/xor/queries.txt @@ -0,0 +1,4 @@ +4 xor 5 +5 ⊕ 79 +4 xor 3 xor 1 +9489 xor 394 xor 9349 xor 39 xor 29 xor 4967 xor 3985