diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-02-21 10:19:04 +0000 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-02-21 10:19:04 +0000 |
| commit | 581089b8db6d3db074ce27d74c03344c590bb0a3 (patch) | |
| tree | 73cee998dc5a41bda80f2b8dc4c0a501a18abc9e /challenge-048 | |
| parent | 170c09b1653da44f10c6ec6349b987ad80b4eb36 (diff) | |
| download | perlweeklychallenge-club-581089b8db6d3db074ce27d74c03344c590bb0a3.tar.gz perlweeklychallenge-club-581089b8db6d3db074ce27d74c03344c590bb0a3.tar.bz2 perlweeklychallenge-club-581089b8db6d3db074ce27d74c03344c590bb0a3.zip | |
- Added solutions by Nick Tonkin.
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; +} |
