Inspired by: Find an Unrelated Number
Given two positive integers as input, output the mathematical operations that can be used on those inputs to generate every number from
n inclusive where
n is the smallest prime greater than the sum of the two inputs. If the number cannot be generated using the list of mathematical operations below, the output for that number should indicate that it is "unrelated".
For example, for the inputs
n=7 so one valid output would be
Subtraction, Modulus, Bitwise OR, Unrelated, Addition, Multiplication, Unrelated
(see Output section below for clarification on valid outputs)
(If Erik the Outgolfer's answer is valid, the last term will always be
Operations that must be considered are:
Addition (a + b) Subtraction (a - b) and (b - a) Multiplication (a * b) Division (a / b) and (b / a) Modulus (a % b) and (b % a) Bitwise OR (a | b) Bitwise XOR (a ^ b) Bitwise AND (a & b)
In cases where an operation would lead to a non-integer (such as
2/3), always floor. So
Exponentiation is not included because it is never required.
b**a will always be larger than
2(a+b)-2 (which is (probably) the largest possible
n) except for the cases
a=b=2. The cases
a=b=2 have valid solutions that do not use exponents:
/|U+U, respectively. For the rest of the cases where
a**b=1 which can also be found with
b**a=b which can also be found with
Concatenation is not included because it was shown to always be larger than
A list or array of the mathematical operations that can be used with the inputs to generate every number from
n inclusive where
n is the smallest prime larger than the sum of the two inputs. (You do not need to output the value of
Output can be in any format valid for your language so long as it is clearly understood. For instance, it can be an array where each value is a separate operation, a string with a delimiter between each value, or even just a solid string where each character is a different value.
You can use any character(s) so long as each possible result has a unique representation. For instance,
+-*/%|^&U will work and so will
CODEgolf!. You are advised to include a legend or explanation of how the output can be read.
If more than one operation can be used to generate a given number, you may output any one of them. Do not output all of them.
Input | n | Example Valid Output ----------------------------------------- 2, 3 | 7 | Subtraction, Modulus, Bitwise OR, Unrelated, Addition, Multiplication, Unrelated 2, 3 | 7 | -%|U+*U 2, 3 | 7 | 2579139 1, 1 | 3 | [*,+,U] 6, 6 | 13 | ["/","U","U","U","U","&","U","U","U","U","U","+","U"] 6,12 | 19 | U/U&U-UUU^UUU|UUU+U 12,6 | 19 | U/U&U-UUU^UUU|UUU+U 7,11 | 19 | /U&-UU%UUUU^UU|UU+U 7,15 | 23 | %/UUUU%-UUUUUU|UUUUUU+U (2nd value is a floor divide)
(I can easily add more test cases if someone finds an interesting one.)
I think the test case outputs are all valid but I've been known to mistakes. Please tell me if you spot one.
This is code-golf so fewest bytes wins!