Almost six years ago, fellow PPCG member steenslag posted the following challenge:
In a standard dice (die) the numbers are arranged so that opposite faces add to seven. Write the shortest possible program in your preferred language which outputs a random throw followed by 9 random tippings. A tipping is a quarter turn of the dice, e.g. if the dice is facing 5, all possible tippings are 1,3,4 and 6.
Example of desired output:
So, now that everybody has completely forgotten about it and the winning answer has long since been accepted, we'll be writing a program to validate the die tipping sequences generated by the submitted solutions. (This makes sense. Just pretend it does.)
Your program or function is given a sequence such as
1532131356. Validate that each consecutive digit is:
- Not equal to the previous digit
- Not equal to 7 minus the previous digit
(You don't have to validate the first digit.)
- Your program must return a truthy value if the input is valid and a falsey value otherwise.
- You can assume that the input consists of only the digits 1-6 and is at least 1 character long. Sequences won't have a fixed length like in steenslag's challenge.
- You can take the input as a string (
"324324"), an array or array-like datastructure (
[1,3,5]) or as multiple arguments (
1353531414 3132124215 4142124136 46 4264626313135414154 6 2642156451212623232354621262412315654626212421451351563264123656353126413154124151545145146535351323 5414142
11 3132124225 6423126354214136312144245354241324231415135454535141512135141323542451231236354513265426114231536245 553141454631 14265411
Opposing side of die
16 42123523545426464236231321 61362462636351 62362462636361