diff options
Diffstat (limited to 'challenge-048')
| -rw-r--r-- | challenge-048/1nickt/README | 1 | ||||
| -rw-r--r-- | challenge-048/1nickt/perl/ch-1.pl | 11 | ||||
| -rw-r--r-- | challenge-048/1nickt/perl/ch-2.pl | 20 |
3 files changed, 32 insertions, 0 deletions
diff --git a/challenge-048/1nickt/README b/challenge-048/1nickt/README new file mode 100644 index 0000000000..539f10b14a --- /dev/null +++ b/challenge-048/1nickt/README @@ -0,0 +1 @@ +Solutions by Nick Tonkin. diff --git a/challenge-048/1nickt/perl/ch-1.pl b/challenge-048/1nickt/perl/ch-1.pl new file mode 100644 index 0000000000..3c0576daa8 --- /dev/null +++ b/challenge-048/1nickt/perl/ch-1.pl @@ -0,0 +1,11 @@ +use strict; +use warnings; + +my @position = (1..50); + +until (@position == 1) { + splice @position, 1, 1; + push @position, shift @position; +} + +print "Survivor started in position @position"; diff --git a/challenge-048/1nickt/perl/ch-2.pl b/challenge-048/1nickt/perl/ch-2.pl new file mode 100644 index 0000000000..dc6bfc751f --- /dev/null +++ b/challenge-048/1nickt/perl/ch-2.pl @@ -0,0 +1,20 @@ +use strict; +use warnings; +use DateTime::Set; + +# Date cannot be higher than 31; thus year must be lower than 2300 +my $end = DateTime->new({ year => 2299, month => 12, day => 31 }); +my $start = $end->clone->add( days => 1 )->set_year('2000'); + +my $dates = DateTime::Set->from_recurrence( + start => $start, + end => $end, + recurrence => sub { shift->add( days => 1 ) }, +); + +my $iter = $dates->iterator; + +while ( defined(my $date = $iter->next) ) { + my $us_format = $date->strftime('%m%d%Y'); + print "$us_format\n" if $us_format eq reverse $us_format; +} |
