프로그래밍 문제/[Python] CheckIO
[CheckIO] Majority
UltraLowTemp-Physics
2021. 3. 11. 06:15
Problem: py.checkio.org/en/mission/majority/
My Solution:
def is_majority(items: list) -> bool:
# your code here
return True if items.count(True) > items.count(False) else False
if __name__ == '__main__':
print("Example:")
print(is_majority([True, True, False, True, False]))
# These "asserts" are used for self-checking and not for an auto-testing
assert is_majority([True, True, False, True, False]) == True
assert is_majority([True, True, False]) == True
assert is_majority([True, True, False, False]) == False
assert is_majority([True, True, False, False, False]) == False
assert is_majority([False]) == False
assert is_majority([True]) == True
assert is_majority([]) == False
print("Coding complete? Click 'Check' to earn cool rewards!")