Post History
The squares of a 5 by 5 chessboard are labelled with the letters A to Y in English reading order: A B C D E F G H I J K L M N O P Q R S T U V W X Y Determine whether a string is a knight's ...
#1: Initial revision
5 by 5 knight's tour string validator
The squares of a 5 by 5 chessboard are labelled with the letters A to Y in English reading order: ```txt A B C D E F G H I J K L M N O P Q R S T U V W X Y ``` Determine whether a string is a knight's tour of this board. ## Input - A string of 25 distinct letters from A to Y inclusive. ## Output - An indication of whether this string represents a valid knight's tour on the 5 by 5 chessboard. This may be one of 2 distinct values, or any truthy or falsy value if your language supports that concept. - If using 2 distinct values, you may choose either of them to indicate a valid knight's tour. Specifically, it is permitted to use `false` or a specific falsy output to indicate valid and/or to use `true` or a specific truthy output to indicate invalid. - If using arbitrary truthy and falsy values, so you have more than 2 distinct values for your outputs, you must use truthy to indicate a valid knight's tour, not the other way around. - The string is a valid knight's tour if each consecutive pair of letters is a knight's move apart on the 5 by 5 chessboard. That is, the pair of letters is one of: - Differing by 1 row and 2 columns. - Differing by 2 rows and 1 column. - The first and last letters do not need to be a knight's move apart from each other (if all consecutive pairs are a knight's move apart, it is impossible for the first and last to be, since the board has an odd number of squares). ## Test cases Test cases are in the format `input : output`, with the output being `true` for a valid tour and `false` otherwise. ```txt MJCFQXODGPWTIBKVSHENYRULA : true ALURYNEHSVKBITWPGDOXQFCJM : true IBKVSHENYRULAMJCFQXODGPWT : false URYNEHSVKBITWPGDOXQFCJMAL : false LIBJPWNCFTVSHAOURGDMXQYKE : false NFDGRYKEHQXPJCLWTIAOUSVMB : false ROHKVDTILUCYNGPBXMJSEWAQF : false HEWALSJXBKRODVFQNCYITMPGU : false ``` ## Scoring This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins. > Explanations are optional, but I'm more likely to upvote answers that have one. [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
