


#!/usr/bin/perl
use strict;
use warnings;
binmode STDOUT, ":raw";
my $bitarray = "";
while (<>) {
chomp;
my $x = tonum($_);
vec($bitarray, $x, 1) = 1 if defined $x;
}
print $bitarray;
sub tonum {
my ($s) = @_;
return $s if $s =~ /^\d+$/;
my $rv = 0;
foreach my $c (split(//, $s)) {
$rv = ($rv * 103 + ord($c)) % 1374;
}
return $rv;
}
#!/usr/bin/perl
use strict;
use warnings;
my $fn = shift @ARGV;
open(my $fh, "<:raw", $fn) or die;
my $bitarray;
read $fh, $bitarray, -s $fn;
close($fh);
while (<>) {
chomp;
my $x = tonum($_);
if (vec($bitarray, $x, 1)) {
print "yes\n";
} else {
print "no\n";
}
}
sub tonum {
my ($s) = @_;
return $s if $s =~ /^\d+$/;
my $rv = 0;
foreach my $c (split(//, $s)) {
$rv = ($rv * 103 + ord($c)) % 1374;
}
}
% cat test.txt 1234567 1500020 2431124 7777777 9876543 % ./mkbitarray.pl test.txt > test.ba % ./trybitarray.pl test.ba test.txt yes yes yes yes yes yes % ./trybitarray.pl test.ba 1 no 1234567 yes 2345 no 7777777 yes
わたしのなかでは「ラビリンス/魔王の迷宮」の魔王なんだよねぇ、どうしても。



