Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Unlimited Attempts Allowed Details Scenario: Your significant other has developed a habit of sending you a list of items to pick up at the grocery
Unlimited Attempts Allowed Details Scenario: Your significant other has developed a habit of sending you a list of items to pick up at the grocery store before each of your date nights. While cute at first, the chore of trudging all around the store is growing tiresome. To save your relationship, you devise a plan to get all the items on the list as quickly as possible. Since you prefer to traverse the aisles of the store in a fixed order (you are a creature of habit), you resolve to re-order the list such that you would encounter each item sequentially as you traverse the store in your preferred manner. Genius! You even took it a step further and made a special trip to the store to white down the sequence of all the items you see while traversing the store in your preferred way. You call this your "canonical" ordering. Your assignment: Write a program called HoneyDo which will reorder a list of groceries based on a provided canonical ordering. Your program must read a list of groceries from a text file called "groceries.txt" wherein each item to be purchased is listed on its own line of the file (shown below). Your program should also read a separate file called "canonical.txt" which lists the sequence of all the grocery store items that you might encounter in their "canonical" ordering (also shown below). The output of your program is printed to the screen and shows both the original grocery list as well as the canonically re-ordered list (again, also shown below). Example of groceries.txt: milk bread onions cereal ice cream toothpaste apples frozen pizza Example of canonical.txt The output of the program is below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started