aboutsummaryrefslogtreecommitdiff
path: root/challenge-009/dave-jacoby
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2019-05-22 15:06:26 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2019-05-22 15:06:26 +0100
commit8f8a09f2cd07c5987cce98db3eb5f84c1b48a2ce (patch)
treedf05e7c0482604a060e5c874cd2c061389872150 /challenge-009/dave-jacoby
parent7fc23c86970f13fb06ef4a20ed8669d4429152ec (diff)
downloadperlweeklychallenge-club-8f8a09f2cd07c5987cce98db3eb5f84c1b48a2ce.tar.gz
perlweeklychallenge-club-8f8a09f2cd07c5987cce98db3eb5f84c1b48a2ce.tar.bz2
perlweeklychallenge-club-8f8a09f2cd07c5987cce98db3eb5f84c1b48a2ce.zip
- Added solutions by Dave Jacoby.
Diffstat (limited to 'challenge-009/dave-jacoby')
-rw-r--r--challenge-009/dave-jacoby/blog1.txt1
-rw-r--r--challenge-009/dave-jacoby/perl5/ch-1.pl29
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-009/dave-jacoby/blog1.txt b/challenge-009/dave-jacoby/blog1.txt
new file mode 100644
index 0000000000..ec05d9deeb
--- /dev/null
+++ b/challenge-009/dave-jacoby/blog1.txt
@@ -0,0 +1 @@
+https://jacoby.github.io//2019/05/21/finding-first-square-with-five-distinct-digits-plus.html
diff --git a/challenge-009/dave-jacoby/perl5/ch-1.pl b/challenge-009/dave-jacoby/perl5/ch-1.pl
new file mode 100644
index 0000000000..168883e058
--- /dev/null
+++ b/challenge-009/dave-jacoby/perl5/ch-1.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use utf8;
+use feature qw{ postderef say signatures state switch };
+no warnings
+ qw{ experimental::postderef experimental::smartmatch experimental::signatures };
+
+use List::Util qw{uniq};
+
+while (1) {
+ my $d = infinite_iterator(); # gets set each loop
+ if ( test($d) ) { say $d ; exit; }
+}
+
+sub infinite_iterator {
+ state $x = 0;
+ return ++$x**2; # $x += 1; $s = $x squared; return $s;
+}
+
+sub test ( $square ) {
+ my @square = uniq split //, $square;
+ return scalar @square > 4 ? 1 : 0 ;
+ # that is a ternary operator, and it is the same as
+ # return 1 if scalar @square > 4;
+ # return 0;
+}
+