Assignment 5 Submit Assignment Due Dec 11 by 11:59pm Points 110 Submitting a file upload File Types py Available Nov 21 at 12am – Dec 11 at 11:59pm 21 days Programming Assignment #5: Graph Solution to the Water Container Problem What is the assignment? To implement a function that uses a graph-search approach to produce a “path” that represents a solution to the water container problem. See the following wikipedia page for more information about this problem, which dates back much further than the Die-Hard movie that it appears in 😉 https://en.wikipedia.org/wiki/Water_pouring_puzzle (Links to an external site.) What to hand in? One (and only one) *.py file should be handed in. All your checks, unit tests should be inside of this file. The name of the function in your program should be findWaterContainerPath, and it should except three integer arguments. Note that your program should be able to run at the console/terminal (e.g. $ python your_file.py). If it does not, then the execution portion of the assignment will be 0. What needs to be done? Ultimately, all that needs to be done is to have a function, named findWaterContainerPath, return a list of states that represents a solution to the water container problem. Note that each state can be thought of a vertex on a graph, and the transitions between the states can be thought of as the edges. To successfully implement the function you will need to figure out what all of the possible state transitions (i.e. edges). You’ll then perform a BFS across all of these states; adding a state to your final solution path when it is used (and being sure to not add, or to remove, states that are not on the solution path). Be careful… As with all assignments, do not copy code from the internet, and do not share/copy code directly from others. There are lots of poor implementations of this problem online, so even if you look at some to better understand the problem, be sure that you implement your own so that you can be confident that you understand what each step is doing. Remember, copying/sharing code is a violation of the Student Code of Conduct. If you are found to have been doing this, then the grade for this assignment may be a zero, and a report with the Dean of Students may be filed. Getting Started Use the following code to get started if you like. If, however, you decide not to, be sure that you still name your function “findWaterContainerPath”, and that it accepts the three given arguments. import math import unittest def findWaterContainerPath(a, b, c): “”” DOCUMENTATION FOR THIS FUNCTION “”” starting_state = (0, 0) final_path = list() final_path.append(starting_state) “”” THIS IS WHERE THE REAL WORK FOR THIS ASSIGNMENT WILL BE “”” return final_path “”” ADD ANY OTHER (HELPER) FUNCTIONS THAT ARE NEEDED HERE “”” class TestWaterContainerGraphSearch(unittest.TestCase): def testFindWaterContainerPath(self): “”” INSERT DESCRIPTION OF WHAT THIS TEST IS CHECKING “”” “”” IMPLEMENT YOUR FIRST TEST HERE “”” pass “”” ADD MORE TESTS TO CHECK YOUR FUNCTIONS WORKS FOR OTHER VALUES “”” def main(): capacity_a = input(“Enter the capacity of container A: “) capacity_b = input(“Enter the capacity of container B: “) goal_amount = input(“Enter the goal quantity: “) # ADD SOME TYPE/VALUE CHECKING FOR THE INPUTS (OR INSIDE YOUR FUNCTION) if int(goal_amount) % math.gcd(int(capacity_a), int(capacity_b)) == 0: path = findWaterContainerPath(int(capacity_a), int(capacity_b), int(goal_amount)) else: print(“No solution for containers with these sizes and with this final goal amount”) print(path) # unittest_main() – run all of TestWaterContainerGraphSearch’s methods (i.e. test cases) def unittest_main(): unittest.main() # evaluates to true if run as standalone program if __name__ == ‘__main__’: main() unittest_main() Good luck! Rubric Assignment 5 Rubric Assignment 5 RubricCriteriaRatingsPtsThis criterion is linked to a Learning OutcomeProgram Execution and Output 30.0 to >25.0 ptsGoodProgram ex…
Looking for a solution written from scratch with No plagiarism and No AI?
WHY CHOOSE US?
We deliver quality original papers |
Our experts write quality original papers using academic databases.We dont use AI in our work. We refund your money if AI is detected |
Free revisions |
We offer our clients multiple free revisions just to ensure you get what you want. |
Discounted prices |
All our prices are discounted which makes it affordable to you. Use code FIRST15 to get your discount |
100% originality |
We deliver papers that are written from scratch to deliver 100% originality. Our papers are free from plagiarism and NO similarity.We have ZERO TOLERANCE TO USE OF AI |
On-time delivery |
We will deliver your paper on time even on short notice or short deadline, overnight essay or even an urgent essay |