【每日一题20220314】神秘数字

:woman_mage:给定一个数字列表,请找出0~9之间哪些数字尚未出现,按升序排列。

示例:
输入: [12, 34, 56, 78]
输出:“09”
解释:因为12345678都出现过,唯独0和9尚未出现。

题目难度:简单
题目来源:CodeWars:Filter unused digits

def solution(nums: list) -> str:
    # your code here

assert solution([12, 34, 56, 78]) == "09"
assert solution([2015, 8, 26]) == "3479"
assert solution([276, 575]) == "013489"
assert solution([864, 896, 744]) == "01235"
def solution(nums: list) -> str:
    import re
    res_str = '0123456789'
    for n in nums:
        num_str = str(n)
        for i in num_str:
            res_str = re.sub(i, '', res_str)
    return res_str

def solution(li:list):
return ‘’.join([str(i) if str(i) not in ‘’.join(li) else ‘’ for i in range(10)

def solution(nums: list) -> str:
    return ''.join(str(i) for i in range(10) if str(i) not in str(nums))

def solution(list):
target = [str(x) for x in range(10)]
current = ‘’.join([str(x) for x in list])
result = [x for x in target if x not in current]
return ‘’.join(result)

if name == ‘main’:
datas = [[12, 34, 56, 78],[2015, 8, 26],[276, 575], [864, 896, 744]]
for data in datas:
result = solution(data)
print(result)

def solution(nums: list) -> str:
    str1 = '0123456789'
    s = ''.join([str(x) for x in nums])
    result = []
    for x in str1:
        if x not in s:
            result.append(x)
    return ''.join(result)


assert solution([12, 34, 56, 78]) == "09"
assert solution([2015, 8, 26]) == "3479"
assert solution([276, 575]) == "013489"
assert solution([864, 896, 744]) == "01235"
    def solution(nums: list) -> str:
        str_nums = str(nums)
        return_str = ""
        for i in range(10):
            if str(i) not in str_nums:
                return_str += str(i)
        return return_str
def mystic_num(num_list):
    st = '0123456789'
    st_list = [str(i) for i in num_list]
    st_num = "".join(st_list)
    not_in_str_list = [i for i in st if i not in st_num]
    not_in_str = "".join(not_in_str_list)
    return not_in_str


assert mystic_num([45,67,12,2,3,9]) == "08"
assert mystic_num([45,67,12,8]) == "039"
def solution(nums: list) -> str:
    return ''.join(str(i) for i in range(10) if str(i) not in str(nums))


assert solution([12, 34, 56, 78]) == "09"
assert solution([2015, 8, 26]) == "3479"
assert solution([276, 575]) == "013489"
assert solution([864, 896, 744]) == "01235"```
def solution(nums: list) -> str:
    # 0314 神秘数字
    res = ''
    for i in range(10):
        if str(i) not in str(nums):
            res += str(i)
    print(res)
    return res

assert solution([12, 34, 56, 78]) == "09"
assert solution([2015, 8, 26]) == "3479"
assert solution([276, 575]) == "013489"
assert solution([864, 896, 744]) == "01235"
def solution(nums: list) -> str:
    return ''.join([str(i) for i in range(10) if
                    i not in list(set([int(j) for j in ''.join([str(nums[i]) for i in range(len(nums))])]))])


assert solution([12, 34, 56, 78]) == "09"
assert solution([2015, 8, 26]) == "3479"
assert solution([276, 575]) == "013489"
assert solution([864, 896, 744]) == "01235"