<aside> 💡 The course materials for this class are actually really comprehensive so a lot of what’s below is just a summary of stuff that’s there + some additional resources I found.

I worked on Task 1 and Task 2 at the same time and turned them in together, per my mentor’s recommendation. Task 1 is a paper where you’ll basically brainstorm your project, Task 2 is completing the project and a paper reflecting on its completion and what you’d do next time.

There are no explicit instructions to back up your project to Github but I’d highly recommend you do so as someone who ended up corrupting my project files when I was almost done and had to start over.

The walkthrough is structured in the order I completed everything and I highlight when I complete specific rubric requirements for each task as I go. If you’re going to complete one task at a time try using cmd(or ctrl) + f to segment each task, or another walkthrough may be better for you.

</aside>

COURSE PREP
Get Set Up for Python
Download PyCharm IDE (IntelliJ and XCode will also work, I just wanted the experience with a new IDE)
Download Python
Download these course materials from Course Search :

Look over these files then read the Project Summary in the next box to get an understanding of the project. | | Project Summary You’re creating a delivery route where you’ll split 40 packages between two drivers and three trucks. You can use 1, 2, or 3 trucks as long as they drive less than 140 miles combined. Picking up and dropping off packages happens instantaneously and there is no stopping for gas. The drivers can leave the hub at 8am and can return to the hub at any time to reload or park.

Each truck can carry a maximum of 16 packages at a time and goes at an average speed of 18mph. Your delivery company (WGUPS) plans to expand in the future, so keep scalability in mind.

Some packages have special constraints, which can be found in the WGUPS Package File document under Special Notes. A few notes on the special notes:

Keep The Complete DSA Course in Python handy. It’s a great reference for both tasks if you need to look anything up.

Use the Algorithms for the Traveling Salesman Problem article, The Complete DSA Course in Python, and Zybooks to explore algorithm options for the project. Make sure the algorithm is self-adjusting, meaning it makes decisions based on the input and operations placed on it. There is a good definition of self-adjusting algorithms in the pdf at Course Search → “Task Directions Summary” → Section A: Algorithm Selection (page 4) (heads up, this document is outdated from the current rubric requirements). | | Helpful Reddit Quote: ”I made an appointment with my instructor, Sidney Rubey…He suggested thinking of this project from an object-oriented Java point of view. That's when it really clicked. When I was looking at the projects on GitHub, none of them were using object classes. They were using arrays and hash maps for every little thing, when instead, these things could be attributes of a class object. My project consists of 261 lines of code…less than half of the lines of code of the projects I saw online.” | | *Make sure that you’re keeping track of any code snippets or information that you take from elsewhere and use in your project or papers. You’ll need to cite them at the end.

You may also want to push to Git in case of errors to be safe but there’s no requirement to do so.* |

| TASK 2 : REQUIREMENT A | Create and Populate Hash Table | | --- | | NOTE You can not use a dictionary. | | TIP Write comments explaining everything in your code as you go to save time once we get to that requirement later.

Resources: **Python Comments | | Create Table Open your IDE and set up your project. Create a Package class and create a hash table with an add/insert function. You’re probably going to want to put a str function in the class for printing later. The hash table needs to be self-adjusting. Self-adjusting = the structure makes decisions when acted upon (resizing, re-ordering the data, etc.) Look at the “Task Directions Summary” course document in section D: Data Structure for tips on this — the code needed to be adjusted slightly to work for me, mine was a hybrid of the instructor’s version and the version from the video linked below.

Make sure you have a hash function either inside the insert function or as its own function that’s called within the insert function.

Resources: Webinar 1 in the Course Creating a Hash Map Using Lists | | Import Data Open the WGUPS Package File. Delete the header rows, the empty columns, and the logo. Export to CSV file. Drag/drop this new CSV file into your project folder (directory shown in IDE next to project name). | | Read File Read the packages file, slice the data and define the variables. Then create a Package class object of the variables you need to insert and use your insert function to add them to your hash table.

