# Please note: this is arestricted-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 , 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 1, 0, 1, 0, 0, 2, 1, 0, 0, 0, 10, 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, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 10, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 10, 0, 0]
[0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 10, 0]
[0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 1, 0, 0, 2, 0, 2, 0, 0, 2, 0, 0, 0, 1, 2, 0, 0, 0, 0, 10]

• Deleted Sandbox post. Also, I'd appreciate any and all feedback, including any explanations behind any downvotes, if you'd like to voice your concerns. After all, I can only improve. – caird coinheringaahing Nov 26 '19 at 4:11

# Jelly, 37 27 bytes

b ȷ2½RJÞ©¤µ€$p /Aµ~E)UCCTL  Try it online! A monadic link that takes a pair of integers as its argument and returns the closeness as an integer. When run as a full program implicitly prints the result. Note encoding is using the Jelly codepage (available at Jelly); byte count and neighbouring pair closeness both reflect this. This TIO link has a footer that breaks the program itself into overlapping pairs, converts each to the codepoints in the Jelly code page and then calls the code itself on each pair. The code section actually isn’t used; it actually evaluates the copy of the code seen in the argument. A (possibly) minimal implementation of the closeness algorithm without the code restriction would be 9 bytes bⱮ€⁵ŒpE€S, so there’s effectively a 18 byte cost to ensuring all pairs are close. Test using version of OP’s link Verification of closeness of every pair between 1 and 30 using the data from the question (will print 1 if all match). ## Explanation Code explained below. I’ve omitted the spaces since they are ignored here. I’ve indicated steps that are only there because of the code restriction in square brackets. Note many of these aren’t no-ops, but they do not change the final result. $              | [Following as a monad]
µ€               | - For each integer in input:
b       ¤                 | - Convert to each of the following bases:
ȷ2                       |   - 100
½                      |   - Square root
R                     |   - Range
JÞ©                  |   [- Sort by sequence along each list]
p/            | Reduce using Cartesian product
A           | [Absolute]
µ          | Start a new monadic chain
)       | For each sublist:
~         | [- Bitwise not]
E        | - Check whether equal
U      | [Reverse]
C     | [1 minus this]
C    | [1 minus this]
T   | Convert to list of indices for each positive entry
L  | Length


Finally, here’s a handy TIO link to generate the pairs of integers 0-255 as well as characters in any codepage. The link as provided will give the pairs for Jelly, but you can change the argument for any other code page provided the characters exist in Unicode. They should be provided as a single string from 0 to 255. Example for 05AB1E, without the preceding integer bit (just characters).

• Still getting zero for the output of the OP's code face tester. Just testing I've got the right paste, "b :.CU¶U )$ñþ⁵+938ZAµ$ p /Aµ~E)U=1+0BS". Looks right. – ouflak Nov 26 '19 at 14:15
• @ouflak are you using the Jelly codepage? – Nick Kennedy Nov 26 '19 at 14:15
• shrug I'm just dropping it into the OP's link. – ouflak Nov 26 '19 at 14:17
• @ouflak That link of OP uses Unicode codepoints instead of the Jelly codepage. – Kevin Cruijssen Nov 26 '19 at 14:24
• Together we got a 26 :) – Jonathan Allan Nov 27 '19 at 20:58

# 05AB1E, 595251 43 bytes

εηθA~TLTBB™ÿćV9yΓиΓdJRzzªh}¯ðð~V¢ 2
D//wO


Ok, that took a while.. Did it by trial-and-error, but I have the feeling that creating a brute-force program would have been more time-efficient now that I'm finally done.. But, it works!

-9 bytes thanks to @Grimy.

Uses the 05AB1E encoding; the characters map to these 0..255 values.

Explanation:

The base program I started with was 12 bytes, which was either εTLBćy×š}¢O or vyTLBćy×š}¢O.

Here an explanation of the first base program (second is similar, but with a loop instead of map):

ε         # Map both values in the (implicit) input-pair to:
TL       #  Push a list in the range [1,10]
B      #  Convert the current value to each of these [1,10] bases
ć     #  Extract head; pop and push remainder-list and first item separated to the stack
y    #  Push the current value again
×   #  Repeat the "1" that many times
š  #  And prepend it back to the list
}        # After the map: push both lists separated to the stack
¢       # Count for each value in the second list how many times it occurs in the first list
O      # And sum those counts together
# (after which the result is output implicitly)


