-
Notifications
You must be signed in to change notification settings - Fork 0
/
hydrate.py
31 lines (30 loc) · 952 Bytes
/
hydrate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Description: https://www.codewars.com/kata/5aee86c5783bb432cd000018/python
# Short task summary:
##Welcome to the Codewars Bar!
##
##Codewars Bar recommends you drink 1 glass of water per standard drink so you're not hungover tomorrow morning.
##
##Your fellow coders have bought you several drinks tonight in the form of a string. Return a string suggesting how many glasses of water you should drink to not be hungover.
##Example parties:
##Input 0:
##
##"1 beer"
##Output 0:
##
##"1 glass of water"
##Explaination 0:
##
##You drank one standard drink
##Input 1:
##
##"1 shot, 5 beers, 2 shots, 1 glass of wine, 1 beer"
##Output 1:
##
##"10 glasses of water"
##Explaination 1:
##
##You drank ten standard drinks
# My solution:
def hydrate(drink_string):
glasses = str(sum([int(x) for x in drink_string if x.isdigit()]))
return glasses + " glasses of water" if glasses != "1" else glasses + " glass of water"