Skip to content
This repository
Browse code

everyone use the same algorithm

  • Loading branch information...
commit fd8c65751e337bcc350391497a34341f554b5572 1 parent 6a13388
Kevin Scaldeferri authored September 07, 2009
2  haskell/004/01.hs
@@ -13,7 +13,7 @@ palindromes :: [Integer]
13 13
 palindromes =
14 14
     do
15 15
       a <- [100..999]
16  
-      b <- [100..999]
  16
+      b <- [a..999]
17 17
       let prod = a * b
18 18
       guard $ isPalindrome prod
19 19
       return prod
6  perl5/004/01.pl
@@ -4,15 +4,15 @@
4 4
 
5 5
 # Problem 4
6 6
 # 16 November 2001
7  
-# 
  7
+#
8 8
 # A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
9  
-# 
  9
+#
10 10
 # Find the largest palindrome made from the product of two 3-digit numbers.
11 11
 
12 12
 
13 13
 my $max = 0;
14 14
 for my $a ( 100..999 ){
15  
-    for my $b ( 100..999 ){
  15
+    for my $b ( $a..999 ){
16 16
         my $product = $a * $b;
17 17
 
18 18
         $max = $product if $product > $max

0 notes on commit fd8c657

Please sign in to comment.
Something went wrong with that request. Please try again.