#JavaScript (ES6), 55 bytes Takes input as `(a)(b)` with \$a\le b\$. Returns \$0\$ (valid), \$1\$ (ended) or \$3\$ (invalid). <!-- language-all: lang-javascript --> a=>b=>3*(a<0|a>29|b>30|b>21&(a-=b)*a>4)|b>20&a*a>1|b>29 [Try it online!](https://tio.run/##dZHLCsIwEEX3fsWsbEao5NGFBZt/mT6USEiLFUHov9ckulATFxmGc5nJCbnQnebuaqZb6cZ@WE/NSo1uG612jI58IS3rpdWK@yLFllHZtLgjXWEAfEu@F6Gt125082iHvR3PrBhcP/QFbj7hiQFHJgX@YiGz2CMmVYoPyBRPcf3GX7y4kzU9sPlmrAXjYLL0wKwYpDujL8/6@pP1/fMMmYgZF9VSlTIMAIg61Sk99FHmEvBZiCAXBV8/JTORjAtVbkpxfNU0quLCKv0bwYN8rLg@AQ "JavaScript (Node.js) – Try It Online")