-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsim-ci
More file actions
executable file
·35 lines (30 loc) · 771 Bytes
/
sim-ci
File metadata and controls
executable file
·35 lines (30 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env perl
use Modern::Perl;
use autodie;
use Scalar::Util qw(openhandle);
sub infile {
my $file = shift;
return $file if openhandle($file);
open my $fh, '<', $file;
return $fh;
}
my $fh = infile(shift // *STDIN);
binmode $fh;
while (read $fh, my $model, 24) {
my @bits = split //, $model;
# Reorder from Simecek's to our convention
@bits = @bits[
0,6,7,18,
4,16,17,22,
3,12,13,21,
1,8,9,19,
5,14,15,23,
2,11,10,20,
];
# Simecek uses 0- and 1-valued bytes, but we use
# the ASCII symbols "0" and "1"
@bits = map { ord $_ } @bits;
# And we use "0" for "is inside", which makes more
# sense in our polynomial setting.
say join '', map { 1 - $_ } @bits;
}