def solution(num: int) -> int:
n = 0
n_set = set()
while True:
n += 1
num_multiply = num * n
for i in list(str(num_multiply)):
n_set.add(i)
if len(n_set) == 10:
break
return n
assert solution(42) == 9
assert solution(1) == 10
assert solution(666) == 11
def solution(num:int)-> int:
'''
假设我们有个概念叫「数字深度」,是指一个非零正整数num总共需要多少个乘数才能从乘积结果中集齐0~9共10个数字。其中,乘数从1开始,依次递增。
例如:输入数字42:
当42 * 1=42,共收集了4,2;
当42 * 2=84,收集8,4,目前共收集到2,4,8;
当42 * 3=126,收集1,2,6,共收集了1,2,4,6,8;
以此类推,最终直到42*9才集齐。
因此数字42的深度是9。
请编写一个函数solution,接收一个目标数num,统计一共需要多少个乘数才能完整收集到0~9数字。
:param num:
:return:
'''
listA = []
number = 1
while True:
new_num = num * number
for i in str(new_num):
if i not in listA:
listA.append(i)
if len(listA) >= 10:
# print(listA)
break
number += 1
return number
assert solution(42) == 9
assert solution(1) == 10
assert solution(66) == 11
def solution(num: int) -> int:
list1 = [i for i in range(0, 10)]
list2 = []
n = 0
while list2 != list1:
n += 1
x = num * n
for j in str(x):
if int(j) not in list2:
list2.append(int(j))
list2.sort()
return n
assert solution(42) == 9
assert solution(1) == 10
assert solution(666) == 11
temp_list = []
deep_count = 0
while len(temp_list) < 10:
deep_count += 1
temp_num = num * deep_count
for i in str(temp_num):
if i not in temp_list:
# if i in temp_list:
# continue
# else:
temp_list.append(i)
return deep_count
def solution(num: int) -> int:
count = 1
num_collect = ""
while True:
for i in str(num*count):
if i not in num_collect:
num_collect += i
if len(num_collect)==10: break
count += 1
return count
def solution1(num: int) -> int:
count = 1
st = ''
num1 = num
while True:
for i in list(str(num)):
if i not in st:
st += i
if len(st) == 10:
break
count += 1
num +=num1
return count
def solution(num: int) -> int:
n = 1
data = {str(i) for i in range(0, 10)}
num_set = set()
while True:
num_str = str(num * n )
num_set.update(num_str)
if data == num_set:
return n
n += 1
assert solution(42) == 9
assert solution(1) == 10
assert solution(666) == 11
def solution(num: int) -> int:
result = set(str(num))
i = 1
while True:
for r in set(str(num * i)):
if r not in result:
result.add(r)
if len(result) == 10:
return i
i += 1
assert solution(42) == 9
assert solution(1) == 10
assert solution(666) == 11