Generation

generate functionSun, 25 Dec 2022

My washing machine uses water amount of water to wash load (in JavaScript and Python) or max_load (in Ruby) amount of clothes. You are given a clothes amount of clothes to wash. For each single item of clothes above the load, the washing machine will use 10% more water (multiplicative) to clean. For example, if the load is 10, the amount of water it requires is 5 and the amount of clothes to wash is 14, then you need 5 * 1.1 ^ (14 - 10) amount of water. Write a function howMuchWater (JS)/how_much_water (Python and Ruby) to work out how much water is needed if you have a clothes amount of clothes. The function will accept 3 arguments: - water, load (or max_loadin Ruby) and clothes.

# 1. how much water does my washing machine use # 2. how much water does my clothes need for washing # 1. 5 litres # 2. (1.1 ^ (14 - 10)) * 5 # 3. 5 * 1.1 ^ 4 # 4. 5 * 1.1 * 1.1 * 1.1 * 1.1 = 7.4074 def how_much_water(water, load, clothes): return (1.1 ** (clothes - load)) * water print(how_much_water(5, 10, 14))

Questions about programming?Chat with your personal AI assistant