# Letterss of Natac
In a game I just made up that doesn’t have anything to do with any other game that you may or may not have played, you collect resources on each turn and then use those resources to build things like roads, settlements and cities. If you would like to try other kata about this game, they can be found **[here](https://www.codewars.com/collections/59e6938afc3c49005900011f)**
## Task
This kata asks you to implement a time efficient version of the function `play_if_enough(hand, play)` , which takes as input a `hand`, the resources you have (a string of letters representing the resources you have), and a `play`, (a string of letters representing the resources required to build a certain game object), and returns a tuple (list in r) of a boolean value, corresponding to whether you have enough resources, and your hand. If you had enough to build the object, the returned hand is your resources minus those you used to build the object. If not, it is your original hand (the one passed to the function).  
For example, if it takes 3 ore and 2 grain to build a city, `play` is `”ooogg”`. If `hand` is `”ooooogggssbbb”`, then `play_if_enough(hand, play)` returns `(True, “oogssbbb”)`. 
## Examples
```python
play_if_enough("ooooogggssbbb", "ooogg")  => (True, "oogssbbb")
play_if_enough("oogssbbb", "bwsg")        => (False, "oogssbbb")
play_if_enough("", "bw")                  => (False, "")
play_if_enough("abcdefghij", "aa")        => (False, "abcdefghij")
```
## Notes: 
1. The order of resources in your hand (or play) is not relevant. You can shuffle your hand any way you'd like, so long as you have the same number of each resource.
2. There are 26 different resources, each represented by a lower case letter a-z, so a valid hand is a string of lower case letters.
3. A valid play is a string of any number of lower case letters.
4. You do not have to test for whether a hand or play is valid. 
5. A hand can be empty, but a play can't. In the event a hand is empty, you don't have the cards to play, so return `(False, "")`, in the correct data structure for your language, see example 4 above.
6. Tests include hand sizes of up to 150000 elements and play sizes up to 10000 elements.
def play_if_enough(hand, play):
    p=[hand.count(i)-play.count(i) for i in sorted(set(list(play)))]
    d=all(x>=0 for x in p)
    h=[i*hand.count(i) for i in sorted(set(list(hand))) if play.count(i)==0]
    h_p=[i*(hand.count(i)-play.count(i)) for i in sorted(set(list(play)))]
    return (d,''.join(h+h_p)) if d is True else (d,hand)
def play_if_enough(hand, play):
    p=[hand.count(i)-play.count(i) for i in sorted(set(list(play)))]
    d=all(x>=0 for x in p)
    h=[i*hand.count(i) for i in sorted(set(list(hand))) if play.count(i)==0]
    h_p=[i*(hand.count(i)-play.count(i)) for i in sorted(set(list(play)))]
    return (d,''.join(h+h_p)) if d is True else (d,hand)