aboutsummaryrefslogtreecommitdiff
path: root/challenge-182/baryshevs
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2022-09-25 09:39:04 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2022-09-25 09:39:04 +0100
commit5979e8be2ae466fad1c654d93f79cf183a4d9766 (patch)
treef2329964da4d34c817545b5b473ca6118f33eaee /challenge-182/baryshevs
parent4d295987c26bc1589b0713f7686102aa5f6a0fd6 (diff)
downloadperlweeklychallenge-club-5979e8be2ae466fad1c654d93f79cf183a4d9766.tar.gz
perlweeklychallenge-club-5979e8be2ae466fad1c654d93f79cf183a4d9766.tar.bz2
perlweeklychallenge-club-5979e8be2ae466fad1c654d93f79cf183a4d9766.zip
- Added solution for week 182 by Baryshev Sergey.
Diffstat (limited to 'challenge-182/baryshevs')
-rw-r--r--challenge-182/baryshevs/README1
-rw-r--r--challenge-182/baryshevs/perl/ch-1.pl37
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-182/baryshevs/README b/challenge-182/baryshevs/README
new file mode 100644
index 0000000000..61199ce0e4
--- /dev/null
+++ b/challenge-182/baryshevs/README
@@ -0,0 +1 @@
+Solutions by Baryshev Sergey.
diff --git a/challenge-182/baryshevs/perl/ch-1.pl b/challenge-182/baryshevs/perl/ch-1.pl
new file mode 100644
index 0000000000..8da8f53cdf
--- /dev/null
+++ b/challenge-182/baryshevs/perl/ch-1.pl
@@ -0,0 +1,37 @@
+#!/usr/bin/perl
+
+=head1
+
+Week 182:
+
+ https://theweeklychallenge.org/blog/perl-weekly-challenge-182
+
+Task #1: Max Index
+
+ You are given a list of integers.
+
+ Write a script to find the index of the first biggest number in
+ the list.
+
+=cut
+
+use v5.30;
+use Test2::V0;
+
+is max_index(5, 2, 9, 1, 7, 6), 2, 'Example 1';
+is max_index(4, 2, 3, 1, 5, 0), 4, 'Example 2';
+
+done_testing;
+
+# METHOD
+
+sub max_index {
+ my $biggest_index=0;
+ return unless scalar @_;
+ for (my $i=0; $i<scalar (@_); $i++) {
+ $biggest_index=$i if ($_[$i] > $_[$biggest_index]);
+ }
+ return $biggest_index;
+}
+
+#EOF \ No newline at end of file