diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-02-22 11:56:04 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-22 11:56:04 +0000 |
| commit | ea9e5776dcf133b8ae8b7e2032d31db685604d2f (patch) | |
| tree | 4768e7c5a4c903de5a96538cd22995840c1336fa /challenge-048 | |
| parent | de551f99333ef8fee0533bcc1dfe2efaf7be482e (diff) | |
| parent | d5aed83391473fa98552a43acf7fbb560620b891 (diff) | |
| download | perlweeklychallenge-club-ea9e5776dcf133b8ae8b7e2032d31db685604d2f.tar.gz perlweeklychallenge-club-ea9e5776dcf133b8ae8b7e2032d31db685604d2f.tar.bz2 perlweeklychallenge-club-ea9e5776dcf133b8ae8b7e2032d31db685604d2f.zip | |
Merge pull request #1290 from choroba/ech048b
Add blogpost by E. Choroba about 048: Survivor and Palindrome Dates
Diffstat (limited to 'challenge-048')
| -rw-r--r-- | challenge-048/e-choroba/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-048/e-choroba/perl/ch-1a.pl | 8 |
2 files changed, 5 insertions, 4 deletions
diff --git a/challenge-048/e-choroba/blog.txt b/challenge-048/e-choroba/blog.txt new file mode 100644 index 0000000000..f517d615f4 --- /dev/null +++ b/challenge-048/e-choroba/blog.txt @@ -0,0 +1 @@ +http://blogs.perl.org/users/e_choroba/2020/02/perl-weekly-challenge-048-survivor-and-palindrome-dates.html diff --git a/challenge-048/e-choroba/perl/ch-1a.pl b/challenge-048/e-choroba/perl/ch-1a.pl index 59edc5fed9..71802c3fd6 100755 --- a/challenge-048/e-choroba/perl/ch-1a.pl +++ b/challenge-048/e-choroba/perl/ch-1a.pl @@ -5,17 +5,17 @@ use feature qw{ say }; my @people = (1) x 50; my $sword = 0; -my $next = sub { +sub following { do { $sword = (1 + $sword) % @people } until $people[$sword]; -}; +} while (1 < (my $living = grep $_, @people)) { # print 1 + $sword, ' kills '; - $next->(); + following(); # print 1 + $sword, $living == 2 # ? ' and the survivor is ' # : ' and passes the sword to '; $people[$sword] = 0; - $next->(); + following(); # say 1 + $sword; } say 1 + $sword; |
