aboutsummaryrefslogtreecommitdiff
path: root/challenge-114/abigail/perl/ch-2.pl
blob: 61e2ddf1eaeba181e8a821a917f01dae42ee9729 (plain)
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
#!/opt/perl/bin/perl

use 5.032;

use strict;
use warnings;
no  warnings 'syntax';

use experimental 'signatures';
use experimental 'lexical_subs';

#
# See ../README.md
#

#
# Run as: perl ch-2.pl < input-file
#

#
# For a description of the algorithm, see
# https://abigail.github.io/HTML/Perl-Weekly-Challenge/week-114-2.html
#

say oct sprintf ("0b0%b" => $_) =~ s {01(1*)(0*)$} {10$2$1}r while <>;

__END__