Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
9
Task/Palindrome-dates/Perl/palindrome-dates-1.pl
Normal file
9
Task/Palindrome-dates/Perl/palindrome-dates-1.pl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use Time::Piece;
|
||||
my $d = Time::Piece->strptime("2020-02-02", "%Y-%m-%d");
|
||||
|
||||
for (my $k = 1 ; $k <= 15 ; $d += Time::Piece::ONE_DAY) {
|
||||
my $s = $d->strftime("%Y%m%d");
|
||||
if ($s eq reverse($s) and ++$k) {
|
||||
print $d->strftime("%Y-%m-%d\n");
|
||||
}
|
||||
}
|
||||
16
Task/Palindrome-dates/Perl/palindrome-dates-2.pl
Normal file
16
Task/Palindrome-dates/Perl/palindrome-dates-2.pl
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use feature 'say';
|
||||
use ntheory qw/forsetproduct/;
|
||||
|
||||
my $start = '2020-02-02' =~ s/-//gr;
|
||||
my($y) = substr($start,0,4);
|
||||
|
||||
my(@dates,$cnt);
|
||||
forsetproduct { push @dates, "@_" } [$y..$y+999],['01'..'12'],['01'..'31'];
|
||||
for (@dates) {
|
||||
(my $date = $_) =~ s/ //g;
|
||||
next unless $date > $start and $date eq reverse $date;
|
||||
say s/ /-/gr;
|
||||
last if 15 == ++$cnt;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue