Challenge inspiration was this that I saw somewhere:
The word "nun" is just the letter n doing a cartwheel
Your challenge is to take a string and determine if it is the first letter doing a cartwheel.
A string is a letter doing a cartwheel if:
- The first letter is the same as the last letter. (The letter can't land on its head.)
- The string alternates between cartwheeling letters every one character.
The cartwheeling letters are
q. Note that
w together are not cartwheeling letters, and neither are
- You will take a string using any of our standard input methods.
- You will output a truthy value if the string is a cartwheeling letter, and a falsy value if it is not. Output can be done using any standard output methods.
- Only lowercase cartwheel letters
qneed to be handled.
- You may assume that input is never empty.
- A one-character string is not a valid cartwheel.
Input -> Output nun -> truthy nunun -> truthy nunununu -> falsy wmw -> truthy wmwun -> falsy bqbqbqbqbqb -> truthy v^v^v -> falsy AVAVA -> falsy OOO -> falsy ununununu -> truthy nunwmwnun -> falsy nun unun -> falsy nunwmw -> falsy nnuunnuunnuu -> falsy nwnwnwnwn -> falsy m -> falsy nunuuunun -> falsy
As with code-golf, the shortest code (in each language) wins!