Assume that there are n tyres that could be used by car, tricycle and bicycle. Write a program to accept n tyres and generate all the combinations (i.e. the number) of car(s), tricycle(s) and bicycle(s) that could exhaust the n tyres. Ensure that all the objects have fair share where possible

Consider a combination (c,t,b) with n-4 tyres, if any. Add a car: you get a combination with n tyres. This covers all combinations having at least one car. It remains to generate the combinations without car. Consider all such combinations with n-3 tyres and add a tricycle. This gives all combinations with at least one tricycle. It remains to generate the combinations with only bicycles. There is one combination (0, 0, n//2) if n is even and none if n is odd.

Edited 2 Years Ago by Gribouillis

thanks but can you please help with the program preview

First meditate what Dani wrote at the top of the software development page

Our Software Development forum category encompasses topics related to application programming and software design. When posting programming code, please make sure it is formatted appropriately. Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.

It means that people will help if you post your own python attempts to solve the problem.

Edited 2 Years Ago by Gribouillis

This article has been dead for over six months. Start a new discussion instead.