35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
'''
|
|
There is a game called Mario Adventures, consisting of n levels. Bill and his friend Bob are addicted to the game. Each of them wants to pass the whole game.
|
|
Bill can complete certain levels on his own and Bob can complete certain levels on his own. If they combine their skills, can they complete all levels together?
|
|
|
|
Given an integer n - the total number of levels, list of integers bill_levels - the number of levels Bill can complete and Another list of integers
|
|
bob_levels - the number of levels Bob can complete. Return string I become the hero! If they can complete all levels together, in the opposite case Oh, no!
|
|
The castle is locked!
|
|
|
|
Example 1
|
|
Input:
|
|
n = 5; bill_levels = [3, 1, 2, 3]; bob_levels = [2, 2, 4]
|
|
Output:
|
|
Oh, no! The castle is locked!
|
|
'''
|
|
|
|
from typing import List
|
|
|
|
class Solution(object):
|
|
def solve(self, n:int, bill_levels: List[int], bob_levels: List[int]) -> str:
|
|
print(f"n: {n}, bill_levels: {bill_levels} bob_levels: {bob_levels}")
|
|
total_levels = set(bill_levels + bob_levels)
|
|
print(f"Total levels combined: {total_levels}")
|
|
if len(total_levels) == n:
|
|
return "I become the hero!"
|
|
else:
|
|
return "Oh, no! The castle is locked!"
|
|
|
|
# Example usage
|
|
if __name__ == "__main__":
|
|
solution = Solution()
|
|
n = 5
|
|
bill_levels = [3, 1, 2, 3]
|
|
bob_levels = [2, 2, 4]
|
|
result = solution.solve(n, bill_levels, bob_levels)
|
|
print(result) # Output: Oh, no! The castle is locked! |