Is it possible to find a short function for a table of points where the result of the function is always -1, 0 or 1?

49 Views Asked by At

For context, I am trying to solve a Code golf problem, where you need to solve a problem with a program, where the program with the shortest source code wins. There is a pretty hard problem on there where you have to map Unicode arrows like ↖⇒↳ etc. to their direction, like ⇘: [1, -1], or ←: [-1, 0].

Trying to do this systematically is pretty hard, because Unicode is kind of a mess and the Arrows block is super inconsistent, for example ↳ and ↲ should be the other way around, and a few like ⥀ are also included that resolve to [0,0].

Essentially, I have this table, and need to find f1 and f2: (x is the respective Unicode code point, so the number assigned to each symbol. All numbers in base 10)

x       f1(x)   f2(x)
8601    -1      -1
8626    -1      -1
8665    -1      -1
8592    -1      0
8656    -1      0
8678    -1      0
8598    -1      1
8624    -1      1
8662    -1      1
8595    0       -1
8659    0       -1
8681    0       -1
8596    0       0
8597    0       0
8660    0       0
8661    0       0
10560   0       0
10561   0       0
8593    0       1
8657    0       1
8679    0       1
8600    1       -1
8627    1       -1
8664    1       -1
8594    1       0
8658    1       0
8680    1       0
8599    1       1
8625    1       1
8663    1       1

The functions should also be as short as possible (so something like ((x+a) modulo b)-c would be better than ax⁶+bx⁵+cx⁴+dx³+ex²+fx+g). I tried brute-forcing a few functions, but have not had any success yet.

Also, the fact that there are only three possible values for f(x) should make this easier, right? I'm a CS person and not that good at math, but my intuition says that should be doable, but I could also be very wrong.

Is this possible? If yes, how?

EDIT: My goal is using JS, so stuff like if conditions would also work if it makes the result shorter.