Skip to main content
2 of 2
Commonmark migration

05AB1E, 14 bytes

ε78920S>sk}`.S

Returns 1, -1, or 0 for more than; less than; or equal respectively.

Try it online or verify all test cases.

Explanation:

ε              # Loop over the input-array
 78920S>       #  Convert 78920 to a list of digits, and increase each by 1,
               #  resulting in [8,9,10,3,1]
        sk     #  Index this list with the input-number (-1 if not found)
               #   i.e. [1,4] → [4,-1]
          }    # Stop the loop
`              # Put all items of the now mapped list separated onto the stack
 .S            # Take the signum (1 if a>b; -1 if a<b; 0 if a==b)
               #  i.e. 4 and -1 → 1
Kevin Cruijssen
  • 131.5k
  • 13
  • 144
  • 384