Print your hash table instance to make sure you meet the requirement. Close the file.

Resources: Webinar 2 in the Course Reading CSV Files |

| TASK 1 : REQUIREMENTS B, B1, C6, C7 | Explain Self-Adjusting Data Structure | | --- | | Requirement B This one is a freebie since they specify that we have to use a hash table. Just state that here. Explain how the data structure overall is self-adjusting and how it is used to store date in general. You will be specific to your data structure in the next requirement. | | Requirement B1 Explain how you arranged your hash table to store the requested data elements. Talk about how it uses the package ID to insert the other information. Discuss how your table handles collisions here. Not anywhere else, do it here. My PA was returned for not having it here even though it’s not in the rubric and I mentioned chaining in Req B. 🙃  | | Requirement C6 Describe 2+ strengths and weaknesses of using the form of hash table you implemented. I used two intro sentences followed by bullet points here.

Resources: Pros and Cons of Data Structures | | Requirement C7 Identify which variable you used as the key for your hash table and why it was the best choice out of the listed variables.

Resources: Zybooks 6.1 |

| TASK 2 : REQUIREMENT B | Create Look-Up Function | | --- | | Basically another freebie. I just used and cited a mixture of the code from the Resources below. You can return the package data any way you want to (as multiple variables or an object - with headings or not).

Resources: Webinar 1 in the Course Creating a Hash Map Using Lists |

| TASK 1 : REQUIREMENTS A, C1, C2, C3, C4, C5 | Explain Algorithm, Logic, and Efficiency | | --- | | Requirement A Name the algorithm you’ll use to find the truck routes. Explain how it works and how it can meet the requirements. It needs to be a specific, recognized name of an algorithm like the ones mentioned below.

Resources: Algorithm Details ”How to Dijkstra” Course Webinar 2-Opt and Nearest Neighbor Walkthroughs (Course Search) | | Requirement C1 Write out the logic of your algorithm in 4-5 pseudocode statements. This is only for your truck route algorithm, not the entire project.

Resources: How to Write Pseudocode Python Pseudocode Pseudocode Example (Algorithm Overview Template - Course Tips → Supplemental Resources) Project Implementation Steps document (Course Search) | | Requirement C2 List all hardware, languages, IDE, OS, etc. necessary to implement your pseudocode. Just literally list what you’re using while working on your project and what it’s for. Hardware = your computer model, Language = Python 3, OS = your computer’s OS, IDE = Pycharm, ETC. = anything extra that may be necessary for your solution if you’re doing something fancy..probably nothing | | Requirement C3 List the space-time complexity for each major section of your program and the overall complexity of your solution. This is a good time to plan out how you’ll structure the rest of your project. Find one of the implementation guides in the course resources and use that to get an idea of what needs to be done. Use the sections from there to fill in this section of the paper and maybe add some comments into your project to guide you moving forward.

Tips:

Resources: Algorithm Overview Template - Course Tips → Supplemental Resources Big O Cheat Sheet | | Requirement C4 Explain how the self-adjusting portions of the solution will allow it to accommodate a growing number of packages. Explain how any other part of your solution (if any) would limit the solution from being able to do so. | | Requirement C5 Efficiency = time complexity, a program is efficient if its complexity is polynomial time or lower. Maintainability = other developers can understand, update, and maintain it. Explain how your solution is both maintainable and efficient and how it could be more m&e. |

| TASK 2 : REQUIREMENTS C, C1, C2 | Write the Program and Finalize Comments | | --- | | NOTE: In this step you’ll finish the rest of your project and everything (minus the interface) should be functional once you finish this section.

