softnshare / kata

Code Kata 這個概念是由 The Pragmatic Programmer 的作者之一Dave Thomas提出的, 想要提升自己的coding skill嗎? 歡迎加入這個slack channel, 加入請參考右邊網頁說明
https://softnshare.wordpress.com/slack/kata/
38 stars 4 forks source link

How much water do I need? #25

Open jawayang opened 8 years ago

jawayang commented 8 years ago

https://www.codewars.com/kata/how-much-water-do-i-need/

My washing machine uses L amount of water to wash X amount of clothes. For every 1 unit increase in clothes, the washing machine will use 10% more water to clean (i.e. For X = X + 1, L = L * 110%.

Write a function howMuchWater (JS)/how_much_water (Python) to work out how much water is needed if you have a N amount of clothes. The function will accept 3 parameters - howMuchWater(L, X, N) / how_much_water(L,X,N)

My washing machine is an old model that can only handle double the amount of X. If N > 2X, return 'Too much clothes'. The washing machine also cannot handle any amount of clothes less than X. If that is the case, return 'Not enough clothes'.

The answer should be rounded to the nearest 2 decimal places.

翻譯: 寫出一個 howMuchWater 函式 有三個參數 L , X , N 用來計算洗衣機的用水量 L 是 標準水量 X 是 標準洗衣量 N 是 你要洗的衣服數量 洗衣機最多可以洗 標準量的兩倍衣服,不得超過。 但是最少不能低於標準量 意思就是 每超過一件要需加上總水量的 10% 超過的第二件就是 再加上加了10%後的10%

jawayang commented 8 years ago

PASS