Recently, me and a couple of my friends decided to play some cards, and one of them suggested the game 'Irish Snap', which was the inspiration for this challenge. However, I later learnt that the game has a lot of different rules that you can play with, some of which are listed here. The rules that are in this challenge aren't currently listed on that page, hence the name, 'Variant Rules'
Given an array of 3 cards, output a truthy or falsey value depending on if they make a valid snap in a game of Irish snap.
The input will be an array of 3 numbers, ranging from 1-13 inclusive, with 1 representing an ace, 11 representing a jack, 12 representing a queen and 13 representing a king. The input can be in any order of top, middle, bottom.
The 4 different criteria for if cards make an Irish snap are:
- The top and middle cards are the same
- The top and middle cards have a difference of one
- The top and bottom cards are the same
- The top and bottom cards have a difference of one
If any of these criteria are met, you must output a truthy value. As well as this, for the two criteria that require the cards to have a difference of one, it 'wraps around', meaning that an ace and a king are considered to have a difference of one, and vice versa.
Input (Bottom, Middle, Top) -> Output 1 13 7 -> False 1 4 13 -> True 9 3 6 -> False 8 9 7 -> True 2 6 5 -> True 12 5 11 -> True 10 4 8 -> False 12 13 7 -> False 9 7 10 -> True 7 3 1 -> False 4 2 3 -> True