Make sure you have an outline for what you plan to do beforehand or you’re going to waste a lot of time. There’s many ways to do everything, and the “Implementation Steps” documents in Course Search are super helpful if they match your algorithm, but here’s what I did: | | Get Distances and Addresses Data Add the distances csv to your project and open the file like you did for the packages. You’re allowed to edit the csv prior to importing your data to transpose the data to the empty cells (mirroring the distances). I didn’t and chose to add the functionality in my code when looking up distances instead. Think something like “if distance from here to there is present, return distance..else return distance from there to here”.

You’ll want to put the data into some kind of data structure or multiple data structures that allow you to find the index for the distance you’re trying to find (2d array/list, hash map, etc.). You can also use a dictionary here, just not for the package hash table.

You’ll also want to get a list or array of your addresses or location names so you can easily reference them later in your algorithm. In old walkthroughs you may see mention of an address csv file. That’s no longer available, just grab this from the distances csv.

Resources: WGUPS Distance Table Matrix_2-Opt (Course Search) | | Create Truck Instances Create a Truck class and three truck objects. As attributes and functions you want to take care of all of the parameters and “jobs” related to the trucks (when they leave, how many packages they can hold, which packages they’re taking, their route, their driver, etc.) | | Load Trucks You’re allowed to do this manually (should look something like packages.truck1 = [1, 2, 3] or truck.add_packages(1, 2, 3)) or you can create an algorithm for this. Either way, make sure you account for the Special Notes in the Packages csv file.

Here’s how I went about adding this functionality to my code:

  1. Write a comment block or open a word document and write out the following things to get organized:

  2. Then write out pseudocode for conditional (if/then) statements that will determine where packages go if a certain constraint is met - and then put these conditional statements in order. For example, if we had three constraints that were 1. must be on truck 1, 2. must arrive at 9am, and 3. _ package must go with _ and _, it would make the most sense to:

Other students also mentioned other methods for loading trucks, like a mixture of conditional and the nearest neighbor algorithm on the whole package list, then chopping the list at the truck maximum amount. | | Implement Your Truck Route Algorithm Use the resources below and Google to help you implement your algorithm.

Resources: Algorithm Details ”How to Dijkstra” Course Webinar 2-Opt and Nearest Neighbor Walkthroughs (Course Search) | | Get Delivery Times You’ll want to create time objects to track how long it will take your package to travel on the truck before delivery. You should have the times the trucks leave already as a truck object attribute and the time the package is due in the package object attributes. It’s on time if the departure time + the time it takes to deliver is less than the time it’s due right?

Don’t implement any solutions that require external tools like pandas. Your evaluator won’t have it downloaded.

