2025-09-13 15:36:12 -04:00
|
|
|
"""
|
|
|
|
|
name: Nicholas Tamassia
|
|
|
|
|
Honor Code and Acknowledgments:
|
|
|
|
|
This work complies with the JMU Honor Code.
|
|
|
|
|
Comments here on your code and submission.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# All modules for CS 412 must include a main method that allows it
|
|
|
|
|
# to imported and invoked from other python scripts
|
|
|
|
|
def main():
|
|
|
|
|
|
2025-09-18 08:10:15 -04:00
|
|
|
sounds: list[str] = sys.stdin.readline().strip().split()
|
2025-09-13 15:36:12 -04:00
|
|
|
num_animals: int = int(sys.stdin.readline().strip())
|
|
|
|
|
|
|
|
|
|
fox_sounds: list[str] = []
|
|
|
|
|
animals_ecountered: list[str] = []
|
|
|
|
|
|
2025-09-18 08:10:15 -04:00
|
|
|
animal_sounds: list[tuple[str, str]] = []
|
|
|
|
|
|
|
|
|
|
for line in sys.stdin.readlines()[:num_animals]:
|
|
|
|
|
split_line = line.strip().split(" goes ")
|
|
|
|
|
animal_sounds.append((split_line[0], split_line[1]))
|
2025-09-13 15:36:12 -04:00
|
|
|
|
|
|
|
|
for sound in sounds:
|
|
|
|
|
animal_found = False
|
|
|
|
|
for animal, animal_sound in animal_sounds:
|
|
|
|
|
if sound == animal_sound:
|
|
|
|
|
animal_found = True
|
|
|
|
|
if animal not in animals_ecountered:
|
|
|
|
|
animals_ecountered.append(animal)
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if not animal_found:
|
|
|
|
|
fox_sounds.append(sound)
|
|
|
|
|
|
|
|
|
|
print("what the fox says: " + " ".join(fox_sounds))
|
|
|
|
|
print("also heard: " + " ".join(animals_ecountered))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|