I have a problem like this:
Given a list of numbers with n
(10 <= n <= 60)numbersx1, x2,..., xnsuch that1 <= xj <= 10. Enter the number k(1 <= k <= 8), enter the number m(0 <= m <= 9). Find a combination of k numbers in the given list of numbers such that the sum of the k numbers found modulo 10 equals m. For example: for the sequenceN = {1,3,5,6,3,7,2,9,10,3,4,6}with k = 3 and m = 5, then one of the satisfying combinations is{5,6.4} -> (5 + 6 + 4) % 10 = 5.
I want to find the optimal solution to the problem but i haven't found a way other than using recursion to brute-force. Is there a better way than brute-force? Thank you for your reading!