diff options
| author | aut0exec <32361472+aut0exec@users.noreply.github.com> | 2023-01-23 20:47:54 -0600 |
|---|---|---|
| committer | aut0exec <32361472+aut0exec@users.noreply.github.com> | 2023-01-23 20:47:54 -0600 |
| commit | 391da064891c3a64b1cf8d2c9a4ebb8aeb39efbe (patch) | |
| tree | 6ddb050459ca1f9eda71a3ccf8fd7a788465db4a | |
| parent | 27b88f614b9bb53872ef0da19a56087505836db0 (diff) | |
| download | perlweeklychallenge-club-391da064891c3a64b1cf8d2c9a4ebb8aeb39efbe.tar.gz perlweeklychallenge-club-391da064891c3a64b1cf8d2c9a4ebb8aeb39efbe.tar.bz2 perlweeklychallenge-club-391da064891c3a64b1cf8d2c9a4ebb8aeb39efbe.zip | |
Task 1 solution
| -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; + } +} |
