Wednesday, February 22, 2023
HomeSoftware EngineeringFiguring out Integer Depth in Python

Figuring out Integer Depth in Python

The problem

The depth of an integer n is outlined to be what number of multiples of n it’s essential to compute earlier than all 10 digits have appeared at the very least as soon as in some a number of.


let see n=42

A number of         worth         digits     remark
42*1              42            2,4 
42*2              84             8         4 existed
42*3              126           1,6        2 existed
42*4              168            -         all existed
42*5              210            0         2,1 existed
42*6              252            5         2 existed
42*7              294            9         2,4 existed
42*8              336            3         6 existed 
42*9              378            7         3,8 existed

Wanting on the above desk underneath digits column yow will discover all of the digits from “ to 9, Therefore it required 9 multiples of 42 to get all of the digits. So the depth of 42 is 9. Write a operate named computeDepth which computes the depth of its integer argument. Solely optimistic numbers higher than zero might be handed as an enter.

The answer in Python code

Possibility 1:

def compute_depth(n):
    i = 0
    digits = set()
    whereas len(digits) < 10:
        i += 1
        digits.replace(str(n * i))
    return i

Possibility 2:

def compute_depth(n):
    s, i = set(str(n)), 1
    whereas len(s) < 10:
        i += 1
        s |= set(str(n*i))
    return i

Possibility 3:

from itertools import depend

def compute_depth(n):
    discovered = set()
    replace = discovered.replace
    return subsequent(i for i,x in enumerate(depend(n, n), 1) if replace(str(x)) or len(discovered) == 10)

Check circumstances to validate our resolution"Fundamental exams")


Please enter your comment!
Please enter your name here

Most Popular

Recent Comments

situs slot gacor provider terbaik agen toto slot terpercaya 2023 agen toto togel terpercaya 2023 situs toto togel pasaran resmi terbaik bandar toto macau pasaran resmi toto togel bandar toto slot gacor 4d 2023 bo togel online pasaran terlengkap sepanjang masa bo toto slot terlengkap sepanjang masa situs toto togel 2023 bet 100 perak daftar toto slot dan toto togel 2023 bermain toto togel dengan bet hanya 100 perak daftar toto slot bonus new member terpercaya bermain toto slot pelayanan 24 jam nonstop agen slot gacor 4d hadiah terbesar bandar toto slot provider terbaik toto slot gacor 4d hingga toto togel toto togel pasaran resmi terpercaya bo togel online terbaik 2023 agen togel online terbesar 2023 situs togel online terpercaya 2023 bo togel online paling resmi 2023 toto togel pasaran togel hongkong resmi situs slot online pasti gacor agen slot online anti rungkad bo slot online deposit tanpa potongan situs toto togel dan toto slot bonus new member situs toto slot gacor 4d bo toto slot gacor 4d bo toto slot gacor dari toto togel 4d bo toto slot 4d terpercaya bo toto slot terpercaya toto macau resmi dari toto togel 4d agen togel terbesar dan situs toto slot terpercaya bandar toto togel dan slot online 2023 bo slot gacor terbaik sepanjang masa winsortoto winsortoto bo toto togel situs toto situs toto togel terpercaya situs toto slot terpercaya situs slot gacor 4d terbaik sepanjang masa agen toto togel dan situs toto slot terpercaya situs toto togel dan agen toto slot terpercaya bandar toto togel tersedia pasaran toto macau resmi agen toto togel bet 100 perak deposit 10rb ltdtoto