| University | University of Auckland (UOA) |
| Subject | Computer Science |
Task
Write a program that constructs either the shortest word chain connecting a pair of words from a given list or a chain of a specified length.
The input for this task consists of a file (to be read from stdin) that contains a list of word chain problems (one per line, no blank lines) followed by a blank line, followed by a list of words that can be used (all lower case letters, not necessarily all of the same length). The output, to stdout, should be the (or a) solution to each problem.
If an impossible problem is given, the output should echo the input for that problem, followed by a space and the word impossible. A problem consists either of two words or two words followed by a number. In the first case, the shortest possible chain between them is to be found and in the second case, a chain of exactly the given length (the length of a chain is the total number of words in the chain).
For example with this input file:
cat  cup
cap cup 4
cat  dog 3
emu kea
flu  covid
car cat
cat
cup
dog
cap
cut
elephant
The output file could be:
cat cut cup
cap cat cut cup
cat dog 3 impossible
emu kea impossible
flu covid impossible
car cat impossible
Stuck! Do not Know Assessment Answers?
Hire NZ Native Experts 24/7.
Are you seeking coursework help on computer science in New Zealand? Then just take help from coursework experts online. With the help of professionals, the students can bring an A+ grade to your programming homework assignment without taking any headache.
- MGMT902 Enterprise and Information Systems Assignment 2: Cyber Security Governance and ICT Strategy Report | AIS
- Managing for Sustainability Assessment 1 Report and Academic Poster 2026 | Otago Polytechnic
- SCIE707 Research Project Proposal and Cultural Safety & Engagement Statement Assessment 2026 | AUT
- CA ANZ Tax (NZ) Assessment 1 Case Study Term 4 2026: Hume & Hearth Ceramics Limited
- BILD 361 Project Management Assessment 2, 2026: BIM Residential Project Management Plan | VUW
- SARC 321 Construction Assignment 3 2026: Envelope, Gantt Chart and Site Logistics Plan | Victoria University of Wellington
- LAWCOMM 782 Trade Mark Practice Letter of Advice 2026 | University of Auckland
- LAWCOMM 795 Copyright and Design Final Assessment 2026 | University of Auckland
- BSNS5202 Advanced Business Information Assessment 3, 2026 | Open Polytechnic
- BSNS5203 Applied Business Technologies Assessment 2, 2026 | Open Polytechnic

