Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CS Games 2023 Team A Application
PLEASE FILL IN THE FOLLOWING!
Full Name
Calder Johnson
UWindsor Email
[email protected]
Application Form
Briefly explain how your solution works and how to run it
This is an amendment to my previous submission, a bug was fixed PLEASE MAKE SURE TO TEST THE CURRENT VERSION OF THE SOLUTION :)
My solution is written in python and should be ran using an up-to-date python 3 interpreter. It accepts input with the format specified by the problem, and it is case sensitive (though making it case insensitive would be the small matter of updating the driver code).
My solution makes use of a wrapper function and an inner recursive function which does most of the work to validate the words. First, I initialize a result boolean variable which I default to false. Then, I use a pair of for loops to locate every instance of the first letter in the word we're trying to find in the grid. I call my inner function on each instance of that letter.
My inner function accepts the grid, a word, and the row and column of the letter in question. Each time, if its cell is on the correct next letter, it will call itself on every adjacent cell, sending the grid with the letter just checked removed to prevent repeats, and sending the word with the first letter removed so that the next letter can be checked. I always validate the case that the function is called on invalid indexes (doing nothing in that case). When the function receives an empty word, its base case is reached as every letter must have been found and the word is present, returning true. After calling on each adjacent cell, I replace the letter so as to not modify the grid for other branches of the search.