aboutsummaryrefslogtreecommitdiff
path: root/challenge-048
diff options
context:
space:
mode:
authorE. Choroba <choroba@matfyz.cz>2020-02-22 00:28:35 +0100
committerE. Choroba <choroba@matfyz.cz>2020-02-22 00:28:35 +0100
commitd5aed83391473fa98552a43acf7fbb560620b891 (patch)
treeb0459f6fdfc85ad020b18d5d02a8a31e63c756a7 /challenge-048
parent5fedad5ccd75d2fb5a34d22f01fe30a46588bb16 (diff)
downloadperlweeklychallenge-club-d5aed83391473fa98552a43acf7fbb560620b891.tar.gz
perlweeklychallenge-club-d5aed83391473fa98552a43acf7fbb560620b891.tar.bz2
perlweeklychallenge-club-d5aed83391473fa98552a43acf7fbb560620b891.zip
Fix the code according to the blog post
Diffstat (limited to 'challenge-048')
-rwxr-xr-xchallenge-048/e-choroba/perl/ch-1a.pl8
1 files changed, 4 insertions, 4 deletions
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;