Merge pull request #42 from MithrandirAgain/master

Added xor goodie
master
Hunter Lang 2012-02-05 08:08:56 -08:00
commit 3ce9932b1d
2 changed files with 20 additions and 0 deletions

16
xor/goodie.pl Normal file
View File

@ -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';
}
}

4
xor/queries.txt Normal file
View File

@ -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