day08
This commit is contained in:
parent
88fc836bd5
commit
78d3e14c07
16
08/1.pl
Normal file
16
08/1.pl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
use 5.20.0;
|
||||||
|
|
||||||
|
my %reg;
|
||||||
|
|
||||||
|
while(<>) {
|
||||||
|
s/^(\w+)/\$reg{$1}/;
|
||||||
|
s/(?<=if )(\w+)/\$reg{$1}/;
|
||||||
|
s/dec/-=/;
|
||||||
|
s/inc/+=/;
|
||||||
|
eval;
|
||||||
|
}
|
||||||
|
|
||||||
|
use List::UtilsBy qw/ max_by /;
|
||||||
|
use List::AllUtils qw/ max /;
|
||||||
|
|
||||||
|
say max values %reg;
|
17
08/2.pl
Normal file
17
08/2.pl
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use 5.20.0;
|
||||||
|
use List::AllUtils qw/ max /;
|
||||||
|
|
||||||
|
my %reg;
|
||||||
|
my $max;
|
||||||
|
|
||||||
|
while(<>) {
|
||||||
|
s/^(\w+)/\$reg{$1}/;
|
||||||
|
s/(?<=if )(\w+)/\$reg{$1}/;
|
||||||
|
s/dec/-=/;
|
||||||
|
s/inc/+=/;
|
||||||
|
eval;
|
||||||
|
$max = max $max, values %reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
say $max;
|
1000
08/input.txt
Normal file
1000
08/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user