In this assignment, you will implement a solution for generating an optimal weekly timetable for a school. The program should create a schedule based on classes, subjects, teachers, and period requirements while satisfying various constraints.
A school needs an automated way to create their weekly timetable. They have several classes of students, a set of subjects that need to be taught, and teachers who are qualified to teach specific subjects. The goal is to create a valid timetable that satisfies all the requirements and constraints.
- Each class needs to study a specific set of subjects.
- Each subject requires a specific number of periods per week for each class.
- Each teacher can only teach specific subjects (based on their qualifications).
- Teachers cannot teach more than one class simultaneously.
- Each day consists of exactly 6 periods, 5 days per week (Monday through Friday).
- Each period is 1 hour long.
- All classes must have all their required periods scheduled within the week.
The program should generate a complete timetable for all classes that satisfies all constraints, showing:
- Which teacher teaches which subject to which class during each period
- A clear visualization of the weekly schedule for each class and teacher
This assignment has no external dependencies and requires only Python 3.6 or higher.
- Fork the repository
- Open the repository in GitHub Codespaces
- No additional setup is required - you can start coding immediately
- To run the program:
python main.py
generate_timetable(): Create a valid timetable meeting all constraintsdisplay_timetable(): Show the timetable in a readable formatvalidate_timetable(): Verify the timetable satisfies all constraints
The provided main.py file contains the input data structure:
- Classes (e.g., "Class 6A", "Class 6B", etc.)
- Subjects (Mathematics, Science, English, etc.)
- Teachers and their teaching capabilities
- Period requirements for each class and subject
Do not modify these input data structures.
Your solution must check that:
- All classes get the required number of periods for each subject
- Teachers only teach subjects they're qualified for
- No teacher is scheduled to teach two classes at the same time
Your timetable display should be clear and organized, showing:
- Day and period information
- Subject and teacher for each class during each period
To test your implementation:
- Run the program:
python main.py - The program will:
- Generate a timetable
- Validate the timetable
- Display the timetable (if valid)
If successful, you should see a complete timetable that satisfies all constraints.
Your solution will be evaluated based on:
- Correctness: Does the generated timetable satisfy all constraints?
- Completeness: Are all required periods scheduled for all classes?
- Code quality: Is the code well-structured, commented, and readable?
- Output clarity: Is the timetable presented in a clear, understandable format?
- Make sure your code runs without errors and produces valid timetables
- Include comments explaining your implementation details
- Add your details into id.json
- Submit your solution by pushing your changes to the forked repository in GitHub Codespaces