Project Euler 655 - Divisible Palindromes

Official link: https://projecteuler.net/problem=655

Note: My code took ~1900 seconds to run

Thought Process

My idea is quite simple, probably unoptimized, and a bit smarter than brute force, hence the long runtime.

Then using the above I simply go through every digit, calculate all the x1 and x2 and find all the matches, which gives me the number of palindromes with N digits divisible by 10,000,019 and then sum up all the digits.

Also, in order to match x1 and x2 I use dictionaries.

Interactive Code

Enter 2 integers separated by a space (N, Mod)

Code will output how many palindromes there are with digits 0 to N divisble by mod

For example: 5 109 will output

There are 1 palindromes with 3 digits divisible by 109

There are 1 palindromes with 4 digits divisible by 109

There are 7 palindromes with 5 digits divisible by 109

Total = 9