diff --git a/Elizabeth/DigitGame/README.md b/Elizabeth/DigitGame/README.md new file mode 100644 index 0000000..7223215 --- /dev/null +++ b/Elizabeth/DigitGame/README.md @@ -0,0 +1,40 @@ +You are given an array of positive integers nums. + +Alice and Bob are playing a game. In the game, Alice can choose either all single-digit numbers or all double-digit numbers from nums, and the rest of the numbers are given to Bob. Alice wins if the sum of her numbers is strictly greater than the sum of Bob's numbers. + +Return true if Alice can win this game, otherwise, return false. + +Example 1: + +Input: nums = [1,2,3,4,10] + +Output: false + +Explanation: + +Alice cannot win by choosing either single-digit or double-digit numbers. + +Example 2: + +Input: nums = [1,2,3,4,5,14] + +Output: true + +Explanation: + +Alice can win by choosing single-digit numbers which have a sum equal to 15. + +Example 3: + +Input: nums = [5,5,5,25] + +Output: true + +Explanation: + +Alice can win by choosing double-digit numbers which have a sum equal to 25. + +Constraints: + +1 <= nums.length <= 100 +1 <= nums[i] <= 99 diff --git a/Elizabeth/DigitGame/digit.py b/Elizabeth/DigitGame/digit.py new file mode 100644 index 0000000..f2797cd --- /dev/null +++ b/Elizabeth/DigitGame/digit.py @@ -0,0 +1,44 @@ +class Solution(object): + def canAliceWin(self, nums): + """ + :type nums: List[int] + :rtype: bool + Elizabeth + Truphena + Risper + """ + #initialize the variables to an empty list + single_digit_nums=[] + double_digit_nums=[] + #condition to add the single digits and double digits to their respective lists + for i in nums: + if 0<=i<=9: + single_digit_nums.append(i)#adds each element between 0 and 9 + + for i in nums: + if 10<=i<=99: + double_digit_nums.append(i)#adds each element between 10 and 99 + #sum of the single and double digits + sum_single_digits=sum(single_digit_nums) + sum_double_digits=sum(double_digit_nums) + #scenario 1 if Alice receives sum of single digits + Alice_single=sum_single_digits + Bob_double=sum_double_digits + #scenario 2 if Alice receives sum of double digits + Alice_double=sum_double_digits + Bob_single=sum_single_digits + #condition if Alice receives more than Bob + if(Alice_single>Bob_double) or (Alice_double>Bob_single): + return True + else: + return False + + print(canAliceWin.__doc__) + +solution=Solution() +#nums = [1,2,3,4,10] +#nums = [1,2,3,4,5,14] +nums = [5,5,5,25] +print(solution.canAliceWin(nums)) + + diff --git a/complexity Analysis/Elizabeth/Monotonic/README.md b/Elizabeth/Monotonic/README.md similarity index 100% rename from complexity Analysis/Elizabeth/Monotonic/README.md rename to Elizabeth/Monotonic/README.md diff --git a/complexity Analysis/Elizabeth/Monotonic/array.py b/Elizabeth/Monotonic/array.py similarity index 100% rename from complexity Analysis/Elizabeth/Monotonic/array.py rename to Elizabeth/Monotonic/array.py