I have a school project, where I have to write a program in c#. I think I'm on the right track but I stuck on this problem.
In this section of the program I have to write a backtracking algorithm. I have classes(English, Physics, Maths etc.) and all the classes last for a specific time. (For example 1h, 2h, 3h, 5h etc.). Also, I have maxClassHours which shows how much time one can spend at school this day.
The algorithm should collect all the possible combinations of the classes which fill this maxClassHours as much as possible.
It's important that I can only sit a given class once! So I can only have one Maths lesson.
For example the maxClassHours is 5 so I can spend 5 hours sitting in different classes.
Let's say I have these classes:
- Maths - 2h
- Physics - 1h
- Music - 2h
- Dance - 5h
- P.E. - 3h
- Geography - 5h
- English - 3h
- French - 1h
- Science - 7h
- Art - 1h
The goal is to find all the possible combinations (using backtrack algorithm) which fills this 5 hours.
I hope it make sense... Thank you for the help.
EDIT: I would like to understand how backtracking algorithm can be applied on this problem.
EDIT2: I tried to work on it for hours, but I couldn't make significant progress, that's why I'm asking for some help...