From 727dfe756a6725983c74e410f9c526db666cdad8 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 29 Sep 2016 05:05:49 -0400 Subject: problem 206 --- 206.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 206.pl diff --git a/206.pl b/206.pl new file mode 100644 index 0000000..e36a1c5 --- /dev/null +++ b/206.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.014; + +use bigint; + +for my $first (0..9) { + for my $second (0..9) { + my $min = 1020304050607080900 + $first * 100000000000000000 + $second * 1000000000000000; + my $max = 1020394959697989990 + $first * 100000000000000000 + $second * 1000000000000000; + my $guess = 10 + 10 * int(sqrt($min) / 10); + + while (1) { + my $square = $guess**2; + say $guess and exit if $square =~ /^1.2.3.4.5.6.7.8.9.0$/; + $guess += 10; + last if $square > $max; + } + } +} -- cgit v1.2.3