2016-02
This commit is contained in:
parent
88422a98ed
commit
a1a18c063e
35
2016/02/1.pl
Normal file
35
2016/02/1.pl
Normal file
@ -0,0 +1,35 @@
|
||||
use 5.20.0;
|
||||
use List::AllUtils qw/ reduce min max /;
|
||||
|
||||
my @grid = (
|
||||
[ 1,2,3],
|
||||
[4,5,6],
|
||||
[7,8,9],
|
||||
);
|
||||
|
||||
my %d = (
|
||||
U => [ -1, 0 ],
|
||||
R => [ 0, 1 ],
|
||||
L => [ 0, -1 ],
|
||||
D => [ 1, 0 ],
|
||||
);
|
||||
|
||||
my $coord = [ 1,1 ];
|
||||
while(<>) {
|
||||
chomp;
|
||||
$coord = reduce {
|
||||
my $n = $d{$b};
|
||||
use DDP;
|
||||
# p $a;
|
||||
[
|
||||
map { max 0, min $_, 2 }
|
||||
map { $a->[$_] + $n->[$_] }
|
||||
0..1
|
||||
]
|
||||
|
||||
|
||||
} $coord, split '';
|
||||
|
||||
say $grid[$coord->[0]][$coord->[1]];
|
||||
|
||||
}
|
37
2016/02/2.pl
Normal file
37
2016/02/2.pl
Normal file
@ -0,0 +1,37 @@
|
||||
use 5.20.0;
|
||||
use List::AllUtils qw/ reduce min max /;
|
||||
|
||||
my @grid = (
|
||||
[ ],
|
||||
[ '', '', '', 1, '','' ],
|
||||
[ '', '', 2, 3, 4, '' ,'' ],
|
||||
[ '', 5, 6, 7, 8, 9, ],
|
||||
[ '', '', 'A' ,'B', 'C' ],
|
||||
[ '', '', '', 'D' ],
|
||||
);
|
||||
|
||||
my %d = (
|
||||
U => [ -1, 0 ],
|
||||
R => [ 0, 1 ],
|
||||
L => [ 0, -1 ],
|
||||
D => [ 1, 0 ],
|
||||
);
|
||||
|
||||
my $coord = [ 3,1 ];
|
||||
while(<>) {
|
||||
chomp;
|
||||
$coord = reduce {
|
||||
my $n = $d{$b};
|
||||
use DDP;
|
||||
# p $a;
|
||||
my $x = [
|
||||
map { $a->[$_] + $n->[$_] }
|
||||
0..1
|
||||
];
|
||||
|
||||
$grid[$x->[0]][$x->[1]] ? $x : $a;
|
||||
} $coord, split '';
|
||||
|
||||
print $grid[$coord->[0]][$coord->[1]];
|
||||
|
||||
}
|
5
2016/02/input.txt
Normal file
5
2016/02/input.txt
Normal file
@ -0,0 +1,5 @@
|
||||
RDLRUUULRRDLRLLRLDDUDLULULDDULUDRRUURLRLLUULDURRULLRULDRRDLLULLRLLDRLDDRRRRLLRLURRRDRDULRDUULDDDULURUDDRRRUULUDRLLUUURLUDRUUUDRDUULLRLLUDDRURRDDDRDLUUURLRLLUDRURDUDUULDDLLRDURULLLURLDURLUUULDULDDULULLLRRUDLRUURDRDLLURLUDULDUUUURRLDLUDRULUDLDLLDRLDDDRRLLDUDLLRRDDDRLUDURLLLDRUDDLDDRRLUDRRDUDLRRLULDULURULDULUULDRLLDRUUDDRLLUDRULLRRRLRDLRLUDLRULDRDLRDRLRULUDUURRUUULLDDDDUDDLDDDDRRULRDLRDDULLDLDLLDLLDLLDRRDDDRDDLRRDDDRLLLLURRDLRRLDRURDDURDULDDRUURUDUDDDRDRDDRLRRLRULLDRLDLURLRLRUDURRRDLLLUDRLRDLLDDDLLUDRLDRRUUDUUDULDULLRDLUDUURLDDRUDR
|
||||
URULDDLDDUDLLURLUUUUUULUDRRRDDUDURDRUURLLDRURLUULUDRDRLLDRLDULRULUURUURRLRRDRUUUDLLLLRUDDLRDLLDUDLLRRURURRRUDLRLRLLRULRLRLRDLRLLRRUDDRLRUDULDURDLDLLLRDRURURRULLLDLLRRDRLLDUUDLRUUDDURLLLDUUDLRDDURRDRRULLDRLRDULRRLLRLLLLUDDDRDRULRRULLRRUUDULRRRUDLLUUURDUDLLLURRDDUDLDLRLURDDRRRULRRUDRDRDULURULRUDULRRRLRUDLDDDDRUULURDRRDUDLULLRUDDRRRLUDLRURUURDLDURRDUUULUURRDULLURLRUUUUULULLDRURULDURDDRRUDLRLRRLLLLDDUURRULLURURRLLDRRDDUUDLLUURRDRLLLLRLUDUUUDLRLRRLDURDRURLRLRULURLDULLLRRUUUDLLRRDUUULULDLLDLRRRDUDDLRULLULLULLULRU
|
||||
DURUUDULRRLULLLDDUDDLRRDURURRRDDRRURDRURDRLULDUDUDUULULDDUURDDULRDUDUDRRURDRDDRLDRDRLDULDDULRULLDULURLUUDUDULRDDRRLURLLRRDLLDLDURULUDUDULDRLLRRRUDRRDDDRRDRUUURLDLURDLRLLDUULLRULLDDDDRULRRLRDLDLRLUURUUULRDUURURLRUDRDDDRRLLRLLDLRULUULULRUDLUDULDLRDDDDDRURDRLRDULRRULRDURDDRRUDRUDLUDLDLRUDLDDRUUULULUULUUUDUULDRRLDUDRRDDLRUULURLRLULRURDDLLULLURLUDLULRLRRDDDDDRLURURURDRURRLLLLURLDDURLLURDULURUUDLURUURDLUUULLLLLRRDUDLLDLUUDURRRURRUUUDRULDDLURUDDRRRDRDULURURLLDULLRDDDRRLLRRRDRLUDURRDLLLLDDDDLUUURDDDDDDLURRURLLLUURRUDLRLRRRURULDRRLULD
|
||||
LLUUURRDUUDRRLDLRUDUDRLRDLLRDLLDRUULLURLRRLLUDRLDDDLLLRRRUDULDLLLDRLURDRLRRLURUDULLRULLLURRRRRDDDLULURUDLDUDULRRLUDDURRLULRRRDDUULRURRUULUURDRLLLDDRDDLRRULRDRDRLRURULDULRRDRLDRLLDRDURUUULDLLLRDRRRLRDLLUDRDRLURUURDLRDURRLUDRUDLURDRURLRDLULDURDDURUUDRLULLRLRLDDUDLLUUUURLRLRDRLRRRURLRULDULLLLDLRRRULLUUDLDURUUUDLULULRUDDLLDLDLRLDDUDURDRLLRRLRRDDUDRRRURDLRLUUURDULDLURULUDULRRLDUDLDDDUUDRDUULLDDRLRLLRLLLLURDDRURLDDULLULURLRDUDRDDURLLLUDLLLLLUDRDRDLURRDLUDDLDLLDDLUDRRDDLULRUURDRULDDDLLRLDRULURLRURRDDDRLUUDUDRLRRUDDLRDLDULULDDUDURRRURULRDDDUUDULLULDDRDUDRRDRDRDLRRDURURRRRURULLLRRLR
|
||||
URLULLLDRDDULRRLRLUULDRUUULDRRLLDDDLDUULLDRLULRRDRRDDDRRDLRRLLDDRDULLRRLLUDUDDLDRDRLRDLRDRDDUUDRLLRLULLULRDRDDLDDDRLURRLRRDLUDLDDDLRDLDLLULDDRRDRRRULRUUDUULDLRRURRLLDRDRRDDDURUDRURLUDDDDDDLLRLURULURUURDDUDRLDRDRLUUUULURRRRDRDULRDDDDRDLLULRURLLRDULLUUDULULLLLRDRLLRRRLLRUDUUUULDDRULUDDDRRRULUDURRLLDURRDULUDRUDDRUURURURLRDULURDDDLURRDLDDLRUDUUDULLURURDLDURRDRDDDLRRDLLULUDDDRDLDRDRRDRURRDUDRUURLRDDUUDLURRLDRRDLUDRDLURUDLLRRDUURDUDLUDRRL
|
4
2016/02/test
Normal file
4
2016/02/test
Normal file
@ -0,0 +1,4 @@
|
||||
ULL
|
||||
RRDDD
|
||||
LURDL
|
||||
UUUUD
|
Loading…
Reference in New Issue
Block a user