Advertisement
Badella

Dr CooCoo's Pack Of Hens

May 5th, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. from itertools import permutations
  2. class Solution:
  3.     def Met(self, eggs, goal):
  4.         # write your method here
  5.         if sum(eggs) < goal:
  6.             return False
  7.         elif min(eggs) > goal:
  8.             return False
  9.         else:
  10.             eggs[:] = [x for x in eggs if x <= goal]
  11.             for i in range(1,len(eggs)):
  12.                 for j in list(permutations(eggs,i)):
  13.                     if sum(j) == goal :
  14.                         return True
  15.             return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement