text:
How many threes?
In this task your code will be given an integer \$n\$ as input.  Your code should then output the greatest number of multiples of \$3\$ that can be concatenated (in base \$10\$) to form \$3n\$ (with no leading zeros).   For example if you were given \$26042\$ as input,
\$26042\times3=78126\$
and \$78126\$ can be made by concatenating \$78\$, \$12\$ and \$6\$, so you output \$3\$.
Any standard forms of IO are permitted.  Answers should aim to minimize the number of bytes in their code.

Here are the first \$6562\$ entries in this sequence starting with zero:
1,1,1,1,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,2,2,2,2,2,2,3,3,3,3,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,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1,1,1,1,1,1,2,2,2,2,1,1,1,1,1,1,2,2

Retina, 11 bytes of Latin-1
v`.3*[012¶]

Try it online!
Retina works on strings rather than integers, so I'm taking the number as it'd appear in a file (digits followed by a newline).
(Note: as pointed out in the comments, v`.3*[¶-2] works for 10 bytes, but I didn't come up with it myself.)
Algorithm
Almost all the solutions here have a multiplication by 3, but I thought it'd be interesting to try to solve the problem without it. We already know from the algorithm most people are using that we need to identify the number of suffixes of 3n that are divisible by 3. Now, given a suffix of n (say s), 3s will appear as a suffix of 3n if the multiplication s×3 does not carry into the digit before the suffix. Meanwhile, if the multiplication s×3 does carry, then the corresponding suffix of 3n will not be divisible by 3 (as the digital root of 3s is divisible by 3 – 3 divides (10-1) and we're working in base 10 – and the corresponding suffix of 3n will be equal to 3s but without a leading 1 or 2, neither of which is divisible by 3).
We do need to adjust for the possibility that 3n has more digits than n, thus meaning that 3n has an extra suffix that doesn't correspond to any suffix of n. This suffix is trivially the whole number 3n, and will always be divisible by 3 (for obvious reasons). Thus, if the multiplication n×3 carries, we have to add 1 to the result. We can note that if n×3 doesn't carry, it will contribute 1 to the result using a naive algorithm, whereas if it does, it won't; and thus we can do this adjustment simply by counting the "suffix that represents the whole number n" unconditionally, rather than checking for a carry. Equivalently (and slightly more tersely), we can unconditionally not count this suffix, and count some other suffix instead (the empty suffix is convenient), as it'll come to the same total.
How do we determine if a multiplication by 3 would carry? Well, if the first digit of the number is greater than 3, it must; if it's less than 3, it can't. If it's 3, whether it carries or not will depend on the next digit of the number in the same way. If the number consists entirely of 3s, the multiplication won't carry (it'll stop just short at a number consisting entirely of 9s). Thus, the algorithm we want is "count the number of proper suffixes that start with 0 or more 3s, followed by 0, 1, 2, or the end of the string; plus one extra suffix".
Explanation
This algorithm ends up longer than the consensus algorithm in most languages, so I'm submitting it in Retina, a language where it turns out to be shorter than the more usual method (and a similar length to golfing languages).
v`.3*[012¶]
v`            {Count the number of} points within the input from which you can
  .             ignore one character,
   3*           and skip past any number (including zero) of 3s,
     [012¶]     to find 0, 1, 2, or the newline at the end of the input.

The requirement to ignore one character before we start looking means that the improper suffix consisting of the whole number cannot be counted (as the suffixes that we actually look at will be the ones starting one character to the right of where Retina starts, and thus not at the first character). However, the improper suffix consisting only of the newline at the end of the number will always be counted, thus giving us the one extra suffix we need.

This was the algorithm I had in mind when I wrote the question.  I'm glad to see someone used it!

@WW: This answer was more a case of "this is an interesting algorithm, let's find a language where it's efficient" than "this is an interesting language, let's find the best algorithm in it". (Although Retina is an interesting language anyway, as it happens!) I guess this is a weird side effect of the "competition per-language"; it means that you can make an answer "better", in some sense, by translating it to a language which doesn't deal with translations of competing answers well.

I believe [¶-2] saves a byte since you should be able to assume the input consists only of numeric digits and the newline.

Haskell, 51 bytes
f n=sum[1|x<-scanr(:)"0".show$3*n,read x`mod`3<1]-1

Try it online!
The key idea is the following: given a multiple of 3 (call it \$3n\$), the best way to write it as the juxtaposition of multiples of 3 is to start from the end (or the beginning) and select multiples of 3 greedily. For instance, if \$3n=78126\$, then we get (starting from the end) a \$6\$, then a \$12\$, and finally a \$78\$: \$78|12|6\$. Note that this is possible because a number is a multiple of 3 iff the sum of its digits is a multiple of 3. Also note that if we concatenate two multiples of 3, we get another multiple of 3, so \$6,12|6,78|12|6\$ are all multiples of 3.
Thus the answer can be found by considering the list of suffixes of \$3n\$ (e.g. \$[78126,8126,126,26,6]\$) and counting the multiples of 3.

Husk, 9 bytes
#o¦3dṫd*3

Try it online or verify the first 2188 terms!
Explanation
#(¦3d)ṫd*3  -- example: 42
        *3  -- times 3: 126
       d    -- digits: [1,2,6]
      ṫ     -- tails: [[1,2,6],[2,6],[6]]
#(   )      -- count values that are truthy when
    d       -- | undigits: [126,26,6]
  ¦3        -- | divisible by 3: [42,0,2]
            -- : 2

Perl 6 Raku, 54 28 26 bytes
-14 bytes thanks to nwellnhof!
{sum [\+](.comb)X%%3}o*×3

Try it online!
This counts how many prefixes of the number times three are divisible by 3.
Explanation:
{                   }o*×3  # Pass the input times 3 into the code block
     [\~](.comb)           # Get all the prefixes of the number
                X%%3       # Map each to whether they are divisible by 3
 sum                       # And get the sum

Shaved off another byte.

@nwellnhof I didn't realise you could combine with Whatever code. Neat!

05AB1E, 14 12 7 6 bytes
3*η3ÖO

-5 bytes creating a port of @BMO's Husk answer.
-1 byte thanks to @Nitrodon by changing suffixes to prefixes.
Try it online or verify the first 1000 items.
Explanation:
3*        # Multiply the (implicit) input by 3
          #  i.e. 26042 → 78126
  η       # List of prefixes
          #  i.e. 78126 → ["7","78","781","7812","78126"]
   3Ö     # Check for each if its divisible by 3
          #  i.e. ["7","78","781","7812","78126"] → [0,1,0,1,1]
     O    # And take the sum (which is implicitly output)
          #  i.e. [0,1,0,1,1] → 3

Old 12-bytes answer:
3*.œʒ3ÖP}€gà

Or alternatively €gà can be éθg.
Try it online or verify the first 1000 items
Explanation:
3*             # Multiply the (implicit) input by 3
               #  i.e. 26042 → 78126
  .œ           # Take all possible partitions of this number
               #  i.e. 78126 → [["7","8","1","2","6"],["7","8","1","26"],["7","8","12","6"],
               #                ...,["781","26"],["7812","6"],["78126"]]
    ʒ   }      # Filter these partitions by:
     3ÖP       #  Only keep partitions where every number is divisible by 3
               #   i.e. ["7","8","1","2","6"] → [0,0,0,0,1] → 0
               #   i.e. ["78","12","6"] → [1,1,1] → 1

               #(option 1:)
         €g    # Take the length of each remaining partition
               #  i.e. [["78","12","6"],["78","126"],["7812","6"],["78126"]] → [3,2,2,1]
           à   # And take the max (which we output implicitly)
               #  i.e. [3,2,2,1] → 3

               #(option 2:)
         é     # Sort the remaining partitions by length
               #  i.e. [["78","12","6"],["78","126"],["7812","6"],["78126"]]
               #   → [["78126"],["78","126"],["7812","6"],["78","12","6"]]
          θ    # Take the last one (the longest)
               #  i.e. [["78126"],["78","126"],["7812","6"],["78","12","6"]]
               #   → ["78","12","6"]
           g   # And take its length (which we output implicitly)
               #  i.e. ["78","12","6"] → 3

Using prefixes instead of suffixes gives the same result in one fewer byte.

@Nitrodon Thanks! :) I knew about the 1-byte prefixes builtin, but didn't realize the challenge works by using prefixes instead of suffixes as well.

APL (Dyalog Unicode), 14 bytes
+/0=3|+\⍎¨⍕3×⎕

Try it online! or verify the first 1000
Explanaition
+/0=3|+\⍎¨⍕3×⎕
             ⎕ ⍝ prompt for input
           3×  ⍝ multiply by 3
        ⍎¨⍕    ⍝ convert the number to a vector of digits
      +\       ⍝ take the cumulative sum
    3|         ⍝ find each term modulo 3
+/0=           ⍝ count those that equal 0

This works because a number is divisible by three if and only if the sum of its digits is divisible by three

Jelly, 7 bytes
×3DÄ3ḍS

Try it online!
How it works
×3DÄ3ḍS  Main link. Argument: n

×3       Compute 3n.
  D      Decimal; convert 3n to the array of its digits in base 10.
   Ä     Accumulate; take the cumulative sum.
         Note that an integer and its digit sum are congruent modulo 3.
    3ḍ   Test each partial digit sum for divisibility by 3.
      S  Take the sum of the Booleans, counting the multiples of 3.

JavaScript (ES6), 41 bytes
f=(n,i=10)=>!(n*3%i%3)+(n*3>i&&f(n,i*10))

Try it online!

Python 2, 99 88 bytes
lambda n:g(`3*n`)
g=lambda n:int(n)%3<1and 1+max([g(n[i:])for i in range(1,len(n))]+[0])

Try it online!

MathGolf, 15 14 bytes
3*▒0\Æ§_3÷\;]Σ

Try it online!
-1 byte thanks to JoKing
Explanation
3*                Multiply the input by 3
  ▒               Convert to a list of digits
   0\             Push a zero and swap the top two elements
     Æ            Execute the next 5 characters for each block
      §           Concatenate
       _          Duplicate
        3÷        Check divisibility by 3 (returns 0 or 1)
          \       Swap top two elements
           ;      Discard TOS (the last swap
            ]Σ    Wrap the entire stack in an array and output its sum

I don't know if this is the correct solution to the problem but it mimics the JS solution by Arnauld. If I'm incorrect, I'll try to fix it.

14 bytes

@JoKing I'll have do figure out what your code does, then I'll update with an explanation (I know what it does, but not why it works)

Haskell, 44 bytes
g.(*3).max 1
g 0=0
g n=0^mod n 3+g(div n 10)

Try it online!
Uses Delfad0r's observation that the output is the number of suffixes (equivalently, prefixes) of 3n that are multiples of 3. This method finds the prefixes arithmetically by repeatedly floor-dividing by 10 rather than using the string representation. The 0^ is a short arithmetic way to produce 1 if the exponent mod n 3 is zero, and produce 0 otherwise.
The first line is the main function, which triples the input before passing it to the helper function g which is defined recursively. The max 1 is a hack to make f(0) equal 1, since we're required to handle zero like the string '0' rather than the empty string.

Python 2, 48 bytes
n=input()*3;p=n<1
while n:p+=n%3<1;n/=10
print p

Try it online!
Similar to ovs's answer, but takes the whole prefix mod 3 without accumulating rather than the last digit. Outputs True as 1 on input of 0.

Python 3, 42 bytes
f=lambda n:n>=1and(n%1<1/3)+f(n/10)or n==0

Try it online!
Uses ideas from ais523's very nice solution. Repeatedly floor-divides the input by 10 until it's zero, and counts how many times the fractional part is less than 1/3. On very large inputs float precision will eventually be a problem. The n=0 case is handled with or n==0 making it return True for 1. The code can work in Python 2 if the input is a float, if we rewrite n%1<1/3 as n%1*3<1 which is the same length.

Pyth, 16 15 bytes
lef!.E%vT3./`*3

Try it online here.
lef!.E%vT3./`*3Q   Implicit: Q=eval(input())
                   Trailing Q inferred
            `*3Q   Input * 3
            `      Convert to string
          ./       Take divisions into disjoint substrings
  f                Filter the above using:
       vT            Convert each back to integer
      %  3           Mod 3
    .E               Are any non-0?
   !                 Logical NOT
le                 Take the length of the last value
                   As the substring sets are generated in order of number of
                   substrings, the last value is guaranteed to be the longest

Retina, 35 32 bytes
.+
$.(*3*
Lv$`.+
<$&*->
<(---)*>

Try it online! Explanation:
.+
$.(*3*

Multiply the input by 3.
Lv$`.+
<$&*->

Convert each suffix to unary.
<(---)*>

Count the multiples of three.

Shakespeare Programming Language, 376 bytes
T.Ajax,.Page,.Act I:x.Scene I:x[Enter Ajax and Page]Ajax:Listen tothy!You be the sum ofthe sum ofyou you you!Scene V:x.Page:You be the sum ofyou the quotient betweena cat the sum ofa cat the remainder of the quotient betweenI the sum ofa big cat a cat!Ajax:You be the quotient betweenyou twice the sum ofa big big cat a cat!Be you nicer zero?If solet usscene V.Page:Open heart

Try it online!
I wonder if the 1/(1+I/3) trick is better than a control flow.

You don't need the x after scenes. Try it online!

Java 10, 66 bytes
n->{int m=1,r=n<1?1:0;for(n*=3;m<n;m*=10)r+=n%m%3<1?1:0;return r;}

Try it online.
Explanation:
Uses a combination of @BMO's Husk answer (checking how many prefixex are divisible by 3) and @Arnauld's JavaScript (ES6) answer (multiplying an integer by 10 every iteration, and get the prefixes with a modulo of this integer).
n->{             // Method with integer as both parameter and return-type
  int m=1,       //  Modulo-integer, starting at 1
      r=         //  Result-integer, starting at:
        n<1?     //   If the input is the edge-case 0:
         1       //    Start it at 1
        :        //   Else:
         0;      //    Start it at 0
  for(n*=3;      //  Multiply the input by 3
      m<n;       //  Loop as long as `m` is still smaller than `n`
      m*=10)     //    After every iteration: Multiply `m` by 10
    r+=n%m       //   If `n` modulo-`m` (to get a suffix),
          %3<1?  //   is divisible by 3:
        1        //    Increase the result-sum by 1
       :         //   Else:
        0;       //    Leave the result-sum the same by adding 0
  return r;}     //  Return the result-sum

K (ngn/k), 16 bytes
{+/~3!+\.:'$3*x}

Try it online!

Husk, 7 bytes
#¦3∫d*3

Try it online!
Same as the other answer, except it uses cumulative sum.

Imagine having to explicitly convert the number to a list of digits.

Python 2, 56 bytes
n=input()*3;k=p=0
while n:k+=n%10;n/=10;p+=k%3<1
print p

Try it online!

Japt -x, 12 bytes
*3 s å+ ®°v3

Try it or view results for0-1000

Stax, 8 bytes
αNΘ╠╠1d}

Run and debug it
Unpacked, ungolfed, and commented, it looks like this.
3*      triple input
E       convert to array of decimal digits
:+      get all prefix sums
F       for each prefix sum
  3%!   is it a multiple of 3?
  +     add to running total

Run this one

J, 20 bytes
1#.0=[:(3|".)\3":@*]

Try it online!

Perl 5 -p, 32 bytes
$_*=3;s/./$\+=!(($t+=$&)%3)/ge}{

Try it online!

Vyxal, s, 6 5 4 bytes
3*¦₃

Try it Online!
;)
Explained
3*¦₃
3*      # multiply the input by 3
  ¦     # take cumulative sums of that number, treating it as a list
   ₃    # get the divisibility of 3 of each number and then
        # the `-s` flag sums the top of the stack before outputting

Vyxal, 5 bytes
T¦v₃∑

Try it Online!
How?
T¦v₃∑
T     # Triple the (implicit) input
 ¦    # Cumulative sum
  v₃  # Is each element divisible by three?
    ∑ # Sum

Desmos, 61 bytes
f(n)=total(0^{mod(floor(3n/10^{[0...floor(log(0^n+n))]}),3)})

Essentially does the prefix trick that some of the other answers are using. Pretty straightforward, though quite interesting to implement in Desmos.
Try It On Desmos!
Try It On Desmos! - Prettified

Wolfram Language (Mathematica): (53) 43 Bytes
If[#<1,1-Sign@#,Boole[3#~Mod~1<1]+#0[.1#]]&

-10 bytes from att
Pretty long, but I figured it was worth posting anyways because it was difficult enough to golf.
Try It Online

Explanation:
If[#<1, 1-Sign@#: If our input was 0, return 1.
Boole[3#~Mod~1<1]: Otherwise, check if the fractional part of 3n is less than 1, and return 1 if so.
+#0: Then, add this same expression to this total
[.1#]]& but with a tenth of the input.
I also tried using the other algorithm, but I couldn't get anything below around 75 bytes with it. Probably possible to get much lower than 75 (I'm not great at golfing), but 43 certainly seems better.

You could use recursion instead of NestWhileList: Try it online!

That outputs 0 instead of 1 for the 0 case. Is that OK?

43 bytes, fixing the 0 case

That looks good, and is far better. Cool!


text:
Compute the superset
Your task here is simple:
Given a list of integer sets, find the set union.  In other words, find the shortest list of integer sets that contain all the elements in the original list of sets (but no other elements).  For example:
[1,5] and [3,9] becomes [1,9] as it contains all of the elements in both [1,5] and [3,9]
[1,3] and [5,9] stays as [1,3] and [5,9], because you don't want to include 4

Sets are notated using range notation: [1,4] means the integers 1,2,3,4.  Sets can also be unbounded: [3,] means all of the integers >= 3, and [,-1] means all of the integers <= -1.  It is guaranteed that the first element of the range will not be greater than the second.
You can choose to take sets in string notation, or you can use 2-element tuples, using a constant non-integer as the "infinite" value. You can use two distinct constants to represent the infinite upper bound and the infinite lower bound. For example, in Javascript, you could use [3,{}] to notate all integers >= 3, as long as you consistently used {} across all test cases.
Test cases:
[1,3]                     => [1,3]
[1,]                      => [1,]
[,9]                      => [,9]
[,]                       => [,]
[1,3],[4,9]               => [1,9]
[1,5],[8,9]               => [1,5],[8,9]
[1,5],[1,5]               => [1,5]
[1,5],[3,7]               => [1,7]
[-10,7],[1,5]             => [-10,7]
[1,1],[2,2],[3,3]         => [1,3]
[3,7],[1,5]               => [1,7]
[1,4],[8,]                => [1,4],[8,]
[1,4],[-1,]               => [-1,]
[1,4],[,5]                => [,5]
[1,4],[,-10]              => [1,4],[,-10]
[1,4],[,]                 => [,]
[1,4],[3,7],[8,9],[11,20] => [1,9],[11,20]

This is code-golf, so make your answer as short as possible!

Related

Can I use Infinity instead {}?

Can we take input as float values, e.g., [1.0, 3.0] instead of [1, 3]?

As long as you treat them as integers, yes.  In other words [1.0, 3.0], [4.0, 5.0] should still become [1.0, 5.0]

If your language can't take Infinity and -Infinity as input, is it allowed to take -999999 and 999999 (or even larger/smaller) instead?

No, sorry.  They need to be distinctly non-integers.  If your language only consists of integers, then the only option you have is to take input via string representation.

[1,3] is arguably a poor notational choice. In mathematics this denotes a (closed) interval, i. e. the set {  ∊ ℝ | 1 ≤  ≤ 3 }. Note this draws from the set of real numbers.

R + intervals, 90 87 81 bytes
function(...)t(reduce(Intervals(rbind(...),type="Z")))+c(1,-1)
library(intervals)

Try it online!
Input is a list of intervals. -Inf and Inf are R built-ins for minus/plus infinity. Output is a matrix of columns of intervals.
Not usually a fan of using non-standard libraries but this one was fun. TIO doesn't have intervals installed. You can try it on your own installation or at https://rdrr.io/snippets/
The intervals package supports real and integer (type = "Z") intervals and the reduce function is a built-in for what the challenge wants, but the output seems to default to open intervals, so close_intervals +c(1,-1) is needed to get the desired result.
Old version had examples in list of lists which might be convenient so I've left the link here.

I think you can save a few bytes :function(...)close_intervals(reduce(Intervals(rbind(...),type="Z"))). Or even better you can check with op if they allow a matrix as input.

I was literally lying awake in bed last night thinking "there must have been a better way to make a matrix out of the input vectors". I think the challenge is better leaving the input as-is. But it was fun to have reduce and Reduce in there.

I love the "double reduce" thing! just not golfy enough;) What about modifying the open intervals like this: f=function(...)t(reduce(Intervals(rbind(...),type="Z")))+c(1,-1) ?

JavaScript (ES6), 103 bytes
Saved 1 byte thanks to @Shaggy
Saved 1 byte thanks to @KevinCruijssen
Expects +/-Infinity for infinite values.
a=>(a.sort(([p],[P])=>p-P).map(m=M=([p,q])=>p<M+2?M=q>M?q:M:(b.push([m,M]),m=p,M=q),b=[]),b[0]=[m,M],b)

Try it online!
How?
We first sort the intervals by their lower bound, from lowest to highest. Upper bounds are ignored.
We then iterate over the sorted intervals \$[p_n,q_n]\$, while keeping track of the current lower and upper bounds \$m\$ and \$M\$, initialized to \$p_1\$ and \$q_1\$ respectively.
For each interval \$[p_n,q_n]\$:

If \$p_n\le M+1\$: this interval can be merged with the previous ones. But we may have a new upper bound, so we update \$M\$ to \$\max(M,q_n)\$.
Otherwise: there is a gap between the previous intervals and this one. We create a new interval \$[m,M]\$ and update \$m\$ and \$M\$ to \$p_n\$ and \$q_n\$ respectively.

At the end of the process, we create a last interval with the current bounds \$[m,M]\$.
Commented
a => (                  // a[] = input array
  a.sort(([p], [P]) =>  // sort the intervals by their lower bound; we do not care about
    p - P)              // the upper bounds for now
  .map(m = M =          // initialize m and M to non-numeric values
    ([p, q]) =>         // for each interval [p, q] in a[]:
    p < M + 2 ?         //   if M is a number and p is less than or equal to M + 1:
      M = q > M ? q : M //     update the maximum M to max(M, q)
    : (                 //   else (we've found a gap, or this is the 1st iteration):
      b.push([m, M]),   //     push the interval [m, M] in b[]
      m = p,            //     update the minimum m to p
      M = q             //     update the maximum M to q
    ),                  //
    b = []              //   start with b[] = empty array
  ),                    // end of map()
  b[0] = [m, M], b      // overwrite the 1st entry of b[] with the last interval [m, M]
)                       // and return the final result

p<=M+1 can be p<M+2?

@KevinCruijssen I missed that one entirely... Thanks!

Python 2, 118 113 112 111 106 105 104 101 bytes
x=input()
x.sort();a=[];b,c=x[0]
for l,r in x:
 if l>c+1:a+=(b,c),;b,c=l,r
 c=max(c,r)
print[(b,c)]+a

Saved one byte thanks to Mr.Xcoder, one thanks to Jonathan Frech, and three thanks to Dead Possum.
Try it online!

(b,c), saves a byte.

Huh, thought I'd tried that already.

Doesn't g mean your function f isn't reusable and therefore is invalid?

@Neil Probably, but that was just a holdover from an earlier attempt.

You could also do the return becomes print for another byte.

@JonathanFrech The ~-l won't work with floats, and I don't think there's an integer infinity in Python.

@Mnemonic Well, yes; sorry. Using your interpretation of integer set which allows for a non-integer to be a bound ...

@JonathanFrech The problem statement requires handling infinite sets.  I can't use integers for that.

@Mnemonic One could possibly interpret the rules as allowing to process (conceptually) infinite sets of integers.

@JonathanFrech That's the natural way to interpret it, but I don't think there's any nice way to represent that in Python.

@Mnemonic Well, I meant representing the sets using generators and defining a lazy union function which would in theory produce the correct result ... :P

@JonathanFrech If you can do it for less than the byte it would save here, go for it.

Full program is shorter: 101 bytes

Stax, 46 39 38 bytes
├&P◙╛╛ΘΩ¿σa○♦◘♣┐¬≥∩ó¬îî◙k]∙♣•╘○π≡¡jN<♀

Run and debug it
This program takes input in the originally specified string notation.

38 since |M is deprecated

Thx @Razetime. Updated

Ruby, 89 76 bytes
->a{[*a.sort.reduce{|s,y|s+=y;y[0]-s[-3]<2&&s[-3,3]=s.max;s}.each_slice(2)]}

Try it online!
Sort the array, then flatten by appending all the ranges to the first: if a range overlaps the previous one, discard 2 elements from the last 3 (keeping only the max).
Unflatten everything at the end.

Pascal (FPC), 367 362 357 bytes
uses math;type r=record a,b:real end;procedure d(a:array of r);var i,j:word;t:r;begin for i:=0to length(a)-1do for j:=0to i do if a[i].a<a[j].a then begin t:=a[i];a[i]:=a[j];a[j]:=t;end;j:=0;for i:=1to length(a)-1do if a[j].b>=a[i].a-1then begin a[j].a:=min(a[i].a,a[j].a);a[j].b:=max(a[i].b,a[j].b)end else j:=j+1;for i:=0to j do writeln(a[i].a,a[i].b)end;

Try it online!
A procedure that takes a dynamic array of records consisting of 2 range bounds, modifies the array in place and then writes it on standard output, one range per line. (Sorry for that twisted sentence.) Uses 1/0 for ubounded up and -1/0 for unbounded down.
Readable version
It would be nice to just return the array with corrected number of elements, but the dynamic array passed to function/procedure is not dynamic array anymore... First I found this, then there is this excellent, mind-boggling explanation.
This is the best data structure I could found for shortening the code. If you have better options, feel free to make a suggestion.

C (clang), 346 342 bytes
Compiler flags -DP=printf("(%d,%d)\n",-DB=a[i+1], and -DA=a[i]
typedef struct{int a,b;}t;s(t**x,t**y){if((*x)->a>(*y)->a)return 1;else if((*x)->a<(*y)->a)return -1;}i;f(t**a){for(i=0;A;)i++;qsort(a,i,sizeof(t*),s);for(i=0;B;i++){if(B->a<=A->b+1){A->b=B->b;if(B->a<A->a)A->a=B->a;else B->a=A->a;}}for(i=0;A;i++){if(!B)break;if(A->a!=B->a)P,A->a,A->b);}P,A->a,A->b);}

