Project Euler/4: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Problem 4 on Project Euler: https://projecteuler.net/problem=4 | Problem 4 on Project Euler: https://projecteuler.net/problem=4 | ||
==Notes== | |||
In this problem, we are asked to find the largest palindrome number that is the product of two three-digit numbers. | In this problem, we are asked to find the largest palindrome number that is the product of two three-digit numbers. | ||
| Line 12: | Line 14: | ||
* Add the product to a set | * Add the product to a set | ||
* Compute the maximum of the set | * Compute the maximum of the set | ||
Revision as of 09:01, 1 July 2017
Problem 4 on Project Euler: https://projecteuler.net/problem=4
Notes
In this problem, we are asked to find the largest palindrome number that is the product of two three-digit numbers.
This problem has one main task:
- Turning numbers into strings (to check if palindrome)
Normally, Project Euler problems present you with a huge, intractable problem space, and you must spend some time up front eliminating or narrowing down the space you are exploring. But in this case, the key space of all products of all three-digit numbers is trivial to generate, so we do it. Then take the maximum.
Basic structure:
- For each combination of three digit numbers:
- Add the product to a set
- Compute the maximum of the set