Project Euler 172 - Investigating numbers with few repeated digits

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

Thought Process

Extremely similar to Problem 164 for me, basically just re-used my code with a different recursive function.

This time my function looks like this:

compute(goal, pos, count_0, count_1, count_2, count_3, count_4, count_5, count_6, count_7, count_8, count_9)

Just keeps updating the count of each individual number, and then up the pos by 1, if we reach 18 we have a valid number, if any count_x > 3, we stop it there.

Used the @cache decorator from functools for memoization, get the solution in 10 seconds!

Interactive Code

Enter a number (yourinput)

Code will output the number of yourinput-digit numbers n (without leading zeros) such that no digit occurs more than three times