diff options
| author | Adam Russell <ac.russell@live.com> | 2019-05-09 16:22:58 -0400 |
|---|---|---|
| committer | Adam Russell <ac.russell@live.com> | 2019-05-09 16:22:58 -0400 |
| commit | 9cbc4c1e38182ac257a1afe1b915c9467657cdc5 (patch) | |
| tree | 256dc90065d4f9598ebb692bcfd62cab15366cc2 /challenge-007 | |
| parent | b6dfe831cbda4c869683fe3c5ca9ae33576c8c6f (diff) | |
| download | perlweeklychallenge-club-9cbc4c1e38182ac257a1afe1b915c9467657cdc5.tar.gz perlweeklychallenge-club-9cbc4c1e38182ac257a1afe1b915c9467657cdc5.tar.bz2 perlweeklychallenge-club-9cbc4c1e38182ac257a1afe1b915c9467657cdc5.zip | |
initial commit challenge 007
Diffstat (limited to 'challenge-007')
| -rw-r--r-- | challenge-007/adam-russell/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-007/adam-russell/perl5/ch-1.pl | 19 | ||||
| -rw-r--r-- | challenge-007/adam-russell/perl5/ch-2.pl | 14 |
3 files changed, 34 insertions, 0 deletions
diff --git a/challenge-007/adam-russell/blog.txt b/challenge-007/adam-russell/blog.txt new file mode 100644 index 0000000000..25c43b2daa --- /dev/null +++ b/challenge-007/adam-russell/blog.txt @@ -0,0 +1 @@ +https://adamcrussell.livejournal.com/2336.html diff --git a/challenge-007/adam-russell/perl5/ch-1.pl b/challenge-007/adam-russell/perl5/ch-1.pl new file mode 100644 index 0000000000..97fe7e2bad --- /dev/null +++ b/challenge-007/adam-russell/perl5/ch-1.pl @@ -0,0 +1,19 @@ +use strict; +use warnings; +## +# Print all the niven numbers from 0 to 50 inclusive, each on their own line. +# A niven number is a non-negative number that is divisible by the sum of its digits. +## +use constant NIVEN_COUNT => 50; +my $i = 1; +my $count = 0; +do{ + my @digits = split(//,$i); + my $digit_sum = unpack("%32C*", pack("C*", @digits)); + if($i % $digit_sum == 0){ + print "$i "; + $count++; + } + $i++; +}while($count < NIVEN_COUNT); +print "\n"; diff --git a/challenge-007/adam-russell/perl5/ch-2.pl b/challenge-007/adam-russell/perl5/ch-2.pl new file mode 100644 index 0000000000..b351bb1dea --- /dev/null +++ b/challenge-007/adam-russell/perl5/ch-2.pl @@ -0,0 +1,14 @@ +use strict; +use warnings; +## +# Given two input words and a file that contains an ordered word list, implement a +# routine (e.g., find_shortest_ladder(word1, word2, wordlist)) that finds the shortest +# ladder between the two input words. +# +# A word ladder is a sequence of words [w_0, w_1, ..., w_n] such that each word w_i in +# the sequence is obtained by changing a single character in the word wi-1. +## +use Graph; +sub find_shortest_ladder{ + +} |
