# JavaScript (ES6), <s>&nbsp;142 ... 122&nbsp;</s> 121 bytes

Expects an array of characters, e.g. `['5','1','2']`. Returns **0** or **1**.

<!-- language-all: lang-javascript -->

    a=>a.map(n=>D=D.map((_,i)=>D['504405076067'[d*6+i>>1]^i],p+=[w=a.length,-w,1,-1][d=D.indexOf(n)]),p=0,D=[...'254316'])|!p

[Try it online!](https://tio.run/##lZLBbsIwDIbvewp2cjNCaZo4nNIT2nWX3bJsimgLnbq0gjI2ae/ehQEaIFBpZEVJ9H@x7N/v9tOuZsuibkauSrM2V61ViQ0/bB04lUzV9O8YvNGC@KsGjISIMJrISE5Apw9yWCQJM6@FofVQ6Y2yYZm5ebOgow1ldMSMTv0nhUuzr6c8cMQQWquITpUOwxBiFJxJMOTnvm5nlVtVZRaW1TwA/bxcN4tvA@Tu@D0PdhyDwckyhAzG40GzXGeX9LynHgVD6KGPBYv76IUH@v0vfaCAm/XIBHKJhyxd9cqYo5Cc@QPcVi9HH9KH2DLH@hMAXpx@tOXqqpNnxhwy55653DqEfgCeWdMNyPiiOdeBrTUS@mTw8yXif0NvqMFb43e5Jzq7tPOScbkftGOg/QU "JavaScript (Node.js) – Try It Online")