#Retina, 36 bytes +`(.)\1 ^(?!.*(13|31|24|42|(.).\2)) [Try it here.](http://retina.tryitonline.net/#code=K2AoLilcMQoKXig_IS4qKDEzfDMxfDI0fDQyfCguKS5cMikp&input=MTIzNDEyMjExMTExMg&debug=on) #Retina, 50 bytes A`13|31|24|42|(.)(?!\1)(.)(\2\2)*(\1|\2(?!\1|\2).) I think this works? [Try it here.](http://retina.tryitonline.net/#code=QWAxM3wzMXwyNHw0MnwoLikoPyFcMSkoLikoXDJcMikqKFwxfFwyKD8hXDF8XDIpLik&input=MQoxMjM0CjEyMjEKMzMzMwoxNDMzMzIKMjIyMzQKMjIzNAoyMjIxNAoxMjIxNDQxCjQxMjMzCgoxMwoxMjI0CjEyMQoxMjIyMQo0MzIyMQ&debug=on)