|
|
|
|
|
|
m*****k 发帖数: 731 | 1 Please read all the instructions before you start writing the code for this
programming exercise. You have 1-hour to submit your solution (so please
keep track of your time).
(Exercise)
Write a program to read a file and
a) print the number of occurrences of each word
b) print the largest word that starts and ends with the same character.
(Notes)
Anything that is separated by space - “ “ should be treated as a word.
Fullstops - “.” do not count as a part of the word and don’t qualify as a
word to be counted as separately.
(How to approach the problem)
Do not worry about the code syntax, we know this is a free text editor
Do not copy paste from any place outside of this test browser window, we
want to see how you approach the problem
If something is unclear, write your assumption as a part of the code
comments so that it doesn't stop you from finishing this assignment.
Using the right approach is more important than finishing the code (Write
clean, well designed, testable, efficient code)
Use any programming language you like (we prefer if you use java)
(Eg)
Data.txt:
McMurdo Station is a U.S. Antarctic research center on the south tip of Ross
Island, which is in the New Zealand claimed Ross Dependency on the shore of
McMurdo Sound in Antarctica. It is operated by the United States through
the United States Antarctic Program, a branch of the National Science
Foundation. The station is the largest community in Antarctica, capable of
supporting up to 1,258 residents,[1] and serves as the United States
Antarctic science facility. All personnel and cargo going to or coming from
Amundsen–Scott South Pole Station first pass through McMurdo.
Result:
Word -> Count
---------------
McMurdo -> 2
station -> 3
is -> 5
….
….
Longest word that ends and starts with the same character:
------------------------------------------------------------
Antarctica |
|
|
|
|
|
|