In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of November 30th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #07 exercise sheet]


In this problem you should submit a function as described. Inside the function do not print anything that was not asked!

[IP073] Allowed Digits

Theodore "Teddy" loves puzzles and wants to know how many numbers between two given integers a and b are composed only of digits from a specific set of allowed digits. For instance, if the allowed digits are {4,7,8} and we are looking for integers in the range [445, 747], then there are 10 integers fulfilling the requirements: 447, 448, 474, 477, 478, 484, 487, 488, 744 and 747.

The Problem

Write a function possible(digits, a, b) that given a string set of digits and two positive integers a and b, returns the number of integers between a and b that use only digits from the set digits.

Constraints

The following limits are guaranteed in all the test cases that will be given to your program:

1 ≤ ab ≤ 10 000       range of the interval to consider

Example Function Calls Example Output
print(possible("478",445,747))
print(possible("123",445,747))
print(possible("0264",1, 100))
10
0
15

Introduction to Programming (CC1024)
DCC/FCUP - University of Porto