aboutsummaryrefslogtreecommitdiff
path: root/challenge-007
diff options
context:
space:
mode:
authorJoelle Maslak <jmaslak@antelope.net>2019-05-08 11:53:16 +0000
committerJoelle Maslak <jmaslak@antelope.net>2019-05-08 11:53:16 +0000
commitc51956ee96c45c84e109c2d4271527aeb3c83d54 (patch)
treeb1fe865ea1897d3f5173a35ec6974d4091fb68f1 /challenge-007
parent72a7634b2ec6ed242fbf75de7349e2adf2b9eb0a (diff)
downloadperlweeklychallenge-club-c51956ee96c45c84e109c2d4271527aeb3c83d54.tar.gz
perlweeklychallenge-club-c51956ee96c45c84e109c2d4271527aeb3c83d54.tar.bz2
perlweeklychallenge-club-c51956ee96c45c84e109c2d4271527aeb3c83d54.zip
Joelle's week 7 challenge 1 solutions
Diffstat (limited to 'challenge-007')
-rwxr-xr-xchallenge-007/joelle-maslak/perl5/ch-1.pl32
-rwxr-xr-xchallenge-007/joelle-maslak/perl6/ch-1.p615
2 files changed, 47 insertions, 0 deletions
diff --git a/challenge-007/joelle-maslak/perl5/ch-1.pl b/challenge-007/joelle-maslak/perl5/ch-1.pl
new file mode 100755
index 0000000000..cc5b3940ae
--- /dev/null
+++ b/challenge-007/joelle-maslak/perl5/ch-1.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+use v5.26;
+use strict;
+use warnings;
+
+# Turn on method signatures
+use feature 'signatures';
+no warnings 'experimental::signatures';
+
+if ( @ARGV > 1 ) { die("Provide letters to use and (optionally) filename") }
+my $MAX = $ARGV[0] // 50;
+
+#
+# Copyright (C) 2019 Joelle Maslak
+# All Rights Reserved - See License
+#
+
+
+MAIN: {
+ for (my $i=1; $i<=$MAX; $i++) { # We know via math that 0 is not Niven
+ say $i if ! ($i % sum( [ split //, $i ]));
+ }
+}
+
+sub sum($list) {
+ my $sum = 0;
+ foreach my $i (@$list) {
+ $sum += $i;
+ }
+ return $sum;
+}
+
diff --git a/challenge-007/joelle-maslak/perl6/ch-1.p6 b/challenge-007/joelle-maslak/perl6/ch-1.p6
new file mode 100755
index 0000000000..e430395632
--- /dev/null
+++ b/challenge-007/joelle-maslak/perl6/ch-1.p6
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl6
+use v6;
+
+#
+# Copyright © 2019 Joelle Maslak
+# All Rights Reserved - See License
+#
+
+sub MAIN(UInt:D $max = 50) {
+ for 0..$max -> $i {
+ say $i if $i %% [+] $i.comb;
+ }
+}
+
+