diff options
| author | lakpatashi <lakpatashi@gmail.com> | 2021-04-27 10:18:28 +0530 |
|---|---|---|
| committer | lakpatashi <lakpatashi@gmail.com> | 2021-04-27 10:18:28 +0530 |
| commit | a9033deddb8435c32ffa0f1500288cf4473070b8 (patch) | |
| tree | aaa20cecf26399819097a08fdb1f9bd59ce1e5b6 | |
| parent | 927b3585fb743f89f48f458f10be81b394ce2eb0 (diff) | |
| download | perlweeklychallenge-club-a9033deddb8435c32ffa0f1500288cf4473070b8.tar.gz perlweeklychallenge-club-a9033deddb8435c32ffa0f1500288cf4473070b8.tar.bz2 perlweeklychallenge-club-a9033deddb8435c32ffa0f1500288cf4473070b8.zip | |
Finish challenge-014 ch-1 only with perl
| -rw-r--r-- | challenge-014/lakpatashi/README | 1 | ||||
| -rwxr-xr-x | challenge-014/lakpatashi/perl/ch-1.pl | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/challenge-014/lakpatashi/README b/challenge-014/lakpatashi/README new file mode 100644 index 0000000000..bc153bd576 --- /dev/null +++ b/challenge-014/lakpatashi/README @@ -0,0 +1 @@ +Solution by lakpatashi diff --git a/challenge-014/lakpatashi/perl/ch-1.pl b/challenge-014/lakpatashi/perl/ch-1.pl new file mode 100755 index 0000000000..1ea2415974 --- /dev/null +++ b/challenge-014/lakpatashi/perl/ch-1.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +use warnings; +use strict; +use Data::Dumper; +use List::Util qw(sum); +use feature qw(switch); + +#part 1 +my $max = 1000; +my @seq = (0)x$max; +vanEckSeq(); # building pre compiled seq + +print "@seq[0..10]\n"; +sub vanEckSeq{ + for my $i (0..$max-1){ + for my $j (reverse 0..$i-1){ + if($seq[$j] == $seq[$i]){ + $seq[$i+1] = $i-$j; + last; + } + } + } +} |
