0

I have to combine my own school subjects to fit into an assigned schedule for next year. A photo is attached. From every column I need one subject (six total), along with one of each color (and an extra yellow or orange subject). Three subjects should be higher level (HL) and three standard level (SL). I have no idea where to start (excel, python?) and what to do. does anyone have suggestions?

schedule of classes

  • 3
    General logic is easier to do in Python than in Excel. You'll probably want to work with `OpenPyxl`: https://stackoverflow.com/questions/61609377/what-is-the-best-library-in-python-to-deal-with-excel-files but choice of language and libraries depends heavily on what you've done before. Stack Overflow is going to generally prefer 1) that you try to answer the question yourself and ask about specific problems rather than "where do I start?", and 2) you post text versions of code & data rather than screenshots: https://stackoverflow.com/help/how-to-ask – Sarah Messer Jun 30 '22 at 20:09

1 Answers1

1

You can use itertool's combinations. You can change num_per_combos to be how many subjects per combo.

from itertools import combinations

school_subjects = ["math", "science", "history", "geography", "language arts", "Spanish"]

num_per_combos = 3

combos = list(combinations(school_subjects, num_per_combos))

for lists in combos:
    for combo in lists:
        print(combo + " ")
    print("\n")

qiweunvjah
  • 96
  • 7
  • thank you, this is great. how can i rule out combinations, like not being able to have math AND science? – Laurian de Ru Jul 03 '22 at 12:29
  • You could go through all of them, and if they have math and science, you can not print them. For example, you could use a for loop and check that if a combination has math or science in it, that don't print it. – qiweunvjah Jul 05 '22 at 01:34