funchydrate(_input:String)->String{letnumber=input.split(separator:.init(" ")).map{$0.filter{cinc.isNumber}}.compactMap{Int($0)}.reduce(into:0){$0+=$1}return"\(number) glass\(number>1?"es":"") of water"}hydrate("1 beer")// 1 glass of waterhydrate("2 glasses of wine and 1 shot")// 3 glasses of waterhydrate("1 shot, 5 beers, 2 shots, 1 glass of wine, 1 beer")// 10 glasses of water
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My swift solution :