mercredi 15 juillet 2020

How to solve a this beginner python problem without loops nor libraries [closed]

Question: connect squares to a row of x cm long. you have small squares of 1 cm long and big squares of 5 cm long. write a function row_maker(small, big, x). The function receives the number of small squares and the number of big squares you have and the length of the row you want. The function returns True if it is possible to create a row with all the squares you have or some of them (it is OK if there is more than enough square as long as you can connect the square to a row of x cm with some of the given squares). The function returns False if there isn't enough square or you just can preform a row of x cm with the given squares. Guidance: You cannot use loops. You cannot use special libraries. My question is: How do you that? I have figured that I need to use the modulo (%) operator but I've failed to solve the problem.

Examples:

row_maker(3, 1, 8)

True

row_maker(3, 1, 9)

False

row_maker(3, 2, 10)

True

Aucun commentaire:

Enregistrer un commentaire