diff options
| -rw-r--r-- | challenge-201/aut0exec/perl/Task1.pl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-201/aut0exec/perl/Task1.pl b/challenge-201/aut0exec/perl/Task1.pl new file mode 100644 index 0000000000..5cec6c95bb --- /dev/null +++ b/challenge-201/aut0exec/perl/Task1.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +# +# You are given an array of unique numbers. +# Write a script to find out all missing numbers in the range 0..$n where $n is the array size. +# + +use strict; +use warnings; + +#~ my @num_array = (2, 1, 4, 3); +my @num_array = (0, 1, 2, 3, 4); +my $array_len = scalar(@num_array); +my %array_hash = map { $_ => 1 } @num_array; + +print("Array length is: $array_len \n"); + +foreach ( 0..$array_len ){ + #~ print ("Checking $_ \n"); + if (! exists($array_hash{$_})){ + print("Array is missing $_!\n"); + last; + } +} |
