We define the function `f1(n,k)`, as the least multiple of `n` that has all its digits less than `k`. 

We define the function `f2(n,k)`, as the least multiple of `n` that has all the digits that are less than `k`.

Each digit may occur more than once in both values of `f1(n,k)` and `f2(n,k)`.

The possible values for `n` and `k` according to these ranges for both functions `f1` and `f2` in this kata:
``` 
1 <= n <= 1.000.000.000.000
3 <= k <= 9
``` 

For example, let's see the value of both functions for `n = 71` and `k = 4`:
``` 
f1(71,4) == 213 # all its digits less than 4
f2(71,4) == 2130 # 0,1,2,3 all of them present 
```
The integer `76` is the first integer that has the same values of `f1` and `f2` for `k = 4`. 
```
f1(76,4) = f2(76,4) = 10032
```
Let's call these kind of numbers, **forgiving numbers**. (Let's continue with the fashion of attributing personality traits to numbers and, of course, an unknown one)
So, `76` is the smallest forgiving number of order `4`.
In the same way, `485` is the smallest forgiving number of order `5`.

Create a function that given an integer `n` and the order `k`, will output the higher and closest forgiving number to `n` of order `k`.

Let's see some examples:
```
find_f1_eq_f2(500,5) == 547
find_f1_eq_f2(1600,6) == 1799
find_f1_eq_f2(14900,7) == 14996
```
If the number `n` is a forgiving itself for a certain order `k`, the function will never output the same value, remember, closest and **higher** than `n`.

For example, `3456`, is a forgiving one of order `4`,
```
find_f1_eq_f2(3456,4) == 3462
```
**Features of the tests:**

* `n` and `k` will be always valid and positive integers.

* A total of 8 fixed tests.

* A total of 150 random tests in the ranges for `n` and `k` given above.

I'll be waiting your awesome solution. :)

Difficulty: introductory

Starter code:

def find_f1_eq_f2(n,k):
	

Solutions:
def find_f1_eq_f2(n,k):
    s = set(range(k))
    while True:
        n += 1
        testn = n
        while True:
            f = set(map(int,str(testn)))
            if f<=s:
                if f==s: return n
                break
            testn += n

def find_f1_eq_f2(n,k):
    s = set(range(k))
    while True:
        n += 1
        new = n
        while True:
            ns = set(map(int, str(new)))
            if ns < s:
                break
            elif ns == s:
                return n
            new += n
    return n


from itertools import count
from string import digits

def f12(n, k):
    valid_digits = set(digits[:k])
    for x in count(n, n):
        s = str(x)
        if valid_digits.issuperset(s):
            return valid_digits.issubset(s)

def find_f1_eq_f2(n, k):
    return next(i for i in count(n + 1) if f12(i, k))

from itertools import count

def find_f1_eq_f2(n, k):
    for x in count(n+1):
        for y in count(x, x):
            if all(map(lambda c: int(c) < k, str(y))):
                if len(set(str(y))) == k: return x
                else: break

from itertools import count

def find_f1_eq_f2(n, k):
    digits = set(map(str, range(k)))
    for n in count(n + 1):
        for m in map(set, map(str, count(n, n))):
            if m <= digits:
                if len(m) == len(digits): return n
                break

def f1(n,k):
    n_i = n
    while True:        
        if all(int(c) < k for c in str(n_i)):            
            return n_i
        n_i += n
    
def f2(n,k):
    n_i = n
    while True:
        if set(str(n_i)) == set(str(d) for d in range(k)):            
            return n_i
        n_i += n

def find_f1_eq_f2(n,k):
    n_i = n + 1
    while True:    
        if f1(n_i,k) == f2(n_i,k):
            return n_i
        n_i += 1    


from itertools import count
def find_f1_eq_f2(n,k):
    is_f1=lambda n,k:max(map(int,str(n)))<k
    is_f2=lambda n,k:set(str(n))==set(map(str,range(0,k)))
    for i in count(n+1):
        for j in count(1):
            f1,f2=is_f1(i*j,k),is_f2(i*j,k)
            if f1^f2:break
            elif f1 and f2:return i

def less_than(n, k):
    return all(int(x) < k for x in str(n))
    
def has_all(n, k):
    s = str(n)
    for i in range(10):
        if i < k and str(i) not in s:
            return False
        if i >= k and str(i) in s:
            return False
    return True
    
def f1(n, k):
    cn = n
    while not less_than(cn, k):
        cn += n
    return cn

def f2(n, k):
    cn = n
    while not has_all(cn, k):
        cn += n
    return cn


def find_f1_eq_f2(n,k):
    n += 1
    while f1(n, k) != f2(n, k):
        n += 1
    return n
    
    


def digits_less_than(n,k):
    for i in str(n):
        if int(i) >= k:
            return False
    return True

def all_digits_less_than(n,d):
    for i in d:
        if i not in str(n):
            return False
    return True

def find_f1_eq_f2(n,k):
    d = '012'
    for i in range(3,k):
        d += str(i)
    m = 0
    i = 0
    while not all_digits_less_than((m+n)*i,d):
        m += 1
        i = 1
        while not digits_less_than((m+n)*i,k):
            i += 1
    return m+n