For this challenge, it is preferred that you use Java 8 with no third-party libraries.
Write a Java program that reads in two files (both UTF-8 encoded, see table below) and executes a modified wordsearch algorithm on word-search.txt to find the 10 best scoring words (details on scoring later). The program should then write each of them along with their scores in decreasing order to a file output.txt. Words with equal score should be sorted alphabetically. If there are fewer than 10 words in the entire word-search, print out all of the ones you find. If there are no words, leave output.txt empty. The output file should be in the standard CSV format with two columns: word, and score. Do not include a header row. Please be aware that you will be graded on the performance of your solution as well as its correctness and code quality, so try to make sure it completes in under a minute for any valid inputs.
File, Contents
word-search.txt, N x N grid of lowercase letters (a-z) with 𝑁 <= 100
dictionary.txt, M lines each containing one word of lowercase letters (a-z) with M <= 100,000 and each word being no longer than 100 letters
1.A group of characters is considered a word if they appear in dictionary.txt (make sure to only take into account the letters and not any line break characters at the end)
2.Characters can only be legally grouped to make words if
a.Every consecutive character is located either above, below, to the left, or to the right of the preceding character (the first character can appear anywhere on the grid) see image.
b.Each element of the grid is used at most once (so you cannot loop back on elements you have already used in the same word) see image.
3.The grid is bounded/finite, so you cannot teleport from one edge of the grid to the opposite edge see image.
1.Higher scores are better than lower scores
2.For each letter in the word add 1 point
3.For each time the word changes direction subtract 1 point see image.
The top ten words as located on the word-search are shown in the table below. Letters that belong to only one word on the top-10 are highlighted in orange. Letters that belong to more than one word on the top-10 are highlighted in blue. see image.