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

Recommended Answers

All 4 Replies

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.

Thanks but can you please help with the program preview

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.