summaryrefslogtreecommitdiff
path: root/009
diff options
context:
space:
mode:
authorGuillermo Ramos2019-05-23 10:55:17 +0200
committerGuillermo Ramos2019-05-23 12:38:27 +0200
commitb0609bd3cfd84c803596de9ea615829c712492b8 (patch)
tree0c547adc496684391190ee201337fc45d7bdfdcf /009
parent1cb63654f2c308f40b500b3f66fb3c1286aaa428 (diff)
downloadperlweekly-b0609bd3cfd84c803596de9ea615829c712492b8.tar.gz
[009#1]
Diffstat (limited to '009')
-rwxr-xr-x009/ch1.pl17
1 files changed, 17 insertions, 0 deletions
diff --git a/009/ch1.pl b/009/ch1.pl
new file mode 100755
index 0000000..e98223d
--- /dev/null
+++ b/009/ch1.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+# Compute distinct digits of the given number
+sub distinct {
+ my $n = shift;
+ my %uniq; # Poor man's set
+ $uniq{$_} = 1 foreach split(//, $n);
+ return keys %uniq;
+}
+
+my $n = 0;
+$n++ while distinct($n**2) != 5;
+
+print "$n ($n**2 = ", $n**2, ")\n";