【每日一题1201】颠簸前行

:woman_mage: 邓布利多的老爷车已经破败不堪了,最近经常需要维修,一旦路上颠簸次数超过15次就直接趴窝了。这天有急事要出门,而且很不行路途崎岖不平,让我们帮他预告下这趟行程车子能否经得住考验。

给定一个字符串表示路况,其中"_"符号表示平路,"n"表示地面隆起,请编写一个函数,返回车子是否会趴窝情况。

示例:
输入:"______n___n_",返回:True
输入:"_nnnnnnn_n__n______nn__nn_nnn", 返回:False

题目难度:简单
题目来源:codewar: Bumps in the Road

def solution(road: str) -> bool:
    # your code

assert solution("n") is True
assert solution("______n___n_") is True
assert solution("nnnnnnnnnnnnnnnnnnnnn") is False
assert solution("_nnnnnnn_n__n______nn__nn_nnn") is False
def solution(road: str) -> bool:
    return road.count('n') < 15

assert solution("n") is True
assert solution("______n___n_") is True
assert solution("nnnnnnnnnnnnnnnnnnnnn") is False
assert solution("_nnnnnnn_n__n______nn__nn_nnn") is False
def solution(road: str) -> bool:
    if road.count('n') > 15:
        return False
    else:
        return True
    

assert solution("n") is True
assert solution("______n___n_") is True
assert solution("nnnnnnnnnnnnnnnnnnnnn") is False
assert solution("_nnnnnnn_n__n______nn__nn_nnn") is False
def solution(road: str) -> bool:
    return False if road.count('n')>15 else True

assert solution("n") is True
assert solution("______n___n_") is True
assert solution("nnnnnnnnnnnnnnnnnnnnn") is False
assert solution("_nnnnnnn_n__n______nn__nn_nnn") is False
def solution(road: str) -> bool:
    return road.count("n")<15
def solution(road: str) -> bool:
    if road.count('n') > 15:
        return False
    else:
        return True



    assert solution("n") is True
    assert solution("______n___n_") is True
    assert solution("nnnnnnnnnnnnnnnnnnnnn") is False
    assert solution("_nnnnnnn_n__n______nn__nn_nnn") is False

我这算是顶级理解吗???

def lieNest(roads):
# road =
# road.spli(roads)
roads.split()
level = roads.count(’_’)
slope = roads.count(‘n’)
if slope > 15:
print(‘车子趴窝啦!!!’)
else:
print(‘一切正常’)

def solution(road: str) → bool:
s = len(road.split(‘n’))
if s >= 16:
return False
else:
return True

def solution(road: str) -> bool:
    return road.count('n')<15
def solution(road: str) -> bool:
    if road.count('n') >15:
        return False
    else:
        return True

assert solution("n") is True
assert solution("______n___n_") is True
assert solution("nnnnnnnnnnnnnnnnnnnnn") is False
assert solution("_nnnnnnn_n__n______nn__nn_nnn") is False