Thread: How to make a course sorter and optimizer

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    4

    How to make a course sorter and optimizer

    Hi,
    First post, I've posted to reddit and stackexchange with no avail. So basically, I want to create some code that takes input from the user. First the program should know the completed classes with the ability to add new classes once the semester ends. I type in a class and it crosschecks the pre-requistes with my completed classes. If I meet the pre-requites it will add the class to the schedule for the semester and checks it off in my future classes. Then it calculates the amount of time I have left by dividing my credits completed and added by my total credits by 15 per semester. It should be able to give me the best optimized schedule by listing every variation at the end. I don't even know where to start, or even know how to make the database of completed classes. I was hoping someone could help me out how to make this.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Is this for homework? I ask because I can imagine students wanting to write this for their own advantage, but it also sounds like it could be an academic assignment with certain constraints (e.g., you must use C, you cannot use external libraries, etc)
    Last edited by laserlight; 04-30-2019 at 05:45 PM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2019
    Posts
    4
    Nope! I'm on medical leave from university as a physics major. I want to create this program because I'm double majoring and tired of repeatedly doing this on excel. I have the classes on a .csv file and trying to make some code to bring it into vs code and sort it into an array. I'm also intending this to go public for free on my own website when I finish this over my summer. If you'd like some proof I've been posting around as CarterTheSpaceman on reddit. Thanks!

  4. #4
    Registered User
    Join Date
    Apr 2019
    Posts
    4
    Oh also, I'm constrained to C because that's what my engineering program forced me to learn. I'm thinking about using SQL to create a database for the classes and possibly switching over to python but I haven't learned that yet.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I would suggest two approaches:
    • Pre-populate a relational database (e.g., using SQLite) with the classes (perhaps including credits), their pre-requisites, and completed classes (so at least three tables for now). You can then run a query to determine if you can sign up for a candidate class because you have met the pre-requisites. When you actually sign up for the class, you just insert into the completed classes table and you're good to go for the next semester (although you'll have to update the pre-requisites table as and when the faculty change them).
    • Provide the data in some human-readable file format, e.g., a JSON document consisting of a structure containing a list and a structure: the list just lists the class codes for the classes completed, the structure maps class codes to lists of pre-requisites for the respective classes (or you could involve a structure for each class and hence record the credits). You then parse the JSON (using a library) into a dynamic array and some kind of map structure (e.g., using a hash table or balanced binary tree... again libraries may be useful).


    If you use Python the latter would be somewhat easier than with C because of built-in library support.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    Apr 2019
    Posts
    4
    Quote Originally Posted by laserlight View Post
    I would suggest two approaches:
    • Pre-populate a relational database (e.g., using SQLite) with the classes (perhaps including credits), their pre-requisites, and completed classes (so at least three tables for now). You can then run a query to determine if you can sign up for a candidate class because you have met the pre-requisites. When you actually sign up for the class, you just insert into the completed classes table and you're good to go for the next semester (although you'll have to update the pre-requisites table as and when the faculty change them).


    I'm probably going to end up doing this as it seems easier. Any ideas on how to code it? I have no literal idea

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Note that that will only help you with "If I meet the pre-requites it will add the class to the schedule for the semester and checks it off in my future classes", and maybe computing the credits remaining. Do you know SQL?

    In the long run, you may also need to handle schedule conflicts, e.g., two classes meeting the pre-requisites in the same semester having lectures in the same time slot.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alphabetical sorter
    By GSISONYA in forum C++ Programming
    Replies: 2
    Last Post: 05-14-2015, 04:22 AM
  2. Problems with the Compiler Optimizer?
    By KansaiRobot in forum C Programming
    Replies: 4
    Last Post: 05-08-2012, 10:08 AM
  3. Replies: 2
    Last Post: 04-27-2011, 04:14 PM
  4. DLL / EXE optimizer
    By audinue in forum Tech Board
    Replies: 3
    Last Post: 01-22-2010, 11:34 PM
  5. Can't Find Bug in basic MP3 Sorter
    By trickeastcs in forum C++ Programming
    Replies: 12
    Last Post: 12-14-2007, 05:31 PM

Tags for this Thread