Coding 1: What the Fox Says
This is a fairly easy warmup coding homework designed to get you used to the mechanics of the questions/homework assignments for this class.
Remember when this went viral? Ylvis - The Fox (What Does The Fox Say?) [Official music video HD]
The Problem
Motivated by solving the ancient mystery you are going to figure out exactly what the fox says from a transcript of a recording of animal sounds from the forest. You are working with a team of scientists who have already figured out what sounds all of the other animals make. Your task is to filter out the known forest sounds to determine once and for all, what does the fox say?
Input
The input consists of one line of forest noises given as a series of words separated by spaces. The next line of input is a number n describing how many known animal sounds there are. The next n lines describe n animal sounds given in the format "[animal name] goes [noise]".
Output
The output consists of two lines, the first is the list of sounds in order uttered by our shy, sly fox. The last line lists the names of any other animals heard in the recording in the order in which they were first heard with no animal repeated (the scientists asked you for this for research purposes). The first line should be formatted "what the fox says: [whatever the fox did say]". The last line should be formatted "also heard: [space separated list of animals also heard in order they were heard]". There should be NO spaces following the last thing the fox says and the last animal name (just a new line character).
| Sample Input | Sample Output |
toot woof wa ow ow ow pa blub blub pa toot pa blub pa pa ow pow toot |
what the fox says: wa pa pa pa pa pa pow |
Your Task
Your task is to implement two versions of the program solving the code above. The first version (cs412_foxsays_list.py) should only use list data structures. The second version (cs412_foxsays_dict.py) must utilize maps/dictionaries and set data structures to speed up your code as much as possible.
Gradescope is checking for dictionaries to NOT be in the first version and for a dictionary to be in the second version.
Test Cases
Example input/output:
Test #1:
- Input file: foxsays_t1_in.txt
- Output file: foxsays_t1_exp.txt
Test #2:
- Input file: foxsays_t2_in.txt
- Output file: foxsays_t2_exp.txt
There is a unittest file that you can download (foxsays_unittest.py) and use to test your program. See the programming guidelines (located here in canvas: CS412_CodingAssignmentGuidelines.pdf) which specifies how to structure your program and also how to use the unittest file.
You can use a diff program to compare your output to these examples before submitting to Gradescope.
Code Templates for this class
Your python code must utilize this template: cs412_code_template.py
Turning it in
Turn in these two files (cs412_foxsays_list.py and cs412_foxsays_dict.py) to Gradescope. Here are some larger test files to see how fast your program runs:
Leaderboard/Speed Check
Your code will be checked for speed and a leaderboard posted within Gradescope.
Acknowledgments
Problem from Kattis are used under their educational license.