[Kata] Clojure - Day 30

Responsible Drinking

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

"1 beer"  =>  "1 glass of water"
"1 shot, 5 beers and 1 glass of wine"  =>  "7 glasses of water"

Solution

 (ns hydrate)
(defn hydrate [drink-string]
  (def glasses (apply + (map #(Integer/parseInt (str %)) (filter #(Character/isDigit %) drink-string))))
 (str glasses (if (= glasses 1) " glass of water" " glasses of water"))
)

<<:  [2020铁人赛] Day29 - 切换身分Impersonation

>>:  Day 29 - 从大学肄业,联成电脑,到 Microsoft MVP 得奖,从零开始的软件工程师

[Day15] CSV Injection(Formula Injection)

前言 写完一半了,洒花 你的使用的Sheet Application安全吗? 正文 概念 CSV是一...

[Day10] swift & kotlin 实作篇!(1) 开发工具与环境安装

前言 终於把swift & kotlin的基本语言都介绍完了 这些基本概念有了之後 要开始愉...

二、教你怎麽看source code,找到核心程序码 ep.22:Deeplab的model 部署

文章说明 文章分段 文章说明 deeplab的简单介绍、於我的意义 ep.1 tensorflow的...

Day30 - 终於完赛的心得感言

参赛动机 老实说,今年其实没有打算要参赛,打算装死度过 刚好身边有朋友要转职,鼓励对方说可以参加铁人...