Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Majority by kaion300
def is_majority(items: list) -> bool:
# your code here
answer = False
if len(items) < 1:
return answer
count_f, count_t = 0, 0
count_f = items.count(False)
count_t = items.count(True)
if count_f < count_t:
answer = True
return answer
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!")
March 29, 2021