Try it online!

I think you are relying on i's global value.

What @JonathanFrech means is that while(A)i++; should be for(i=0;A;)i++; to explicitly set i=0 before using it in the while-loop, instead of using its default 0 value on global level. Not sure anymore why, but it's required according to the meta rules. Mainly because methods should be self-contained / re-usable, without having to reset global values in between method calls, IIRC.

Fixed reliance on the global i value

@KevinCruijssen See Do function submissions have to be reusable?.

246 bytes

05AB1E (legacy), 88 79 78 bytes
g≠i˜AKïDW<UZ>VIøεAXY‚Nè:}ïø{©˜¦2ôíÆ1›.œʒíεćsO_*}P}н€g®£εø©θàDYQiA}V®нßDXQiA}Y‚

Infinity is input as the lowercase alphabet ('abcdefghijklmnopqrstuvwxyz').
Try it online or verify all test cases.
Important note: If there was an actual Infinity and -Infinity, it would have been 43 42 bytes instead. So little over 50% around 30% is as work-around for the lack of Infinity..
{©Dg≠i˜¦2ôíÆ1›.œʒíεćsO_*}P}н€g®£εø©θàV®нßY‚

Try it online (with Infinity replaced with 9999999999 and -Infinity replaced with -9999999999).
Can definitely be golfed substantially. In the end it turned out very, very ugly full of workarounds. But for now I'm just glad it's working.
Explanation:
Dg≠i          # If the length of the implicit input is NOT 1:
              #   i.e. [[1,3]] → length 1 → 0 (falsey)
              #   i.e. [[1,4],["a..z",-5],[3,7],[38,40],[8,9],[11,20],[25,"a..z"],[15,23]]
              #    → length 8 → 1 (truthy)
    ˜         #  Take the input implicit again, and flatten it
              #   i.e. [[1,4],["a..z",-5],[3,7],[38,40],[8,9],[11,20],[25,"a..z"],[15,23]]
              #    → [1,4,"a..z",-5,3,7,38,40,8,9,11,20,25,"a..z",15,23]
     AK       #  Remove the alphabet
              #   i.e. [1,4,"a..z",-5,3,7,38,40,8,9,11,20,25,"a..z",15,23]
              #    → ['1','4','-5','3','7','38','40','8','9','11','20','25','15','23']
       ï      #  Cast everything to an integer, because `K` turns them into strings..
              #   i.e. ['1','4','-5','3','7','38','40','8','9','11','20','25','15','23']
              #    → [1,4,-5,3,7,38,40,8,9,11,20,25,15,23]
        D     #  Duplicate it
         W<   #  Determine the min - 1
              #   i.e. [1,4,-5,3,7,38,40,8,9,11,20,25,15,23] → -5
           U  #  Pop and store it in variable `X`
         Z>   #  Determine the max + 1
              #   i.e. [1,4,-5,3,7,38,40,8,9,11,20,25,15,23] → 40
           V  #  Pop and store it in variable `Y`
Iø            #  Take the input again, and transpose/zip it (swapping rows and columns)
              #   i.e. [[1,4],["a..z",-5],[3,7],[38,40],[8,9],[11,20],[25,"a..z"],[15,23]]
              #    → [[1,'a..z',3,38,8,11,25,15],[4,-5,7,40,9,20,'a..z',23]]
  ε       }   #  Map both to:
   A          #   Push the lowercase alphabet
    XY‚       #   Push variables `X` and `Y`, and pair them into a list
       Nè     #   Index into this list, based on the index of the mapping
         :    #   Replace every alphabet with this min-1 or max+1
              #   i.e. [[1,'a..z',3,38,8,11,25,15],[4,-5,7,40,9,20,'a..z',23]]
              #    → [['1','-6','3','38','8','11','25','15'],['4','-5','7','40','9','20','41','23']]
ï             #  Cast everything to integers again, because `:` turns them into strings..
              #   i.e. [['1','-6','3','38','8','11','25','15'],['4','-5','7','40','9','20','41','23']]
              #    → [[1,-6,3,38,8,11,25,15],[4,-5,7,40,9,20,41,23]]
 ø            #  Now zip/transpose back again
              #   i.e. [[1,-6,3,38,8,11,25,15],[4,-5,7,40,9,20,41,23]]
              #    → [[1,4],[-6,-5],[3,7],[38,40],[8,9],[11,20],[25,41],[15,23]]
  {           #  Sort the pairs based on their lower range (the first number)
              #   i.e. [[1,4],[-6,-5],[3,7],[38,40],[8,9],[11,20],[25,41],[15,23]]
              #    → [[-6,-5],[1,4],[3,7],[8,9],[11,20],[15,23],[25,41],[38,40]]
   ©          #  Store it in the register (without popping)
˜             #  Flatten the list
              #   i.e. [[-6,-5],[1,4],[3,7],[8,9],[11,20],[15,23],[25,41],[38,40]]
              #    → [-6,-5,1,4,3,7,8,9,11,20,15,23,25,41,38,40]
 ¦            #  And remove the first item
              #   i.e. [-6,-5,1,4,3,7,8,9,11,20,15,23,25,41,38,40]
              #    → [-5,1,4,3,7,8,9,11,20,15,23,25,41,38,40]
  2ô          #  Then pair every two elements together
              #   i.e. [-5,1,4,3,7,8,9,11,20,15,23,25,41,38,40]
              #    → [[-5,1],[4,3],[7,8],[9,11],[20,15],[23,25],[41,38],[40]]
    í         #  Reverse each pair
              #   i.e. [[-5,1],[4,3],[7,8],[9,11],[20,15],[23,25],[41,38],[40]]
              #    → [[1,-5],[3,4],[8,7],[11,9],[15,20],[25,23],[38,41],[40]]
     Æ        #  Take the difference of each pair (by subtracting)
              #   i.e. [[1,-5],[3,4],[8,7],[11,9],[15,20],[25,23],[38,41],[40]]
              #    → [6,-1,1,2,-5,2,-3,40]
      1›      #  Determine for each if they're larger than 1
              #   i.e. [6,-1,1,2,-5,2,-3,40] → [1,0,0,1,0,1,0,1]
.œ            #  Create every possible partition of these values
              #   i.e. [1,0,0,1,0,1,0,1] → [[[1],[0],[0],[1],[0],[1],[0],[1]],
              #                             [[1],[0],[0],[1],[0],[1],[0,1]],
              #                             ...,
              #                             [[1,0,0,1,0,1,0],[1]],
              #                             [[1,0,0,1,0,1,0,1]]]
  ʒ         } #  Filter the partitions by:
   í          #   Reverse each inner partition
              #    i.e. [[1],[0,0,1],[0,1],[0,1]] → [[1],[1,0,0],[1,0],[1,0]]
    ε     }   #   Map each partition to:
     ć        #    Head extracted
              #     i.e. [1,0,0] → [0,0] and 1
              #     i.e. [1] → [] and 1
              #     i.e. [1,0,1] → [1,0] and 1
      s       #    Swap so the rest of the list is at the top of the stack again
       O      #    Take its sum
              #     i.e. [0,0] → 0
              #     i.e. [] → 0
              #     i.e. [1,0] → 1
        _     #    And check if it's exactly 0
              #     i.e. 0 → 1 (truthy)
              #     i.e. 1 → 0 (falsey)
         *    #    And multiply it with the extracted head
              #    (is only 1 when the partition has a single trailing 1 and everything else a 0)
              #     i.e. 1 and 1 → 1 (truthy)
              #     i.e. 1 and 0 → 0 (falsey)
           P  #   And check if all mapped partitions are 1
н             #  Take the head (there should only be one valid partition left)
              #   i.e. [[[1],[0,0,1],[0,1],[0,1]]] → [[1],[0,0,1],[0,1],[0,1]]
 €g           #  Take the length of each inner list
              #   i.e. [[1],[0,0,1],[0,1],[0,1]] → [1,3,2,2]
   ®          #  Push the sorted pairs we've saved in the register earlier
    £         #  Split the pairs into sizes equal to the partition-lengths
              #   i.e. [1,3,2,2] and [[-6,-5],[1,4],[3,7],[8,9],[11,20],[15,23],[25,41],[38,40]]
              #    → [[[-6,-5]],[[1,4],[3,7],[8,9]],[[11,20],[15,23]],[[25,41],[38,40]]]
ε             #  Map each list of pairs to:
 ø            #   Zip/transpose (swapping rows and columns)
              #    i.e. [[1,4],[3,7],[8,9]] → [[1,3,8],[4,7,9]]
              #    i.e. [[25,41],[38,40]] → [[25,38],[41,40]]
  ©           #   Store it in the register
   θ          #   Take the last list (the ending ranges)
              #    i.e. [[25,38],[41,40]] → [41,40]
    à         #   And determine the max
              #    i.e. [41,40] → 41
     DYQi }   #   If this max is equal to variable `Y`
              #     i.e. 41 (`Y` = 41) → 1 (truthy)
         A    #    Replace it back to the lowercase alphabet
           V  #   Store this max in variable `Y`
  ®           #   Take the zipped list from the register again
   н          #   This time take the first list (the starting ranges)
              #    i.e. [[25,38],[41,40]] → [25,38]
    ß         #   And determine the min
              #    i.e. [25,38] → 25
     DXQi }   #   If this min is equal to variable `X`
              #     i.e. 25 (`X` = -6) → 0 (falsey)
         A    #    Replace it back to the lowercase alphabet
           Y‚ #   And pair it up with variable `Y` (the max) to complete the mapping
              #    i.e. 25 and 'a..z' → [25,'a..z']
              #  Implicitly close the mapping (and output the result)
              #   i.e. [[[-6,-5]],[[1,4],[3,7],[8,9]],[[11,20],[15,23]],[[25,41],[38,40]]]
              #    → [['a..z',-5],[1,9],[11,23],[25,'a..z']]
              # Implicit else (only one pair in the input):
              #  Output the (implicit) input as is
              #   i.e. [[1,3]]

Wolfram Language (Mathematica), 57 bytes
List@@(#-{0,1}&/@IntervalUnion@@(Interval[#+{0,1}]&/@#))&

Try it online!
Takes input as a list of lists {a,b} representing the interval [a,b], where a can be -Infinity and b can be Infinity.
Uses the built-in IntervalUnion, but of course we have to massage the intervals into shape first. To pretend that the intervals are integers, we add 1 to the upper bound (making sure that the union of [1,3] and [4,9] is [1,9]). At the end, we undo this operation, and turn the result back into a list of lists.
There's also a completely different approach, which clocks in at 73 bytes:
NumericalSort@#//.{x___,{a_,b_},{c_,d_},y___}/;b+1>=c:>{x,{a,b~Max~d},y}&

Here, after sorting the intervals, we just replace two consecutive intervals by their union whenever that would be a single interval, and repeat until there is no such operation left to be done.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Multiply and Divide
Given a value x find the smallest numerical value greater than y that is capable of being multiplied and divided by x while retaining all original digits.

The new numbers do not lose digits.
The new numbers do not gain digits.

For example:

Input: x = 2, y = 250000

Original: 285714

Division: 142857
Multiplication: 571428

This is true because 285714 is greater than y; then when divided by x results in 142857 and when multiplied by x results in 571428. In both tests all of the original digits from 285714 are present and no extra digits have been added.

The Rules

X should be 2 or 3 as anything higher takes too long to calculate.
Y is required to be a whole number greater than zero.
The shortest code wins.

Test Cases
These are my most common test cases as they are the quickest to test for.

x = 2, y = 250000 = 285714
x = 2, y = 290000 = 2589714
x = 2, y = 3000000 = 20978514
x = 3, y = 31000000 = 31046895
x = 3, y = 290000000 = 301046895

Clarifications

The type of division doesn't matter. If you can get 2.05, 0.25, and 5.20 somehow then feel free.

Good luck to you all!

Are digits counted with multiplicity? I.e., if x=11 and y=10, is 11 the answer? (11/11=1 which has the same digits as 11, but not with multiplicity). Also, is it ok if new digits appear when multiplying by x, as long as all the original digits are present?

No digits are gained nor lost; and this has to be true for multiplication and division. In the case of x = 11 and y = 10 then 11 is not the answer; 11/11 = 1 and 11 * 11 = 121. Thus digits are lost and gained.

deja vu

"X has to be a value between 2 and 5." - if X>=4, the number multiplied by X will be at least 16 times larger than the number divided by X, so surely it will have more digits

x can't be anything other than 2 or 3 since the product is x^2 times the quotient and both should have same number of digits. x = 1 will be a trivial case. IMO, there's no solution for x = 3 for any y though I might be wrong.

What does do not gain / loos digits mean? For example, 1234567899876543210, and 2469135799753086420. They all contain all digits in range 0~9, but first one has 2 nines, but second one has 3 nines. Is this still valid?

@tsh If one numbers contains 2 nines and the other 3, it's not valid. See it this way: if the digits of all three numbers (y, y/x, and y*x) are sorted, the resulting lists of digits should be exactly the same (same amount of digits, same frequencies/counts per digit)

Is division float or integer division?

Also, as others have commented, $X\in{2,3}$, otherwise there will be no valid output. $x\times4=\frac x4\times16$, and $x\times5=\frac x5\times25$, both of which are sure to make the number of digits between the product and the quotient different.

@EriktheOutgolfer If you use float division and ignore the decimal point, then there are solutions: e.g. 153846 for X=4 and 1028574 for X=5.

@ØrjanJohansen I'm pretty sure the decimal point can't be ignored; $15=10^1\times1+10^0\times1$, while $1.5=10^0\times1+10^{-1}\times5$ (yep, those are different digits). And OP has said X and Y must be whole numbers, although it's not all that clear about the output, or what kind of division is implied.

@EriktheOutgolfer I mean ignored for the purposes of checking if the numbers have the same digits.

Is the output (call it $n$) integers? What about $n/x$?

Test cases would be great

I suspect I'm not the only person who is refraining from voting to reopen because the clarification actually makes the challenge more ambiguous, because the correct answer could change dependently on whether floating point output is considered or not. I suspect @EriktheOutgolfer 's question was not asking about allowing floating point output, but about whether it's permitted to use truncating integer division. (And I'm sorry if my comments added to the confusion.)

@ØrjanJohansen You're indeed right that using regular division vs integer division can indeed change the output. However, in the latest clarifications, OP allows both type of divisions, and allows both integer or decimal outputs (where all digits used are equal). Although it makes the challenge more ambiguous for sure, with a performance-heavy (in most languages) challenge like this, I'm not sure whether it's a bad thing. Still, a test case where multiple valid answers are possible based on division-type and/or decimals would be good to add as clarification. Can't really think of one, though..

@KevinCruijssen (142857,285714,71428.5), (1028574,2057148,514287.0) and (1402857,2805714,701428.5) are the first I find for x=2. tsh proved in comments below that for x in {2,3} the division type doesn't actually matter as long as you only allow integer output. Also x=3 can't give finite non-integer output.

The answer for exercise x = 2, y = 250000 not result 285714 here but it would result here 250812 because 125406 501624 seems number permutation ; where is my error?

Yes i have understood; digits are the same all f/x f*x and y...

Yes i have understood; digits are the same all f/x f*x and the number f (that is y incremented)

If x>3 doesn't exist any solution because the 3 numbers has to have different length one can thinking example for x =4.  1; 41; 44*1 they have different length...(16 has length 2)

Husk, 14 bytes
ḟ§¤=OoDd§¤+d*/

Try it online!
Explanation
ḟ§¤=O(Dd)§¤+d*/  -- example inputs: x=2  y=1
ḟ                -- find first value greater than y where the following is true (example on 285714)
 §               -- | fork
         §       -- | | fork
              /  -- | | | divide by x: 142857
                 -- | | and
             *   -- | | | multiply by y: 571428
                 -- | | then do the following with 142857 and 571428
                 -- | | | concatenate but first take
           +     -- | | | | digits: [1,4,2,8,5,7] [5,7,1,4,2,8]
          ¤ d    -- | | | : [1,4,2,8,5,7,5,7,1,4,2,8]
                 -- | and
       d         -- | | digits: [2,8,5,7,1,4]
      D          -- | | double: [2,8,5,7,1,4,2,8,5,7,1,4]
                 -- | then do the following with [2,8,5,7,1,4,2,8,5,7,1,4] and [1,4,2,8,5,7,5,7,1,4,2,8]
   =             -- | | are they equal
  ¤ O            -- | | | when sorted: [1,1,2,2,4,4,5,5,7,7,8,8] [1,1,2,2,4,4,5,5,7,7,8,8]
                 -- | : truthy
                 -- : 285714

I adjusted the value for y to get a closer starting point and the result was incorrect for x = 3, y = 25000000.

@PerpetualJ: If you know the result then you can simply adjust y, and this version should be slightly faster (only the type-checking though).

I've adjusted it after some thought and edited my first comment.

@PerpetualJ: I've fixed it: made an assumption about - which was wrong.

That produced a correct result! :) I'm curious; how do you understand what's going on there by the way?

@PerpetualJ: I wrote the program ;) I added an explanation, now everybody should understand what's going on.

Brachylog v2, 15 bytes
t<.g,?kA/p.∧A×p

Try it online!
Takes input in the form [x,y].
Explanation
t<.g,?kA/p.∧A×p
t                  Tail (extract y from the input)
 <                 Brute-force search for a number > y, such that:
  .                  it's the output to the user (called ".");
   g                 forming it into a list,
    ,?               appending both inputs (to form [.,x,y]),
      k              and removing the last (to form [.,x])
       A             gives a value called A, such that:
        /              first ÷ second element of {A}
         p             is a permutation of
          .            .
           ∧         and
            A×         first × second element of {A}
              p        is a permutation of {.}

Commentary
Brachylog's weakness at reusing multiple values multiple times shows up here; this program is almost all plumbing and very little algorithm.
As such, it might seem more convenient to simply hardcode the value of y (there's a comment on this question hypothesising that 2 is the only possible value). However, there are in fact solutions for y=3, meaning that unfortunately, the plumbing has to handle the value of y as well. The smallest that I'm aware of is the following:
                         315789473684210526
315789473684210526 × 3 = 947368421052631578
315789473684210526 ÷ 3 = 105263157894736842

(The technique I used to find this number isn't fully general, so it's possible that there's a smaller solution using some other approach.)
You're unlikely to verify that with this program, though. Brachylog's p is written in a very general way that doesn't have optimisations for special cases (such as the case where both the input and output are already known, meaning that you can do the verification in O(n log n) via sorting, rather than the O(n!) for the brute-force approach that I suspect it's using). As a consequence, it takes a very long time to verify that 105263157894736842 is a permutation of 315789473684210526 (I've been leaving it running for several minutes now with no obvious progress).
(EDIT: I checked the Brachylog source for the reason. It turns out that if you use p on two known integers, the algorithm used generates all possible permutations of the integer in question until it finds one that's equal to the output integer, as the algorithm is "input → indigits, permute indigits → outdigits, outdigits → output". A more efficient algorithm would be to set up the outdigits/output relationship first, so that the backtracking within the permutation could take into account which digits were available.)

Using a fork can decrease your code by 1 byte. Try it online!

Also according to the docs, it seems checking if two known lists are a permutation is O(n²) http://www.swi-prolog.org/pldoc/man?predicate=permutation/2

@Kroppeb: the problem is that Brachylog's p doesn't run permutation/2 with two known lists, even when given two known integers as arguments; it generates all the permutations of the first integer (using permutation/2 with one known list) and then compares them against the second integer.

Perl 6, 56 54 bytes
->\x,\y{(y+1...{[eqv] map *.comb.Bag,$_,$_*x,$_/x})+y}

Try it online!
Interesting alternative, computing n*xk for k=-1,0,1:
->\x,\y{first {[eqv] map ($_*x***).comb.Bag,^3-1},y^..*}

Haskell, 76 74 bytes
Two bytes shaved off thanks to Lynn's comment
import Data.List
s=sort.show
x#y=[n|n<-[y+1..],all(==s n)[s$n*x,s$n/x]]!!0

For the same byte count your f can be f x y=[n|n<-[y+1..],all(==s n)[s$n*x,s$n/x]]!!0 but then defining your answer as an operator saves two bytes: x!y=… and then your answer is (!) :)

Didn't think of using list comprehensions! Thanks for the suggestion :D

Clean, 92 bytes
import StdEnv
$n m=hd[i\\i<-[m..],[_]<-[removeDup[sort[c\\c<-:toString j]\\j<-[i,i/n,i*n]]]]

Try it online!
Pretty simple. Explanation coming in a while.

JavaScript (ES6), 76 73 69 bytes
Saved 3 bytes by using eval(), as suggested by @ShieruAsakoto
Takes input as (x)(y).
x=>y=>eval("for(;(g=x=>r=[...x+''].sort())(y*x)+g(y/x)!=g(y)+r;)++y")

Try it online!
A recursive version would be 62 bytes, but it's not well suited here because of the high number of required iterations.
How?
The helper function \$g\$ takes an integer as input, converts it to an array of digit characters and sorts this array.
Example:
g(285714) = [ '1', '2', '4', '5', '7', '8' ]

To compare the digits of \$y\times x\$ and those of \$y/x\$ against those of \$y\$, we test whether the concatenation of \$g(y\times x)\$ with \$g(y/x)\$ is equal to the concatenation of \$g(y)\$ with itself.
When adding two arrays together, each of them is implicitly coerced to a comma-separated string. The last digit of the first array is going to be directly concatenated with the first digit of the second array with no comma between them, which makes this format unambiguous.
Example:
g(123) + g(456) = [ '1', '2', '3' ] + [ '4', '5', '6' ] = '1,2,34,5,6'

But:
g(1234) + g(56) = [ '1', '2', '3', '4' ] + [ '5', '6' ] = '1,2,3,45,6'

Commented
x => y =>                   // given x and y
  eval(                     // evaluate as JS code:
    "for(;" +               //   loop:
      "(g = x =>" +         //     g = helper function taking x
        "r =" +             //       the result will be eventually saved in r
          "[...x + '']" +   //       coerce x to a string and split it
          ".sort() + ''" +  //       sort the digits and coerce them back to a string
      ")(y * x) +" +        //     compute g(y * x)
      "g(y / x) !=" +       //     concatenate it with g(y / x)
      "g(y) + r;" +         //     loop while it's not equal to g(y) concatenated with
    ")" +                   //     itself
    "++y"                   //   increment y after each iteration
  )                         // end of eval(); return y

66: x=>F=y=>(g=x=>r=[...x+''].sort()+'')(y*x)!=g(y)|r!=g(y/x)?F(y+1):y May cause stack overflow if y is far from the solution tho.

or 75 using eval: x=>y=>eval("for(;(g=x=>r=[...x+''].sort()+'')(y*x)!=g(y)|r!=g(y/x);y++);y")

@ShieruAsakoto Thanks for the eval() idea. My first attempt was indeed recursive, but I gave up because of the high number of required iterations.

q, 65 bytes
{f:{asc 10 vs x};while[not((f y)~f y*x)&(f y*x)~f"i"$y%x;y+:1];y}

Split number on base 10, sort each ascending, and check if equal. If not, increment y and go again

Japt, 24 bytes
Pretty naïve solution over a few beers; I'm sure there's a better way.
@[X*UX/U]®ì nÃeeXì n}a°V

Try it

Unfortunately this produces an incorrect result when x = 3 and y = 25000.

@PerpetualJ Assuming 315789473684210526 is the first solution for x=3, Javascript or Japt can't compute it correctly since it doesn't fit in double precision.

@PerpetualJ, fixed that earlier. That test case will never complete, though, for the reason Bubbler mentioned above.

@Shaggy This now produces a correct result and the solution that Bubbler pointed at is not the first correct result above 25000. See my test cases if you're curious on that. +1

APL(NARS), 490 chars, 980 bytes
T←{v←⍴⍴⍵⋄v>2:7⋄v=2:6⋄(v=1)∧''≡0↑⍵:4⋄''≡0↑⍵:3⋄v=1:5⋄⍵≢+⍵:8⋄⍵=⌈⍵:2⋄1}
D←{x←{⍵≥1e40:,¯1⋄(40⍴10)⊤⍵}⍵⋄{r←(⍵≠0)⍳1⋄k←⍴⍵⋄r>k:,0⋄(r-1)↓⍵}x}
r←c f w;k;i;z;v;x;y;t;u;o ⍝   w  cxr
   r←¯1⋄→0×⍳(2≠T c)∨2≠T w⋄→0×⍳(c≤1)∨w<0⋄→0×⍳c>3
   r←⌊w÷c⋄→Q×⍳w≤c×r⋄r←r+c
Q: u←D r⋄x←1⊃u⋄y←c×x⋄t←c×y⋄o←↑⍴u⋄→0×⍳o>10⋄→A×⍳∼t>9
M:                     r←10*o⋄⍞←r⋄→Q
A: u←D r⋄→M×⍳x≠1⊃u⋄→B×⍳∼(t∊u)∧y∊u⋄z←r×c⋄v←D z⋄→C×⍳(⍳0)≡v∼⍦u
B: r←r+1⋄→A
C: k←z×c⋄⍞←'x'⋄→B×⍳(⍳0)≢v∼⍦D k
   ⎕←' '⋄r←z

test
  2 f¨250000 290000 3000000
xxxx
1000000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
10000000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
285714 2589714 20978514
 3 f¨ 31000000 290000000
xxxxxxxxx
100000000xxxxxxxxxxxxxxxxxxxxxxxxxx
31046895 301046895

I thought the problem as r a convenient number that can vary so one has the 3 numbers r, r*x, r*x*x in the way r begin to a value that r*x is near y (where x and y are inputs of the problem using same letters as main post). I used the observation that if the first digit of r is d than in r has to appear digits d*x and d*x*x too, for make r (or better r*x) one solution.

Jelly,  14  13 bytes
-1 thanks to Erik the Outgolfer (`` uses make_digits, so D was not required)
+2 fixing a bug (thanks again to Erik the Outgolfer for pointing out the off-by one issue)
×;÷;⁸Ṣ€E
‘ç1#

A full program printing the result (as a dyadic link a list of length 1 is yielded).
Try it online!
How?
×;÷;⁸Ṣ€E - Link 1, checkValidity: n, x               e.g. n=285714,  x=2
×        -     multiply -> n×x                       571428
  ÷      -     divide -> n÷x                         142857
 ;       -     concatenate -> [n×x,n÷x]              [571428,142857]
    ⁸    -     chain's left argument = n             285714
   ;     -     concatenate -> [n×x,n÷x,n]            [571428,142857,285714]
     Ṣ€  -     sort €ach (implicitly make decimals)  [[1,2,4,5,7,8],[1,2,4,5,7,8],[1,2,4,5,7,8]]
        E    -     all equal?                        1

‘ç1# - Main link: y, x
‘    - increment -> y+1
   # - count up from n=y+1 finding the first...
  1  - ...1 match of:
 ç   -   the last link (1) as a dyad i.e. f(n, x)

Note that when the division is not exact the implicit decimal instruction (equivalent to a D) applied prior to the sort yields a fractional part
e.g.: 1800÷3D -> [6,0,0]
while 1801÷3D -> [6.0,0.0,0.33333333333337123]

I'm not really sure this answer is valid; the challenge requires the result to be "greater than y", which I interpret as "strictly greater than Y". Also, you don't need D.

Ah good spot on >= I totally missed that! Had no idea Ṣ had make_digits set on it - thanks. Will have to fix & update later though...

Python 2, 69 bytes
S=sorted
x,y=input()
while(S(`y`)==S(`y*x`)==S(`y/x`))<1:y+=1
print y

Try it online!

f=lambda x,y,S=sorted:y*(S(`y`)==S(`y*x`)==S(`y/x`))or f(x,y+1) should work, but it hits the recursion limit fairly quickly, and I don't know what PPCG rules have to say about that.

Mathematica, 82 74 bytes
x=Sort@*IntegerDigits;Do[If[x[i#]==x@Floor[i/#]==x@i,Break@i],{i,#2,∞}]&

-8 bytes thanks to tsh
Function that takes arguments as [x,y]. Effectively a brute force search that checks if the sorted list of digits for y,y/x and xy are the same.
Try it online!

I'm not familiar with Mathematica. But it could be proved that the answer would still be right if you drop the fractional part of division: All ans, ans/x, ans*x should be divisible by 9. And this may make your solution shorter.

@tsh That works for x=3, but I'm not sure it's true for x=2.

@ØrjanJohansen Let v = a[1]*10^p[1] + a[2]*10^p[2] + ... + a[n]*10^p[n], u =  a[1] * 10^q[1] + ... + a[n] * 10^q[n]. And u-v = a[1]*(10^p[1]-10^q[1]) + ... + a[n]*(10^p[n]-10^q[n]) Since 10^x-10^y=0 (mod 9) always holds. u-v=0 (mod 9) always holds. If there is an wrong answer w, since w*x-w=0 (mod 9), and, w-floor(w/x)=0 (mod 9): we have floor(w/x)=0 (mod 9). if floor(w/x)*x <> w, w-floor(w/x)*x>=9, but this conflict with the fact that w-floor(w/x)*x<x while x could be 2 or 3.

@tsh Thanks! For the benefit of others taking way too long to get this point, w=0 (mod 9) there follows from w*x-w=0 (mod 9) because x-1 is not divisible by 3.

If I exclude the IntegerQ test, it produces a couple of errors when it tries to do IntegerDigits on fractions, but Mathematica still goes past them and produces the correct answer. I'm not sure if errors being included during the calculation would be allowed, even if the final answer is correct.

05AB1E, 16 bytes
[>©Ð²÷s²*)€{Ë®s#

Try it online. (NOTE: Very inefficient solution, so use inputs close to the result. It works for larger inputs as well locally, but on TIO it'll time out after 60 sec.)
Explanation:
[                   # Start an infinite loop
 >                  #  Increase by 1 (in the first iteration the implicit input is used)
  ©                 #  Store it in the register (without popping)
   Ð                #  Triplicate it
    ²÷              #  Divide it by the second input
      s             #  Swap so the value is at the top of the stack again
       ²*           #  Multiply it by the second input
         )          #  Wrap all the entire stack (all three values) to a list
          €{        #  Sort the digits for each of those lists
             ®s     #  Push the value from the register onto the stack again
            Ë       #  If all three lists are equal:
               #    #   Stop the infinite loop

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Make them sum to 10,000
We've recently reached the threshold of 10,000 questions on PPCG. Hooray! Let's celebrate this with a simple challenge.
Input
Two integers \$A\$ and \$B\$, both in \$[1..9999]\$, such that \$A+B<10000\$.
Task
Your task is to add one single digit to one of these integers or one single digit to both of them such that \$A+B=10000\$. If adding a digit to both \$A\$ and \$B\$, it need not necessarily be the same digit.
The new digit can be added at the beginning, at the end or anywhere in the middle of the original integer. However, you can't add a leading zero.
Example:
For \$A=923\$, the following transformations are valid:
$$\color{red}1923\\92\color{red}73\\923\color{red}8$$
But these ones are invalid:
$$\color{red}{0}923\\\color{red}{10}923\\9\color{red}{4}2\color{red}{7}3$$
Given \$A=923\$ and \$B=72\$, there are two possible solutions:
$$923\color{red}8 + 7\color{red}62 = 10000\\92\color{red}73 + 72\color{red}7 = 10000$$
Output
You must print or output a list of all possible solutions.
For the above example, the expected output would be [[9238,762],[9273,727]].
Rules

I/O can be processed in any reasonable, unambiguous format. You may use strings, lists of digits, etc. instead of integers.
The input is guaranteed to have at least one solution.
You are allowed not to deduplicate the output. However, it would be appreciated if the test code is deduplicating it with some post-processing, for instance in the footer section of TIO.
This is a code-golf challenge.

Test cases
Input    --> Output

934, 654 --> [[9346,654]]

737, 628 --> [[7372,2628]]

9122, 88 --> [[9122,878]]

923, 72  --> [[9238,762],[9273,727]]

998, 3   --> [[9968,32],[9987,13]]

900, 10  --> [[9900,100],[9090,910]]    NB: solutions such as [9000,1000] are NOT valid
                                            (more than one digit added to 10)

363, 632 --> [[3673,6327],[3638,6362]]

288, 711 --> [[2881,7119],[2882,7118],[2883,7117],[2884,7116],[2885,7115],[2886,7114],
              [2887,7113],[2888,7112],[2889,7111]]

365, 635 --> [[365,9635],[1365,8635],[2365,7635],[3365,6635],[4365,5635],[5365,4635],
              [6365,3635],[7365,2635],[8365,1635],[9365,635],[3065,6935],[3165,6835],
              [3265,6735],[3465,6535],[3565,6435],[3665,6335],[3765,6235],[3865,6135],
              [3965,6035],[3605,6395],[3615,6385],[3625,6375],[3635,6365],[3645,6355],
              [3655,6345],[3675,6325],[3685,6315],[3695,6305],[3650,6350]]

It’s not a simple challenge if I can’t type it out and be confident it works while in my car. ;p

@Quintec I'd recommend against typing anything while you're in your car. :p

@Arnauld He didn't say he's the driver. ;-) (Serious note: 4 off-topic comments so far, my 3-comment handicap for those purposes is beeping loudly. :P)

When jelly solutions take more than 20 bytes it’s a tough challenge!

output a list of all possible solutions Oh bummer. That'd be difficult for my Runic language. I could probably write a program that could output a solution!

Haskell, 99 97 82 81 bytes
-16 bytes thanks to Delfad0r (taking inputs as a list, using abusing that we don't need to deduplicate -> n can always be in [0,4] & using a clever combination of input-format and ap)!
filter((==1e4).sum).mapM([read.(take n<>(c:).drop n)|c<-['0'..'9'],n<-[0..4]]<*>)

Try it online!

Actually I'm feeling a bit silly: 81 bytes without weird input formats or recent GHC versions...

R, 96 bytes
function(a,b)(w<-grep(gsub("",".?",a?b),1:1e4?9999:0)?r<-1e4-w)[w+a<2&r+b<2]
"?"=paste
"+"=adist

Try it online!
Explanation (ungolfed)
function(a,b){
    # Regex inserting ".*": (998,3) => ".?9.?9.?8.? .?3.?"
  regex <- gsub("",".?",paste(a,b))
    # Positions matching in the whole vector of strings that add to 10K ("1 9999", "2 9998", "3 9997", "4 9996", ...)
  w <- grep(regex,paste(1:1e4,9999:0))
    # 10K minus these matching positions
  r <- 1e4-w
    # Form position-string vector of ('pos1 10K-pos1', 'pos2 10K-pos2', ...)
  paste(w,r)[
  # Filter only those positions where the edit distance between the matched numbers and the originals are less than 2
    adist(w,a)<2 & adist(r,b)<2
  ]
}

We assign ? to paste. That lets us do something cool: a<-b?c<-d does inline assignments within the paste call, which we couldn't do with any other operator than ?, since it has lower precedence than <-.
Now as @JoKing kindly pointed out, there can be cases like 900 10 where two insertions could take place such as 9100 8100. So we filter out matches where the number of characters in either number has increased by more than 1. The quick way to do this is with the Levenshtein edit distance adist which we bind to +.

Thanks for checking! I now filter out matches where there is more than one insertion per number.

Pyth, 28 27 25 24 22 20 bytes
fq^;4sT*FmvsmXLkdThl

Try it online here, or verify all the test cases here - the test suite deduplicates the result by prepending a {.
Input is as a list of strings.
fq^;4sT*FmvsmXLkdThldQ   Implicit: Q=eval(input()), T=10
                         Trailing d, Q inferred
         m           Q   Map each input string, as d, using:
                   ld      Take the length of d
            m     h        Map 0 to the above (inclusive), as k, using:
             X  d            Insert into d...
               k             ... at position k...
              L  T           ... each number [0-9]
           s               Flatten the result
          v                Convert each back to an integer
       *F                Take the cartesian product of the result
                         (this generates all possible pairs of mutated numbers)
f                        Keep the pairs, as T, where...
     sT                  ... the sum of the pair...
 q                       ... is equal to...
  ^;4                    ... 10,000 (; == 10 here, so this is 10^4)

Edit 4: Saved another 2 bytes, thanks to Mr Xcoder - v vectorises by default, and L uses m underneath, so mapping over range is implied, making the U unneccesary too
Edit 3: Introduced to global use of ; operator to retain access to 10 to save 2 bytes, thanks to FryAmTheEggman and issacg:
fq^T4sT*FmvMsmXLkdUThl

Edit 2: I forgot the sum operator exists, how embarassing...
Edit 1: Previous version accepted a list of integers as input, performing string conversions manually, for 27 bytes:
fq10000+FT*FmvMsmXLk`dUThl`

Am I wrong, or does your program allow adding leading zeros (which is forbidden in the challenge statement)?

I don't know Pyth too well, but if it has a builtin for 10 and **, can't you do something like 10**4 instead of the literal 10000?

@KevinCruijssen it does indeed, 10 is usually T, but in function blocks the variables are re-purposed to act as iteration variables instead - in the filter block the iteration variable just so happens to be T, so it can't be used. This means that 10 ^ 4 would be ^10 4, which is 5 bytes long, so no shorter unfortunately

@Delfad0r It's OK to add leading zeros while processing the answer, as long as they don't appear in the output. (Since the strings are converted back to integers, that's fine.)

@Delfad0r it does add a leading 0 to each number, but when the conversion back to an integer is performed the leading 0 is removed - edit: what Arnauld said :oP

@Sok Ah ok. So the T in UT is still 10, for the [0,10) range. But at f...T the T has become an iteration variable for the filter. Thanks for the explanation, that makes sense! And doing T4^ earlier, saving it in a variable, and using that variable in the filter is (at least) 5 bytes as well of course.

Sorry, I misread the statement (I had missed the part where it says you are allowed to leave one of the numbers unchanged).

You can replace 10000 with ^;4.

; always has the value of the iteration variable in the global context, in this case 10. So ^;4 is what you're looking for.

I had no idea about that use of ;, every day is a school day it seems! I'll edit it in when I get a chance, thanks :o)

20 bytes: fq^;4sT*FmvsmXLkdThl. (Pyth beating Jelly? o.O Hooray)

The programming style you used, is there any manual for that?

@pushpen.paul There isn't really, you just get to know it as you use it. I'd recommend just playing around with it in the online interpreter, and there's a good guide to the basics of getting to grips with Pyth here

I think you forgot to update the main code block to use the ; - it looks like just the link and the explanation were updated.

Perl 6, 64 bytes
->\a{grep {all (a Z~$_)X~~/^(.*)(.*)$0.?$1$/},(^1e4 Z(1e4...1))}

Try it online!
This is a port of G B's answer using a regex to check if the numbers are valid. Thanks to nwellnhof for porting it.
Old answer, 127 110, 88 bytes
-22 bytes thanks to nwellnhof!
->\a{grep {all ~<<a Z∈.map:{.comb.combinations(.comb-1..*)>>.join}},(^1e4 Z(1e4...1))}

Try it online!
Anonymous code block that takes in a list of two numbers and returns a list of pairs of numbers.
Rather than fiddle about with inserting the digits in, this solution checks every combination of numbers that sum to 10000 and filters that the given numbers are part of the pair.
Explanation:
->\a{  # Anonymous code block that takes an argument a
     grep ... ,(^1e4 Z(1e4...1))    # Filter from all pairs that add to 10000
         {      ~<<a     # Stringify the contents of a
                     .map:{      # Map the pair to
                           .comb  # The digits of the number
                           .combinations(.comb-1..*)  # The combinations of the digits
                           >>.join  # Each combination joined
                           # Note that combinations preserve order
                           # "123" -> (12,13,123)
                          }
          all       Z∈   # Zip that each element of a is an element of the combination
         }
}

Just curious: can't you use the fact that the pairs can be written as (i,1e4-i) instead of iterating over every (i,j) and filtering them?

Ruby, 93 91 bytes
->a,b{(1..r=10000).map{|x|/^(.*)(.*:)\1.?\2(.*)(.*):\3.?\4$/=~[a,x,b,y=r-x]*?:&&[x,y]}-[p]}

Try it online!
Try every single number up to 10000, and use the regex to check if the numbers match.

R, 179 161 150 144 bytes
function(a,b,w=g(a),r=rep(g(b),e=1e4))paste(w,r)[w+r==1e4]
g=function(x,n=sum(x|1)){for(i in 0:n)for(j in 0:9)F=c(F,append(x,j,i)%*%10^(n:0));F}

Try it online!
35 bytes saved by @JayCe and @Giuseppe.
Explanation
Helper function g gets all possible insertions.
g <- function(x,            # Input vector of digits
              n=sum(x|1)    # Length of x
              ) {
  for(i in 0:n)             # i is the insertion point
    for(j in 0:9)           # j is a digit from 0 to 9
      # Dot product of vector of digits with insert and 10^(n:0) performs the
      # conversion to integer (and gets rid of the leading 0s)
      F=c(F,append(x,j,i)%*%10^(n:0))  # F is a non-reserved built-in alias to FALSE (numerically 0)
  F
}

Main function.
f <-
function(a,                 # Input vectors of digits
         b,
         w=g(a),            # Get all possible insertions for a
         r=rep(g(b),e=1e4)  # Insertions for b replicated 1e4 times each
         )
  paste(w,r)[w+r==1e4]      # paste and w+r recycle w to match length of r
                            # Lots of duplication!

I've noticed after the fact that this is essentially the same logic as the Pyth answer.

using string output saves 10 bytes: TIO

@JayCe Saves more than 10 bytes! Deduplication is allowed to take place outside the challenge code.

-11 bytes using F and %*%

let's kill some more bytes - not need for outer, rep is sufficient

I think we're close to sticking a fork in this one!

A different arithmetic approach to generating the combinations for 134 bytes

Javascript (Node) - 183 136 123 Bytes
123 Bytes thanks to Shaggy
a=>b=>(o={},g=(s,h)=>[...s+0].map((y,x)=>{for(y=10;y--;)h(s.slice(0,x)+y+s.slice(x))}))(a,x=>g(b,y=>1e4-x-y?0:o[+x]=+y))&&o

136 Bytes thanks to Arnauld
e=(h,c,i=h.length+1,j)=>{for(;i--;)for(j=10;j--;)c(h.slice(0,i)+j+h.slice(i))}
f=(a,b,c=[])=>e(a,n=>e(b,m=>1E4-n-m||c.push([+n,+m])))||c

Old Code
Not proud of it, but figured I'd submit anyways. Creates a string prototype function akin to map which takes up the bulk of the bytes. Function just iterates through both permutations, and finds when 1000-a-b is 0. Takes input as strings.
String.prototype.e=function(c){let h=this,L=h.length,i,j;for(i=0;i<=L;i++)for(j=0;j<=9;j++)c(h.slice(0,i)+j+h.slice(i,L));}
f=(a,b,c=[])=>a.e(n=>b.e(m=>1E4-n-m?c:c.push([+n,+m])))?c:c

Try it online!
Ungolfed
String.prototype.e=function(c) {
  let h=this,L=h.length,i,j;
  for(i=0;i<=L;i++)
    for(j=0;j<=9;j++)
      c(h.slice(0,i)+j+h.slice(i,L));
}
f=(a, b, c=[]) =>
  a.e(n =>
    b.e(m =>
      1E4-n-m ? c : c.push([+n,+m])
    )
  ) ? c : c

Here are some quick wins. This is basically the same code without the 'golf-unfriendly' statements (String.prototype, function, let, this) and with a few other optimizations.

From there, you can save 4 more bytes by using a map() instead of the outer for loop. NB: the only reason why we use j as the 1st parameter of the callback function is that we want it to be defined in this scope.

@Arnauld thanks I really appreciate it, you’re a legend man. Post your answer tho, I don’t want to take yours, I’m just doing it for fun.

I'm not going to answer my own challenge and this code is just a modification of yours, so feel free to use it. No worries!

Knocked @Arnauld's suggestions down to 123 bytes

Awesome thanks guys, I updated the post!

Japt, 30 29 25 23 bytes
Takes input as an array of strings, outputs an array of arrays of strings.
£L²ôs f_à øX
rï k@L²aXx

Try it

Explanation
£L²ôs f_à øX
£                :Map each X
 L               :  100
  ²              :  Squared
   ô             :  Range [0,L²]
    s            :  Convert each to a string
      f_         :  Remove elements that return false
        à        :    All combinations of current element
          øX     :    Contains X?
rï k@L²aXx
r                :Reduce by
 ï               : Cartesian product
   k@            :Remove each X that returns true (not 0)
     L²          :  100 squared
      a          :  Absolute difference with
        Xx       :   X reduced by addition

PHP, 162 159 bytes
lovely example for a generator function!
function f($n){for($n+=.1;$n>=1;$n/=10)for($d=-1;$d++<9;)yield strtr($n,".",$d)/10|0;}foreach(f($argv[1])as$x)foreach(f($argv[2])as$y)$x+$y-1e4||print"$x+$y\n";

takes input from command line arguments; prints duplicates. Run with -nr '<code> or try it online.

Pyth, 18 bytes
fqsT^;4*FsMvXLRRTT

Demonstration, test suite (test suite is deduplicated with leading {).
The input is in the form of a list of two strings.
XLRRTT: L and R perform nested maps. Since there are 3 of them, we will perform a triply nested map of the X function. In this case, the X function will insert a character at a designated position into a string.
The string is the input, which is implicit and placed by the first R. The character ranges over 0 ... 9, so we have all possible inserted digits, and is placed by the L. The range is given by T, which is implicitly set to 10, which is implicitly treated as [0 ... 9]. The position ranges over 0 ... 9, which is sufficient, because inserting a number after the 10th position will never be useful. Duplicate results are fine. The range is placed by the second R, and given by the second T.
v: Nested cast strings to ints.
sM: Flatten the second level of lists, leaving us with a list of all possible numbers after digit insertion, for each of the input numbers.
*F: Take the Cartesian product of the two lists of possible numbers.
fqsT^;4: Filter on the pairs whose product is 10000. ; takes the value of 10 here, as T is in use as the filter variable, and ; always as the value of the variable which is in use.

Jelly, 30 bytes
DµJṬ€k€jþ9Ż¤;9R¤;€$ḌF)ŒpS=ȷ4ƊƇ

Try it online!
Kind of clumsy because Jelly has no insertion.
Explanation
                                   Given [a, b].
Dµ                   )             Get [digits(a), digits(b)] then map:
  JṬ€k€jþ9Ż¤;9R¤;€$ḌF                Generate all the insertions.
                      Œp           Cartesian product: get all pairs.
                        S=ȷ4ƊƇ     Filter for: sum equal to ȷ4 (10000).

                       Given e.g. [6,3,5]:
J                      Get [1,2,3].
 Ṭ€                    Get [[1], [0,1], [0,0,1]].
   k€                  Split input with these: gets us
                         [[6],[3,5]] , [[6,3],[5]] , [[6,3,5],[]]
     jþ9Ż¤             Join table-wise with [0..9]
                         → [[[6,0,3,5], [6,3,0,5], [6,3,5,0]],
                            [[6,1,3,5], [6,3,1,6], [6,3,5,1]], …]
          ;9R¤;€$      Append the prefixings of the input by [1..9].
                           [[1,6,3,5], [2,6,3,5], [3,6,3,5]]…
                 ḌF    Undigits all, and flatten.

Python 3, 165 160 153 125 117 bytes

Saved 5 bytes thanks to @JackBrounstein suggestion to remove set from the return value, as the output can contain duplicates.
Saved 7 by replacing range(len(s)) with range(5).
Saved 23 bytes thanks to @Eric Duminil's suggestion to replace itertools with nested list comprehensions (and removing a space).
Saved 8 thanks to @Jo King's suggestion to replace nested list comprehension with a single loop and modulus operator.

Using itertools and a simple helper function.  Accepts strings as input, returns a set of ints as output.
c=lambda s:[int(s[:i%5]+str(i//5)+s[i%5:])for i in range(50)]
lambda a,b:{(i,j)for i in c(a)for j in c(b)if i+j==1e4}

Because the output can include duplicates, you don't need to call set in the last line for -5 bytes.

@JackBrounstein, Thanks.  I missed that part of the rules.

@EricDuminil, Thanks.  I did not know about set comprehensions, that's a neat trick.

117 bytes

@JoKing Clever. After all these suggestions the solution barely resembles what I started with.

Stax, 24 bytes
⌐çΘ♠╖øû°-h∟ñµ%üw▲∞Ç╫[½π=

Run and debug it
Those program takes its two inputs as an array of strings, like this.
["934", "654"]

Charcoal, 33 bytes
ΦＥ×χφＩ⟦ι⁻×χφι⟧⌊Ｅι№Ｅ⊕ＬλΦλ⁻ξρ§⟦θη⟧μ

Try it online! Link is to verbose version of code. Explanation:
   χ                                10
    φ                               1000
  ×                                 Multiply
 Ｅ                                  Map over implicit range
       ι    ι                       Current value
        ⁻×χφ                        Subtract from 10000
      ⟦      ⟧                      Pair of values
     Ｉ                              Cast to string
Φ                                   Filter
                ι                   Current pair
               Ｅ                    Map
                     λ              Current value
                    Ｌ               Length
                   ⊕                Increment
                  Ｅ                 Map over implicit range
                       λ            Current value
                      Φ             Filter over characters
                         ξ          Range value
                          ρ         Character index
                        ⁻           Subtract
                            ⟦θη⟧    Original inputs as a list
                                μ   Index of current value
                           §        Get input at that index
                 №                  Count matching values
              ⌊                     Minimum
                                    Implicitly print each pair double-spaced

In case you didn't understand that, it runs through all the pairs of values that add to 10000 (as strings), then counts how many times each input matches against the result of deleting up to 1 character from the respective value. If the minimum count is nonzero then both inputs matched and this is a possible solution.

Ruby, 110 bytes
Accepts strings as input, returns an array of array of integers.
Based on the python version. For a given integer, C creates an array of numbers that can be created by adding a digit.
The lambda iterates over every possible pair and selects the one whose sum is 10000.
C=->n{(0..49).map{|i|([n[0...i%5],i/5,n[i%5..-1]]*'').to_i}}
->(a,b){C[a].product(C[b]).select{|i,j|i+j==1e4}}

Try it online!

05AB1E (legacy), 36 bytes
0ìε.œʒg3‹}εU9ÝεXDgiìësý}}}˜}`âʒOT4mQ

Can without a doubt be golfed substantially.. Especially inserting the digits, including a leading/trailing one.
Try it online or verify all test cases (ê in the footer is to Uniquify & Sort).
Explanation:
0ì                            # Prepend a 0 before each of the input numbers
  ε                        }  # Map each to:
   .œ                         #  Take all possible partitions
     ʒg3‹}                    #  Only keep those of length 1 or 2
          ε              }    #  Map each partition to:
           U                  #   Pop and store the partition in variable `X`
            9Ý                #   List in the range [0, 9]
              ε         }     #   Map each of those digits to:
               X              #    Get the variable `X`
                Dgi           #    If it's a single number (length == 1):
                   ì          #     Prepend `X` before this digit
                  ë           #    Else (length == 2):
                   sý         #     Join both numbers in `X` with the current digit
                  }           #    Close the if-else
                          ˜   #   Flatten the list of lists
`                             # Now push both lists to the stack
 â                            # Create all possible pairs (cartesian product)
  ʒ                           # Filter this list of pairs by:
   O                          #  Take the sum of the two numbers
    T4m                       #  Push 10000 (10^4)
       Q                      #  And check if they are equal

Jelly, 23 bytes
œcL’$$€ċ"⁹o⁼"Ạ
ȷ4ḶṚĖDçƇ

A monadic link accepting a list of lists of digits
(e.g. for the example of 923 and 72 the input is [[9,2,3],[7,2]])
Try it online! (footer makes it so I/O is a pair of two integers in and a [formatted] list of pairs of integers out)
Or see the test-suite.
How?
Checks all the pairs of "numbers" (lists of digits) which sum to 10000 for validity by forming all ways to choose n-1 digits from those "numbers" maintaining order; and keeps those which are valid (where validity also allows for the "number" under test to be equal to the original "number").
œcL’$$€ċ"⁹o⁼"Ạ - Link 1, is piar valid?: pairToCheck, originalInputPair
      €        - for each list of digits in pairToCheck: e.g. [9,2,3]
     $         -   last two links as a monad:
    $          -     last two links as a monad:
  L            -       length                                 3
   ’           -       decremented                            2
œc             -     choices of that many items               [[9,2],[9,3],[2,3]]
         ⁹     - chain's right argument (originalInputPair)
        "      - zip with: (i.e. apply the following f(x,y) *respectively* across the results above and the originalInputPair)
       ċ       -   count occurrences
            "  - zip with (this time with an implicit right argument of originalInputPair)
           ⁼   -   equal (non-vectorising version)
          o    - locgical OR (vectorising version) i.e. we now have: [OR(isOneDigitLonger(item1),isEqual(item1)), OR(isOneDigitLonger(item2),isEqual(item2))]
             Ạ - all?

ȷ4ḶṚĖDçƇ - Main Link: list (pair) of lists of digits
ȷ4       - literal 10^4 -> 10000
  Ḷ      - lowered range -> [0,1,2,...,9998,9999]
   Ṛ     - reversed -> [9999,9998,...,2,1,0]
    Ė    - enumerate -> [[1,9999],[2,9998],...,[9998,2],[9999,1],[10000,0]] (N.B. last is redundant, but this does not matter)
     D   - to decimals -> [[[1],[9,9,9,9]],[[2],[9,9,9,8]],...,[[9,9,9,8],[2]],[[9,9,9,9],[1]],[[1,0,0,0,0],[0]]]
       Ƈ - filter keep those for which this is truthy:
      ç  -   call last link as a dyad (with a right argument of the pair of lists of digits)

Vyxal, 43 bytes
⌐ƛ⟨⟩n£¥Lʀ(x|n¬₀r(¥CC←x nSṀṅIJ));ḣhẊ'∑k2=

Try it Online! Takes input of the form: "a,b"
Explanation:
?⌐ƛ⟨⟩n£¥Lʀ(x|n¬₀r(¥CC←x nSṀṅIJ));ḣhẊ'∑k2= # full program
?⌐                                       # split implicit input on ","
  ƛ⟨⟩n£¥Lʀ(x|n¬₀r(¥CC←x nSṀṅIJ));         # "insert" lambda map over input
                                ḣh       # unlist them
                                  Ẋ      # cartesian product [a,b]*[c,d]=[[a,c],[a,d],[b,c],[b,d]]
                                   '∑k2  # filter lambda, sum of pair == 10000

The insert lambda can definitely be improved, but I am having trouble figuring out a way to map it instead of explicitly loop over it.

Jelly, 25 bytes
LŻœṖ€z⁶ZjþØDVẎṢḊ)p/S⁼ȷ4ƊƇ

Try it online!
Not the shortest Jelly solution here but maybe someone can golf this? I am stumped


text:
Regular Expression to find a pangram
Awhile back I encountered a simple programming puzzle to determine whether a string was a pangram, or a perfect pangram. (Although it's worth noting that this particular challenge gave a different meaning than the standard definition of a "perfect pangram," to mean any sentence where every letter appears n times for some positive n). And it was a fun challenge. But recently it got me wondering whether it would be possible to solve this challenge purely with regular expressions. If it is, I expect it will be a pretty gnarly regex. But I'm not even sure it is possible.
Still, if anyone is able to do it, it would be the folks here at Code Golf. So here's the challenge:
Write a regular expression which can determine whether or not a given string is a pangram. You can assume that all non-alpha characters have already been stripped out (or don't, if you really want to challenge yourself), and that everything has been transformed into lowercase.
Bonus challenge: write another regular expression to determine whether the given string is a "perfect pangram" by the definition given above.
Examples of an ordinary pangram:

thequickbrownfoxjumpsoverthelazydog

Example of perfect pangrams:

abcdefghijklmnopqrstuvwxyz
jocknymphswaqfdrugvexblitz
squdgykilpjobzarfnthcwmvexhmfjordwaltzcinqbuskpyxveg

I'm not really sure if this is even possible just with regex alone. If you find that it is, kudos!

Pity that Martin is on leave

Pangram, not anagram

Quoted verbatim from the question above (read the question): "any sentence where every letter appears n times for some positive n."

Let me rephrase, as my previous comment was a mess: 1) This needs a winning criterion. Code golf? 2) Bonuses are almost always a bad idea. There should be a single task/objective to the challenge. Having two is confusing, and probably useless, as people will go fot the easier one. 3) What flavours of regexes are allowed?

Not sure what regexes are able to do, but the grammar is certainly not regular which can easily be proven with the Pumping Lemma (just set $w = a^p b^p \cdots z^p$) - so it's likely a regex won't not do the job (it's regular-expression after all).

Thinking about this a bit more: I don't have background in theoretical CS/automata theory, so I could be missing something, but doesn't the pumping lemma allow you to duplicate the entire string?  In your example, ww would also be a valid perfect pangram.

@BMO I'm well aware that regex is not well-suited for this task... but that's part of the fun, and why I'm asking here at code golf.

Assuming you're using a flavor of regex that include look-aheads, detecting a pangram is straightforward, but tedious.  Using Python syntax:
r"(?=.*a)(?=.*b)(?=.*c)(?=.*d)(?=.*e)(?=.*f)(?=.*g)(?=.*h)(?=.*i)(?=.*j)(?=.*k)(?=.*l)(?=.*m)(?=.*n)(?=.*o)(?=.*p)(?=.*q)(?=.*r)(?=.*s)(?=.*t)(?=.*u)(?=.*v)(?=.*w)(?=.*x)(?=.*y)(?=.*z).*"
https://regex101.com/r/Z7NjEQ/2
The (?=.*a) block tests if what follows after that point matches .*a; another way to say that is, is this expression followed by any characters and then an a, or just, does this include an a?  Then repeat that check for every letter of the alphabet.
Without lookaheads, it's still possible, but even more tedious, because you have to account for every possible ordering of the alphabet.  If you were limited to the letters abc, here's what it might look like:
r".*(a.*b.*c|a.*c.*b|b.*a.*c|b.*c.*a|c.*a.*b|c.*b.*a).*"
https://regex101.com/r/OnXQe7/1/
This checks for an a, any set of characters, a b, any set of characters, then a c, OR an a, any set of characters, a c, any set of characters, then a b, OR...you get the idea.
You could use the same approach to check for the standard meaning of perfect pangram (every character exactly once), but not the modified version used here.

This doesn't work for abcdefghijklmnopqrstuvwxyza..

That link shows abcdefghijklmnopqrstuvwxyza as matching the regex, which is correct, though?  I'm specifically answering the ordinary pangram question, not the perfect pangram.

Nvm, I misunderstood the question.. I thought that an ordinary pangram is just a generalized pangram where $n = 1$. Sorry about that!

No worries.  If you want a perfect pangram with n=1, you could specify that the matching string has exactly 26 characters: https://regex101.com/r/Z7NjEQ/4
You could also extend this to work for any given n, but I don't know of a way to extend it to all n.

True, yeah I think it's not possible for all n (see my comment on the challenge itself), though I'd be happy to be proven wrong.

I believe you're right for pure regular expressions, but many regex engines have support for additional features/types of match that might allow it.  Regular expressions shouldn't be able to match palindromes, either, but PCRE can do it.  I don't know enough about those advanced features to see how it would work, but I'd lean very slightly toward it being possible.

Regexp: 45 43 20 19 18 bytes
(?!.*(.).*\1).{26}

Assuming the input is [a-z] (lowercase, only alphabets a to z, spaces etc removed)
A byte saved, thanks to Neil

If you're assuming the input format then . instead of \w?

@Neil oh, thanks, stupid me

@Shaggy "You can assume that all non-alpha characters have already been stripped out", just notified about the assumption

This doesn’t work for either the regular challenge or the bonus. Doesn’t match thequickbrownfoxjumpsoverthelazydog (regular pangram) or squdgykil... (the bonus).