Resources: DateTime Format Convert to String Verifying Packages on Time (think if all(), return routes..else fix it (swap packages, rerun algo, etc.) |

| TASK 2 : REQUIREMENTS D, E, D1, D2, D3 | Create Interface + Add Screenshots | | --- | | Create User Interface It doesn’t have to be graphical, you can just create a series of print/input commands to the command line. You can put it in main.py or elsewhere.

Your interface will be created with a bunch of print statements and conditional loops. Think print welcome message → input = action to take → if action = 1, ask for time, if action = 2, print report….and so on. You can present the information however you want but need to be able to show the following:

My interface had 3 reports:

Each page had options to go back to the main menu or exit the program to make it easy to navigate.

The separate truck summary page was helpful in answering some of the PA questions about how you can verify packages are on specific trucks and such but wasn’t required. You can pass with the first two reports as long as you also include an option for the user to input a time.

Tip: Add in a few while loops and error messages to validate the time input.

Resources: Python How-To: Working With Dates And Times In Python - DEV Community Terminal Welcome Screen Add colour to text in python (ozzmaker.com) Validate Time Input Formatting 1 Formatting 2 Formatting 3 | | Comments Process = what’s happening here. Flow = how it’s happening (the steps). Add process and flow comments throughout your code for EVERYTHING. The current version of the rubric doesn’t require comments specifying the complexity of everything but I added it just in case.

**Resources: Style Guide | | Screenshots Every section doesn’t ask for screenshots but I added them for most requirements. If you File > Export to HTML in Pycharm it’ll allow you to get screenshots of longer sections with nice formatting. I broke up a lot of my screenshots into the natural code sections to make everything readable and added captions to the images for understanding.

Here’s what I added screenshot of: A - package class code, close up of insert function from package hash table, line of code where I created the hash table instance, lines of code where I created the package objects and inserted them into the hash table B - lookup function code from hash table, code showing how the lookup function can be called, output stack showing what the lookup function call returns C - a snippet of my sorting algorithm code, creation of truck instances, code where trucks were loaded (for load in loads[1]: truck.packages.append(load)), code for my 3-opt algorithm C1 - line 1 of main showing requested info with the main.py header at the top C2 - one process block comment, one flow in-line comment D - two different screenshots showing interface throughout different user actions (minus the report — basically the functionality of all the if/else and input areas) D1, D2, D3 - view all packages report at a time within the range E - truck summary page (has departure time, driver, loaded packages, location at the time, miles traveled at the time, and “route complete” if true for each truck, then total miles traveled at time for all trucks F2 and H - screenshots of the interface showing the requirement is met (more on this in next section), my screenshots here are not readable without expanding since I put these sections inside a table but all the other ones are and this is probably considered in the “professional communication” requirement |

| TASK 2 : REQUIREMENTS F1, F2, F3, F3A, G, H, H1, H1A, I, J | Reflections + Final Touches | | --- | | Requirement F1 Add 2+ strengths of your algorithm. Everything that was required of it is a strength: self-adjusting, maintainable, efficient | | Requirement F2 I added a table here to show that all requirements were met using the algorithm. Columns were Requirement, Verification Steps, Algorithm Impact, Final Result. The requirements are that the trucks collectively travel under 140 miles, all packages are delivered on time, all delivery constraints are met, and you’ve shown the progress of trucks and packages in the interface.

If the project was to make a pb+j sandwich and the algorithm is a knife, I would have filled this in like this: Requirement: Create a sandwich with peanut butter and jelly Verification Steps: take sandwich out of bag, place on a plate, remove the top piece of bread, confirm that there is peanut butter and jelly inside Knife Impact: The knife was used to spread the jelly and peanut butter onto the bread slices Final Result: picture of sandwich after following verification steps, “peanut butter and jelly are included in the sandwich”

You don’t have to have a table. You can include this information in paragraph form. Make sure you include how the algorithm specifically made the requirement happen. For screenshots I clipped the part of the interface that showed the specific requirement, so for the requirement that all the truck travel under 140 miles, I have a screenshot from my interface that says “TOTAL MILES TRAVELED BY 7:03PM: 100.3” | | Requirement F3 List two other algorithms, it’s not mentioned but I added a summary of how each other algorithm works. | | Requirement F3A Explain how each other algorithm is different from the one you chose. I chose two overarching differences and explained how my algorithm functions in that regard, then how the other two function differently in the regard.

Example using subjects: ”The subject I chose is math. Math is a subject that uses mainly numbers and variables to calculate things. English is different than Math because it uses letters rather than numbers and variables and its focus in on language and expression rather than calculation. Physical Education is different than math because it’s related to body movement and sports and is physical instead of intellectual.” | | Requirement G What would you do differently if you did the project again and why? You can’t use the algorithms in F. This can deal with how you sorted your packages before loading, the data structures your used (minus the package hash table), how you would lower mileage, sending the trucks at different times or using the drivers differently, etc. | | Requirement H Same as F2 but you’ll explain specifically how the hash table contributed to meeting the requirements, so the hash table would be the knife for the pb+j (from example in F2). | | Requirement H1 + H1A same concept as F3 and F3A, but now focusing on the package hash table and other ways you could have stored the packages and still met the requirements.

Resources: Data Structures | | Requirements I + J APA Citation Generator Language Tool |