29 lines
		
	
	
		
			447 B
		
	
	
	
		
			Ruby
		
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			447 B
		
	
	
	
		
			Ruby
		
	
	
| def isPalindrome(n)
 | |
|   numString = n.to_s
 | |
|   for i in 0..(numString.length-1)/2
 | |
|     if !(numString[i] == numString[numString.length-1-i])
 | |
|       return false
 | |
|     end
 | |
|   end
 | |
|   return true
 | |
| end
 | |
| 
 | |
| def productsOfThreeDigits
 | |
|   products = []
 | |
|   for i in 100..999
 | |
|     for j in 100..999
 | |
|       products << i*j
 | |
|     end
 | |
|   end
 | |
|   products
 | |
| end
 | |
| 
 | |
| palindromes = []
 | |
| for i in productsOfThreeDigits
 | |
|   if isPalindrome(i)
 | |
|     palindromes << i
 | |
|   end
 | |
| end
 | |
| 
 | |
| puts palindromes.sort
 |