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 def how_much_water(L,X,N) 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.

def how_much_water(water, load, clothes): if load >= clothes: return water else: return water * 1.1 ** (clothes - load) how_much_water(5, 10, 14)

Questions about programming?Chat with your personal AI assistant