Setup
Write a function that determines whether a string is a valid guess in a Boggle board, as per the rules of Boggle. Your function should take two arguments (2D array and string) and return true
or false
as to whether the string found in the array follows Boggle rules.
Valid guesses are strings that can be formed by connecting adjacent letters in any direction without using any previously used letters.
Example
{ {'I','L','A','W'}, {'B','N','G','E'}, {'I','U','A','O'}, {'A','S','R','L'} }
In this Boggle board, the words "BINGO", "ILNBIA", and "LINGO" would be valid guesses, while "BUNGIE", "BINS", and "SINUS" would not be. You do not have to test whether the string is a valid word or not, only if it is a valid guess.
Test
{ {'E','A','R','A'}, {'N','L','E','C'}, {'I','A','I','S'}, {'B','Y','O','R'} }
Good luck, have fun coding~!
This challenge comes from 747823 on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!
Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!
Top comments (1)
JavaScript - not pretty and will think about how to make more elegant 😊 . I can move to codepen or something if this is way to big of a blurb