Link to home
Start Free TrialLog in
Avatar of Arachn1d
Arachn1d

asked on

School Timetable Problem

I am trying to write a programme for a school. Here is the problem: All subejcts are organised into options. A subject can be in any number of options, from one to all of them. All the options are at different times, and I need an algorythma that will take the students chosen options, get the times available from a database of what subject/what option(s), and try and fit them together. Then it needs to tell them if they can fit all their subjects in, and, if so, show them all the possible arrangements for them. If not, it needs to tell them what the conflicts are. Any suggesitons? I am happy to clarify if needed. I don't neccessarily need code, pseudo code will do just fine - I need method.
Avatar of setiawan
setiawan

Arachn1d, I have also make something like you asked (in Java).

Ok, so you want to show all subject into option button, I suggest you to put it into one group for each subject.
so user can't choose 2 same subject.

you can use matrix to check the subject have been chosen, so If the matrix is already filled, then you know there is conflict.
matrix [6][7]
   Mon Tue Wed Thu Fri Sat
 1
 2
 3
 4
 5
 6
 7

  regards

   danny
 
Avatar of Arachn1d

ASKER

Not quite - An option is 2-3 preiods a week - the actual timetable doesnt matter. Also, Subjects amy be available in several options - like english. The student would say they want to enter english, and it would try and sort out all the subjects to fit in together - if they do. If they dont, it would tell them of the conflicts, if there is more than one way to fit them all together, it will show them all the options.
I've worked out most of this problem, all I need to know now is how to produce every possible re-arrangement of x digits (x could be from 2 to anything) - eg 123,132,213,231,312,321 for 3 digits. So I need a loop that will alter an array to the latest rearrangement of digits so I can work on them. Help!
This should do it for you. In my test I had a text box for the input and a listbox for the combination output.

Private Sub Command1_Click()
    List1.Clear
    Call doit("", Text1.Text)
End Sub
Private Sub doit(ByVal st As String, ByVal en As String)
'This is a recursive routine that will create all combinations
'of a given string.
    Dim i As Long           'Counter to loop though remaining charchters
    Dim startStr As String  'Part of string already found
    Dim endStr As String    'Part of string left to be disected
   
    'Loop for all charchters left to be disected
    For i = 1 To Len(en)
        'Grab 1 charchter from endString and put it on startString
        startStr = st & Mid(en, i, 1)
       
        'Recalculate endString
        endStr = Left(en, i - 1) & Mid(en, i + 1)
       
        If endStr = "" Then 'Ran out of charchters to disect
            List1.AddItem startStr
        Else
            Call doit(startStr, endStr) 'More charchters to disect, try again.
        End If
    Next i
End Sub
Just change the List1.AddItem list to store startStr into an array for the combinations you want.
Thanks very much, I found this answer perfect for my situation (and a very clever implementation as well!) - If you can submit that as an answer, I'll accept it with thanks!
ASKER CERTIFIED SOLUTION
Avatar of ggilman
ggilman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
A! A+! A++ :)