2

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.

Semiclassical
  • 18,592
lxhom
  • 121
  • It would make sense to link to the Code Golf problem itself, as well as the Wikipedia article on Code Golf. – TonyK May 14 '23 at 14:02
  • @TonyK true, I even had the link in my clipboard but completely forgot to add it haha – lxhom May 14 '23 at 14:04
  • It may be best to focus on just one function at first. In that case, the challenge is to find something in common between those numbers which map to $-1,0,1$. (I unfortunately don’t see anything nice at a glance.) – Semiclassical May 14 '23 at 17:53
  • My first thought: ignoring the 5 digit ones (easy to check anyway with an if statement) and one other number that gets mapped to zero zero, this is basically a bijection between two order 27 sets. If we were working in the continuous world this would be a degree 27 polynomial, but if you can find a discrete mod space where all the left side numbers are different mod that number it would potentially simplify things. It would have to be mod at least 27, and unfortunately 27 doesnt work since you have 8600 and 8627 but you could code a quick check of the smallest b that does uniquely encode them – Andrew May 15 '23 at 19:57

0 Answers0