Take an integer `n (n >= 0)` and a digit `d (0 <= d <= 9)` as an integer. Square all numbers `k (0 <= k <= n)` between 0 and n. Count the numbers of 
digits `d` used in the writing of all the `k**2`. Call `nb_dig` (or nbDig or ...) the function taking `n` and `d` as parameters and returning this count.

#Examples:
```
n = 10, d = 1, the k*k are 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100
We are using the digit 1 in 1, 16, 81, 100. The total count is then 4.

nb_dig(25, 1):
the numbers of interest are
1, 4, 9, 10, 11, 12, 13, 14, 19, 21 which squared are 1, 16, 81, 100, 121, 144, 169, 196, 361, 441
so there are 11 digits `1` for the squares of numbers between 0 and 25.
```
Note that `121` has twice the digit `1`.

Difficulty: introductory

Starter code:

def nb_dig(n, d):
	

Solutions:
def nb_dig(n, d):
    return sum(str(i*i).count(str(d)) for i in range(n+1))

def nb_dig(n, d):
  return str([n**2 for n in range(n + 1)]).count(str(d))


def nb_dig(n, d):
    return ''.join(str(a ** 2) for a in range(n + 1)).count(str(d))


def nb_dig(n, d):
    
    tot_occur = 0;
    
    for i in range(n+1):
        #print(i**2)
        tot_occur += str(i**2).count(str(d))
        
    return tot_occur

def nb_dig(n, d):
   return ''.join(str(n * n) for n in range(n + 1)).count(str(d))

def nb_dig(n, d):
    return sum([str(x**2).count(str(d)) for x in range(n+1)])

nb_dig = lambda n,d: sum(str(k**2).count(str(d)) for k in range(n+1))

def nb_dig(n, d):
    result = 1 if d == 0 else 0

    for k in range(1, n + 1):
        x = k * k
        while x:
            if x % 10 == d:
                result += 1
            x //= 10

    return result


def nb_dig(n, d):
    string = ''
    count = 0
    
    for i in range(n+1):
        string += str(i*i)
    
    for i in string:
        if i == str(d):
            count += 1

    return count

nb_dig=lambda n,d:sum(str(i**2).count(str(d))for i in range(n+1))

def nb_dig(n, d):
    integers = [str(integer ** 2) for integer in range(n + 1)]
    return sum([digits.count(str(d)) for digits in integers])

def nb_dig(n, d):
  s = str(d)
  return sum(sum(c == s for c in str(k**2)) for k in range(n+1))

def nb_dig(n, d):
    square_list=[str(k**2) for k in range(0,n+1)]
    result=0
    result = "".join(square_list).count(str(d))
    return result

def nb_dig(n, d):
    return sum(str(num**2).count(str(d)) for num in range(n + 1))

def nb_dig(n, d):
    return sum([str(k*k).count(str(d)) for k in range(n + 1)])

def nb_dig(n, d):
    thing=0
    d=str(d)
    num = [str(i**2) for i in range(n+1)]
    for i in num:
        if d in i:          
            thing+=i.count(d)
    return thing

def nb_dig(n, d):
    return sum([1 if str(d) in a else 0 for x in range(n+1) for a in str(x*x)])

def nb_dig(n, d):
    d_count = []
    for n in range(n+1):#  n+1 as python stops one number before n 
        square = str(n ** 2)
        d_count.append(square.count(str(d)))
    return sum(d_count)
        
    # your code


def nb_dig(n, d):
    def ds_in_k(k):
        m, r = divmod(k, 10)
        return int(r == d) + (ds_in_k(m) if m else 0)

    return sum(ds_in_k(k ** 2) for k in range(n + 1))


def nb_dig(n, d):
    l=[]
    for i in range(n+1):
        l.append(str(i**2))
    return ''.join(l).count(str(d))