Please note: this is a restricted-source challenge — see details below!
Each natural number \$n\$ has 10 faces: its decimal representations in bases \$1\$ through to \$10\$. For example, the 10 faces of \$12\$ are \$[111111111111, 1100, 110, 30, 22, 20, 15, 14, 13, 12]\$, and the 10 faces of \$4\$ are \$[1111, 100, 11, 10, 4, 4, 4, 4, 4, 4]\$
We can then say that two numbers face each other \$n\$ times if they share \$n\$ faces, counting duplicate faces repeatedly. For instance \$12\$ and \$4\$ do not share a face as no number is in both of their list of faces, whereas \$6\$ and \$11\$ do:
- \$\text{faces}(6) = [111111, 110, 20, 12, 11, 10, 6, 6, 6, 6]\$
- \$\text{faces}(11) = [11111111111, 1011, 102, 23, 21, 15, 14, 13, 12, 11]\$
Both \$11\$ and \$12\$ are in both lists, so \$6\$ and \$11\$ share 2 faces, and so face each other twice.
Finally, we will say that any pair of numbers has a closeness, which is defined as the number of times the two numbers face each other. So far we already have:
- \$\text{closeness}(12, 4) = 0\$
- \$\text{closeness}(6, 11) = 2\$
Notice that \$\text{closeness}(1, 1)\$ is \$100\$ because all 100 possible pairs of \$1\$'s faces are equal i.e. duplicate faces count multiple times.
Your task is, given two natural numbers \$a\$ and \$b\$, output \$\text{closeness}(a, b)\$. You may take input and output in any convenient method or format.
However, your program must only consist of pairs of characters that face each other. In order to determine if a pair of characters face each other, take their code points \$(m, n)\$ in whatever code page you are using to score your program, then, if \$\text{closeness}(m, n) \ne 0\$, then that pair of characters faces each other and can be in your program. This applies to all overlapping pairs in your program. So if your code is abcd
, then ab
, bc
and cd
must all be pairs that face each other.
You may use any pre-existing code page to score your answer, but it must have existed before this challenge was posted.
For instance, none of the pairs of letters in print
(pr
, ri
, in
and nt
) face each other, so your code cannot contain any of those pairs of characters. However, all the pairs in (p b>
((p
, p
, b
and b>
) do face each other, so your code may contain them. Here is a newline-separated list of printable ASCII pairs that face each other for reference, this (Thanks to @Kevin Cruijssen) is a list of all pairs of integers between \$0\$ and \$255\$ which face each other, and this is a Jelly program which verifies that a given string complies with the rules, according to Unicode encoding. It does take 10-15 seconds to run, so be patient with it.
This is code-golf, so the shortest code in bytes wins
Test cases
a, b => closeness(a, b)
24, 35 => 1
10, 15 => 0
50, 11 => 0
18, 12 => 3
16, 15 => 2
1, 1 => 100
12, 10 => 5
30, 18 => 2
6, 6 => 22
20, 4 => 0
3, 35 => 0
23, 3 => 0
Here is a list of \$\text{closeness}(a, b)\$ for all pairs \$\{(a, b) \:|\: 1 \le a \le 50, 1 \le b \le 50\}\$, where the \$n\$-th element of the \$m\$-th row is the result for \$\text{closeness}(m, n)\$:
[100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 66, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 2, 52, 2, 2, 2, 3, 2, 2, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
[0, 2, 2, 40, 2, 2, 2, 2, 3, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]
[0, 2, 2, 2, 30, 3, 3, 3, 3, 4, 2, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,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