Note that the ćy×š is to fix the base-1 conversions, since in 05AB1E any number converted to base-1 would result in a single 1 instead of $$\n\$$ consecutive 1s.

That was the easy part.. I then had to add no-ops to comply to the challenge rules.. I've first created a list of all unique pairs of the 0..255 values (since the one in the challenge description is incorrect I noticed..). And then used this helper program I created to get all characters in the 05AB1E encoding facing the character I've input in the header (you may want to collapse the Input section on TIO in this helper program).

As for the resulting program and how I (and @Grimy) have made the no-ops:

ε           # Map both numbers in the (implicit) input-pair to:
η          #  Pop and push a list of prefixes of the number
θ          #  Pop and push the last prefix (the number itself)
A          #  Push the lowercase alphabet "abcdefghijklmnopqrstuvwxyz"
~          #  Bitwise-OR the number and alphabet (results in the number)
T         #  Push 10
L        #  Pop and push a list in the range [1,10]
TB      #  Convert each to base-10 (they'll remain the same)
B       #  Convert the current value to each of these [1,10] bases
™     #  Titlecase each number (does nothing on integers)
ÿ     #  String interpolation (does nothing outside of a string)
ć     #  Extract head; pop and push the remainder-list and first item separated to the stack
V    #  Pop this 1, and save it in variable Y
9    #  Push 9
y    #  Push the current value
Γ   #  Actual no-op; this character is unbound as any builtin
и   #  Repeat the 9 the value amount of times as list
#  (alternative for the ×, since the builtins facing × were useless;
#   this does mean I need an additional join J though)
Γ  #  Actual unbound no-op again
d  #  Check for each 9 if its non-negative; which is truthy, so they'll become 1s
J  #  Join the list of 1s together to a string
R #  Reverse this string of 1s (no change)
z #  Take 1 divided by this number
z #  And do it again so we're back at this number again
ª #  Append it back to the list
h #  Transform all values to hexadecimal (since we only care about equality,
#  it doesn't matter the numbers are now hexadecimal strings
#  - except for a weird bug where the string "3E#" equals 3..)
}           # Close the map
¯          # Push the global array (empty by default)
          # Push its content (nothing) to the stack
# Push the inner lists we just mapped separated to the stack
ðð        # Push two space characters
~         # Bitwise-OR between the two space characters
V         # Pop and store it in variable Y
¢         # Count for each value in the second list how many times it occurs in the first list
2      # Push a 2
\nD     # Duplicate this 2
//      # Divide the 2 by 2, and then each count by 1 (so they remain the same)
w       # Another unbound no-op
O    # And sum all counts together
# (after which the result is output implicitly)

• I'm glad you got it working, I gave up less than halfway in (: I think Z½ÿ™´ can be ηθA~ for -1. I'll look for other improvements. – Grimmy Nov 27 '19 at 15:27
• A big one: ¤4 \\šXX*/D can be Rzzªh. – Grimmy Nov 27 '19 at 16:53
• Converting to hexadecimal shouldn’t be an issue since it’s bijective and we only care about equality, not about the values themselves. The discrepancy is only due to an ugly 05AB1E bug: 3E9 is incorrectly considered equal to 3. This isn’t specific to ¢. – Grimmy Nov 27 '19 at 19:26
• Your first link doesn’t match the actual code in the answer. Your answer uses иdJ, not ×. This is why V9 works. – Grimmy Nov 27 '19 at 19:29
• Not your fault, I changed from Grimy to Grimmy a few weeks ago. (It was always meant to be pronounced with a short i, so I changed the spelling to reflect that.) – Grimmy Nov 28 '19 at 13:10

# Japt, 60 bytes

Ë5A $$óKS{3N=DVNìN=KDV)q-2 DU=CgM=U)UxPÈ4C=Mg493)UCè¶r4$$P


Try it

I used this program to find facing pairs. This program is Japt-specific, as it filters out characters Japt doesn't use. To use, enter any characters in the input section, and it will find all valid Japt characters that face them. To include control characters in the input, input 《number》 into the input section. To include control characters in the list of facing characters, prepend 。 before the character, like 。#.

