【问题标题】:{-truncated-} in hackerrankhackerrank 中的 {-truncated-}
【发布时间】:2022-08-16 22:28:57
【问题描述】:

我在hackerrank 中尝试了\"Validating UID Challenge\",其中一个测试用例是:YD780V5355{-truncated-} 在输入中,输出是Valid{-truncated-} 在测试用例3 中。那么在这种情况下,{-truncated-} 的真正含义是什么?字符串的长度只有十。这是我的代码:

def checker(string):
    num_of_up = 0
    num_of_di = 0
    exist = []
    if len(string) == 10: #Exact 10 chars
        if string.isalnum(): #Must be alnum
            for char in string:
                exist.append(char)
            if len(exist) == len(set(exist)): #No duppicated char
                return True
            else:
                return False
        else:
            return False
    else:
        return False
    for item in exist:
        if item.isdigit():
            num_of_di += 1
        elif item.isupper():
            num_of_up += 1
    if num_of_up >= 2 and num_of_di >= 3: #more than 2 uppers and 3 ditgits
        return True
    else:
        return False


UID_lst = []
for num in range(int(input())):
    result = []
    ask = input()
    UID_lst.append(ask)
    for item in UID_lst:
        if checker(item):
            result.append(\"Valid\")
        elif not checker(item):
            result.append(\"Invalid\")
for item in result:
    print(item)

  • 你在哪里看到{-truncated-}?单击您的链接时我没有看到它(我被要求注册)。你的代码与它有什么关系?
  • @mkrieger1 只需单击测试用例 3 并滚动到第 20 行
  • 我不能,我没有注册。

标签: python python-3.x


【解决方案1】:

在 HackerRank 中,{-truncated-} 表示输入/输出超过 20 行,因此剩余的行不打印。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-27
    • 2022-12-27
    • 2021-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多