2 of 7
added a shorter version
Arnauld
  • 190.7k
  • 20
  • 173
  • 632

JavaScript (ES6), 58 bytes

Expects a base-4 encoded integer with 123 for DMB, e.g. MBDBMDD = \$2313211_4\$ (\$11749\$ in decimal). Returns 1 for dyadic, 2 for monadic, 3 for both, or 0 for neither.

f=(n,d=1,q=n&2,m=2)=>n>3?f(n>>2,d&n,n&m&&q,m^3):q&n|d&n!=m

Try it online!


JavaScript (ES6), 67 bytes

Expects an integer with 123 for MDB. Returns 1 for monadic, 2 for dyadic, 3 for both, or 0 for neither.

f=(n,d=2,q=n&1,m=1)=>n>3?f(n/10|0,d&=n%=10,n&m&&q,m^3):q&n|d*(n!=m)

Try it online!

Arnauld
  • 190.7k
  • 20
  • 173
  • 632