]> www.fi.muni.cz Git - aoc.git/blob - lib/Y/AoC.pm
Infrastructure cleanups
[aoc.git] / lib / Y / AoC.pm
1 package Y::AoC;
2
3 use v5.36;
4
5 use Exporter qw(import);
6 our @EXPORT_OK = qw(red grey white yellow day year);
7
8 use FindBin qw($Bin);
9 use Term::ANSIColor;
10 use Cwd;
11
12 sub red    { colored(['bright_red    on_black'], @_); }
13 sub white  { colored(['bright_white  on_black'], @_); }
14 sub grey   { colored(['white         on_black'], @_); }
15 sub yellow { colored(['bright_yellow on_black'], @_); }
16
17 sub day {
18         my ($num) = $0 =~ /.*\D(\d+)/;
19         int ((1+$num)/2);
20 }
21
22 sub year {
23         my ($num) = $Bin =~ /.*(\d{4})/;
24         if (!defined $num) {
25                 ($num) = getcwd =~ /.*(\d{4})/;
26         }
27         $num;
28 }
29
30 1;