diff options
| -rwxr-xr-x | challenge-191/tim-potapov/perl/ch-1.pl | 67 | ||||
| -rwxr-xr-x | challenge-191/tim-potapov/perl/ch-2.pl | 48 |
2 files changed, 115 insertions, 0 deletions
diff --git a/challenge-191/tim-potapov/perl/ch-1.pl b/challenge-191/tim-potapov/perl/ch-1.pl new file mode 100755 index 0000000000..5f1595310b --- /dev/null +++ b/challenge-191/tim-potapov/perl/ch-1.pl @@ -0,0 +1,67 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; + +=pod + +Task 1: Twice Largest +Submitted by: Mohammad S Anwar +You are given list of integers, @list. + +Write a script to find out whether the largest item in the list is at least twice as large as each of the other items. + +Example 1 +Input: @list = (1,2,3,4) +Output: -1 + +The largest in the given list is 4. However 4 is not greater than twice of every remaining elements. +1 x 2 < 4 +2 x 2 > 4 +2 x 3 > 4 +Example 2 +Input: @list = (1,2,0,5) +Output: 1 + +The largest in the given list is 5. Also 5 is greater than twice of every remaining elements. +1 x 2 < 5 +2 x 2 < 5 +0 x 2 < 5 +Example 3 +Input: @list = (2,6,3,1) +Output: 1 + +The largest in the given list is 6. Also 6 is greater than twice of every remaining elements. +2 x 2 < 6 +3 x 2 < 6 +1 x 2 < 6 +Example 4 +Input: @list = (4,5,2,3) +Output: -1 + +The largest in the given list is 5. Also 5 is not greater than twice of every remaining elements. +4 x 2 > 5 +2 x 2 < 5 +3 x 2 > 5 + +=cut + +sub function { + my ( $input ) = @_; + +} + +my @cases = ( + { + Name => 'Example1', + Input => 1, + Output => 1, + }, +); + +for ( @cases ) { + is function($_->{Input} ), $_->{Output}, "$_->{Name} - $_->{Input}"; +} + +done_testing(); diff --git a/challenge-191/tim-potapov/perl/ch-2.pl b/challenge-191/tim-potapov/perl/ch-2.pl new file mode 100755 index 0000000000..74b9d29981 --- /dev/null +++ b/challenge-191/tim-potapov/perl/ch-2.pl @@ -0,0 +1,48 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; + +=pod + +Task 2: Cute List +Submitted by: Mohammad S Anwar +You are given an integer, 0 < $n <= 15. + +Write a script to find the number of orderings of numbers that form a cute list. + +With an input @list = (1, 2, 3, .. $n) for positive integer $n, an ordering of @list is cute if for every entry, indexed with a base of 1, either + +1) $list[$i] is evenly divisible by $i +or +2) $i is evenly divisible by $list[$i] +Example +Input: $n = 2 +Ouput: 2 + +Since $n = 2, the list can be made up of two integers only i.e. 1 and 2. +Therefore we can have two list i.e. (1,2) and (2,1). + +@list = (1,2) is cute since $list[1] = 1 is divisible by 1 and $list[2] = 2 is divisible by 2. + +=cut + +sub function { + my ( $input ) = @_; + +} + +my @cases = ( + { + Name => 'Example1', + Input => 1, + Output => 1, + }, +); + +for ( @cases ) { + is function($_->{Input} ), $_->{Output}, "$_->{Name} - $_->{Input}"; +} + +done_testing(); |
