2016-08
This commit is contained in:
parent
2a5f946613
commit
d0911c4387
33
2016/08/1.pl
Normal file
33
2016/08/1.pl
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
use 5.20.0;
|
||||||
|
use experimental qw/ postderef /;
|
||||||
|
|
||||||
|
my $grid = [ map { [ (0) x 50 ] } 0..5 ];
|
||||||
|
|
||||||
|
use DDP;
|
||||||
|
|
||||||
|
while(<>) {
|
||||||
|
if( /rect (\d+)x(\d+)/ ) {
|
||||||
|
for my $x ( 0..$1-1 ) {
|
||||||
|
for my $y ( 0..$2-1 ) {
|
||||||
|
$grid->[$y][$x] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( /rotate row y=(\d+) by (\d+)/ ) {
|
||||||
|
my @v = $grid->[$1]->@*;
|
||||||
|
$grid->[$1] = [ @v[ (-$2)..-1 ], @v[0..($#v-$2)] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( /rotate column x=(\d+) by (\d+)/ ) {
|
||||||
|
my @v = map { $_->[$1] } $grid->@*;
|
||||||
|
@v = ( @v[ (-$2)..-1 ], @v[0..($#v-$2)] );
|
||||||
|
$grid->[$_][$1] = shift @v for 0..5;
|
||||||
|
}
|
||||||
|
|
||||||
|
say;
|
||||||
|
say map { $_ ? '#' : ' ' } @$_ for @$grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
use List::AllUtils qw/ sum /;
|
||||||
|
say sum map { @$_ } @$grid;
|
153
2016/08/input.txt
Normal file
153
2016/08/input.txt
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
rect 1x1
|
||||||
|
rotate row y=0 by 2
|
||||||
|
rect 1x1
|
||||||
|
rotate row y=0 by 5
|
||||||
|
rect 1x1
|
||||||
|
rotate row y=0 by 3
|
||||||
|
rect 1x1
|
||||||
|
rotate row y=0 by 3
|
||||||
|
rect 2x1
|
||||||
|
rotate row y=0 by 5
|
||||||
|
rect 1x1
|
||||||
|
rotate row y=0 by 5
|
||||||
|
rect 4x1
|
||||||
|
rotate row y=0 by 2
|
||||||
|
rect 1x1
|
||||||
|
rotate row y=0 by 2
|
||||||
|
rect 1x1
|
||||||
|
rotate row y=0 by 5
|
||||||
|
rect 4x1
|
||||||
|
rotate row y=0 by 3
|
||||||
|
rect 2x1
|
||||||
|
rotate row y=0 by 5
|
||||||
|
rect 4x1
|
||||||
|
rotate row y=0 by 2
|
||||||
|
rect 1x2
|
||||||
|
rotate row y=1 by 6
|
||||||
|
rotate row y=0 by 2
|
||||||
|
rect 1x2
|
||||||
|
rotate column x=32 by 1
|
||||||
|
rotate column x=23 by 1
|
||||||
|
rotate column x=13 by 1
|
||||||
|
rotate row y=0 by 6
|
||||||
|
rotate column x=0 by 1
|
||||||
|
rect 5x1
|
||||||
|
rotate row y=0 by 2
|
||||||
|
rotate column x=30 by 1
|
||||||
|
rotate row y=1 by 20
|
||||||
|
rotate row y=0 by 18
|
||||||
|
rotate column x=13 by 1
|
||||||
|
rotate column x=10 by 1
|
||||||
|
rotate column x=7 by 1
|
||||||
|
rotate column x=2 by 1
|
||||||
|
rotate column x=0 by 1
|
||||||
|
rect 17x1
|
||||||
|
rotate column x=16 by 3
|
||||||
|
rotate row y=3 by 7
|
||||||
|
rotate row y=0 by 5
|
||||||
|
rotate column x=2 by 1
|
||||||
|
rotate column x=0 by 1
|
||||||
|
rect 4x1
|
||||||
|
rotate column x=28 by 1
|
||||||
|
rotate row y=1 by 24
|
||||||
|
rotate row y=0 by 21
|
||||||
|
rotate column x=19 by 1
|
||||||
|
rotate column x=17 by 1
|
||||||
|
rotate column x=16 by 1
|
||||||
|
rotate column x=14 by 1
|
||||||
|
rotate column x=12 by 2
|
||||||
|
rotate column x=11 by 1
|
||||||
|
rotate column x=9 by 1
|
||||||
|
rotate column x=8 by 1
|
||||||
|
rotate column x=7 by 1
|
||||||
|
rotate column x=6 by 1
|
||||||
|
rotate column x=4 by 1
|
||||||
|
rotate column x=2 by 1
|
||||||
|
rotate column x=0 by 1
|
||||||
|
rect 20x1
|
||||||
|
rotate column x=47 by 1
|
||||||
|
rotate column x=40 by 2
|
||||||
|
rotate column x=35 by 2
|
||||||
|
rotate column x=30 by 2
|
||||||
|
rotate column x=10 by 3
|
||||||
|
rotate column x=5 by 3
|
||||||
|
rotate row y=4 by 20
|
||||||
|
rotate row y=3 by 10
|
||||||
|
rotate row y=2 by 20
|
||||||
|
rotate row y=1 by 16
|
||||||
|
rotate row y=0 by 9
|
||||||
|
rotate column x=7 by 2
|
||||||
|
rotate column x=5 by 2
|
||||||
|
rotate column x=3 by 2
|
||||||
|
rotate column x=0 by 2
|
||||||
|
rect 9x2
|
||||||
|
rotate column x=22 by 2
|
||||||
|
rotate row y=3 by 40
|
||||||
|
rotate row y=1 by 20
|
||||||
|
rotate row y=0 by 20
|
||||||
|
rotate column x=18 by 1
|
||||||
|
rotate column x=17 by 2
|
||||||
|
rotate column x=16 by 1
|
||||||
|
rotate column x=15 by 2
|
||||||
|
rotate column x=13 by 1
|
||||||
|
rotate column x=12 by 1
|
||||||
|
rotate column x=11 by 1
|
||||||
|
rotate column x=10 by 1
|
||||||
|
rotate column x=8 by 3
|
||||||
|
rotate column x=7 by 1
|
||||||
|
rotate column x=6 by 1
|
||||||
|
rotate column x=5 by 1
|
||||||
|
rotate column x=3 by 1
|
||||||
|
rotate column x=2 by 1
|
||||||
|
rotate column x=1 by 1
|
||||||
|
rotate column x=0 by 1
|
||||||
|
rect 19x1
|
||||||
|
rotate column x=44 by 2
|
||||||
|
rotate column x=40 by 3
|
||||||
|
rotate column x=29 by 1
|
||||||
|
rotate column x=27 by 2
|
||||||
|
rotate column x=25 by 5
|
||||||
|
rotate column x=24 by 2
|
||||||
|
rotate column x=22 by 2
|
||||||
|
rotate column x=20 by 5
|
||||||
|
rotate column x=14 by 3
|
||||||
|
rotate column x=12 by 2
|
||||||
|
rotate column x=10 by 4
|
||||||
|
rotate column x=9 by 3
|
||||||
|
rotate column x=7 by 3
|
||||||
|
rotate column x=3 by 5
|
||||||
|
rotate column x=2 by 2
|
||||||
|
rotate row y=5 by 10
|
||||||
|
rotate row y=4 by 8
|
||||||
|
rotate row y=3 by 8
|
||||||
|
rotate row y=2 by 48
|
||||||
|
rotate row y=1 by 47
|
||||||
|
rotate row y=0 by 40
|
||||||
|
rotate column x=47 by 5
|
||||||
|
rotate column x=46 by 5
|
||||||
|
rotate column x=45 by 4
|
||||||
|
rotate column x=43 by 2
|
||||||
|
rotate column x=42 by 3
|
||||||
|
rotate column x=41 by 2
|
||||||
|
rotate column x=38 by 5
|
||||||
|
rotate column x=37 by 5
|
||||||
|
rotate column x=36 by 5
|
||||||
|
rotate column x=33 by 1
|
||||||
|
rotate column x=28 by 1
|
||||||
|
rotate column x=27 by 5
|
||||||
|
rotate column x=26 by 5
|
||||||
|
rotate column x=25 by 1
|
||||||
|
rotate column x=23 by 5
|
||||||
|
rotate column x=22 by 1
|
||||||
|
rotate column x=21 by 2
|
||||||
|
rotate column x=18 by 1
|
||||||
|
rotate column x=17 by 3
|
||||||
|
rotate column x=12 by 2
|
||||||
|
rotate column x=11 by 2
|
||||||
|
rotate column x=7 by 5
|
||||||
|
rotate column x=6 by 5
|
||||||
|
rotate column x=5 by 4
|
||||||
|
rotate column x=3 by 5
|
||||||
|
rotate column x=2 by 5
|
||||||
|
rotate column x=1 by 3
|
||||||
|
rotate column x=0 by 4
|
Loading…
Reference in New Issue
Block a user