This challenge is made much more difficult by the fact that there are many characters in the ISO-8859-1 codepage (Japt's default) that are unused in Japt, and cause syntax errors if they are not part of a string. Additionally, since calls to functions must be closed with  , ), or ¹, many functions are off limits. The code only contains calls to 8 functions total.

Here is the equivalent Javascript code:

U = U.m(function(D, E, F) { return (D, 5, A ).ó(function(K, S) { return (3, N = D, V, N.ì(N = K, D, V)).q("-", 2) }) });
(D, U = C.g(M = U)), U.x(function(P, X, Y, Z) { return (X, 4, C = M.g(493)), U, C.è("===".r(4), P) })


As you can see, there are many assignments made to different variables, because very few variables face a function. The Cartesian product function (ï) is locked, since every character ï faces is an unprintable that results in a syntax error in Japt.

A thing to note is that when values are chained together not like DU or 5A, only the value at the end is used, but only if the values are not arguments to a function. The values before are essentially no-ops.

Ë5A $$óKS{3N=DVNìN=KDV)q-2 Ë //Map each variable D in the input 5A //A is the variable for 10 \t //Tab (a no-op) followed by , followed by a single space //Everything between 2 dollar signs is //injected into the transpiled JavaScript //literally. In this case, we inject nothing //Space is not a no-op in Japt, it acts like parentheses ó //Range, 0-9 //Map each in the range through the following function KS{ //An "old-style" function, taking in parameters K and S //K = current #, S = index (ignored) //Obsolete nowadays, replaced by '@','_','È',and 'Ï' 3N=D //Assign N to D V //No-op variable NìN=KDV //Convert N to base K array, the last two variables are //ignored in the function call. Luckily, if 0 //is passed as the base, it returns base-10 digits //Though 's' is much more handy as it returns a string, //It only accepts bases 2-36 )q-2 //Join the base-K array with '-' (2 is a no-op) //Newline - assign the result of the previous to U DU=CgM=U)UxPÈ4C=Mg493)UCè¶r4$$P
C                             //12
g                            //Index into (wrapping)
M=U)                        //U, essentially getting first element, also assign U to M
DU=                              //Assign that to U

Ux                      //Map everything in U to the following function, then sum
PÈ                    //Function w/ parameters 'P','X','Y','Z'
4C=Mg493)           //Assign C to M[1] (indices are wrapping)
¶r4     //Replace all "4" strings in "===" with ""
UCè    P //No. of elements in C that "===" (equals) P



# Jelly, 27 bytes

5+5ɓz2z2b ð€Z<Ƈp /*6EE¹?ƇTL


A full program accepting a pair of integers which prints the closeness integer.

Try it online!

Or see the 50 by 50 grid (takes ~30s when not cached)

For verification, the bytes used (in hexadecimal) are:

35 2B 35 9B 7A 32 7A 32 62 20 18 0C 5A 3C 90 70 20 2F 2A 36 45 45 81 3F 90 54 4C


...which, as a list of integers, is:

[53, 43, 53, 155, 122, 50, 122, 50, 98, 32, 24, 12, 90, 60, 144, 112, 32, 47, 42, 54, 69, 69, 129, 63, 144, 84, 76]


### How?

5+5ɓz2z2b ð€Z<Ƈp /*6EE¹?ƇTL - Main Link: list of (two) integers, [a, b]
5+5                         - five plus five -> ten
ɓ      ð€                - for €ach n in [1..10] do f([a, b], n):
z2                      -   transpose [a, b] with filler two -> [[a,b]]
z2                    -   transpose that with filler two -> [[a],[b]]
b                   -   convert that to base n (vectorises) [[[xs]],[[ys]]]
Z               - transpose -> [[[xs],[ys]]]
Ƈ             - filter keep if:
<              -   less than [a, b] (always true so filter is a no-op)
/          - reduce by:
p            -   Cartesian product (get all pairs of wrapped representations)
*6        - raise to the sixth power (vectorises)
Ƈ   - filter keep those for which:
?    -   if...
¹     -   ...condition: identity
E       -   ...then: all equal?
E      -   ...else: all equal?
T  - truthy indexes
L - length


Combining the start of Nick Kennedy's and the end of mine gives us a joint 26 byte answer!:

b ȷ2½RJÞ©¤µ€\$ p /*6EE¹?ƇTL


Try it online!

• I put your code into the checker, and it returned '0'. I just don't know if that is good or bad. – ouflak Nov 26 '19 at 12:42
• @ouflak that is a bad thing - I didn't realise this was a source layout problem!! – Jonathan Allan Nov 26 '19 at 12:49