aboutsummaryrefslogtreecommitdiff
path: root/challenge-048
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-048')
-rw-r--r--challenge-048/alexander-karelas/perl/ch-1.pl20
-rw-r--r--challenge-048/alexander-karelas/perl/ch-2.pl14
2 files changed, 34 insertions, 0 deletions
diff --git a/challenge-048/alexander-karelas/perl/ch-1.pl b/challenge-048/alexander-karelas/perl/ch-1.pl
new file mode 100644
index 0000000000..fea14658ef
--- /dev/null
+++ b/challenge-048/alexander-karelas/perl/ch-1.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+
+use v5.26;
+use warnings;
+
+my @people = (1 .. 50);
+
+my $sword_at = 0; # array index
+
+while (@people > 1) {
+ if ($sword_at < $#people) {
+ splice @people, $sword_at + 1, 1;
+ $sword_at++;
+ } else {
+ splice @people, 0, 1;
+ $sword_at = 0;
+ }
+}
+
+say $people[0]; \ No newline at end of file
diff --git a/challenge-048/alexander-karelas/perl/ch-2.pl b/challenge-048/alexander-karelas/perl/ch-2.pl
new file mode 100644
index 0000000000..dca1b0c225
--- /dev/null
+++ b/challenge-048/alexander-karelas/perl/ch-2.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+
+use v5.26;
+use warnings;
+
+use Time::Local;
+
+for (my $year = 2000; $year <= 2999; $year++) {
+ my ($day, $month) = (reverse $year) =~ /(..)(..)/;
+ eval { timegm(0, 0, 0, $day, $month - 1, $year - 1900) };
+ if (! $@) {
+ say reverse($year) . $year;
+ }
+} \ No newline at end of file