[Question]
  [
Let's solve [this user's homework](https://stackoverflow.com/q/64768698/509868); I think it's an interesting exercise!
### Input
Two 3-digit natural numbers.
### Outputs
Two 2-digit numbers. In each of the output numbers, one digit is taken from one input number, and the other from the other number. The choice is independent. The first output number should be the minimal possible to create using these constraints, and the second one should be the maximal such number (or vice versa).
* Input numbers never have leading zeros; output numbers should also not have leading zeros.
* Input and output can be encoded as numbers, strings, lists of digits, etc.
---
Examples (in format `input` - `output`):
```
123, 912 - 11, 93
888, 906 - 68, 98
100, 100 - 10, 11
222, 222 - 22, 22
123, 222 - 12, 32
798, 132 - 17, 93
```
  
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~15 14 13~~ 9 bytes
```
§,▼▲f←ṁP*
```
[Try it online!](https://tio.run/##yygtzv7//9BynUfT9jyatintUduEhzsbA7T@//8fbahjpGMc@z/aUgfIigUA "Husk – Try It Online")
Takes two input arrays, outputs pair `(min,max)`.
-1 byte from Dominic Van Essen.
-1 more byte from Dominic Van Essen (after some more struggling).
-4 bytes taking arrays of digits as input.
## Explanation
```
§,▼▲f←ṁP*
        * cartesian product pairs of the inputs
      ṁP  map each to permuations, and flatten the list
    f←    remove elements where first digit is falsy(<10)
§,        create pair with
  ▼▲      minimum and maximum
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~11~~ 10 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
â€Â9ÝKWsà‚
```
-1 byte thanks to *@ovs*.
[Try it online](https://tio.run/##ASMA3P9vc2FiaWX//8Oi4oKsw4I5w51LV3PDoOKAmv//MTIzCjkxMg) or [verify a few more test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfWXC/8OLHjWtOdxkeXiud3jx4QWPGmb91/kfHW1sYKZjYWQSqxNtaGCgA8RAlrGlkY6lsQVIzNBQx9LSMjYWAA).
**Explanation:**
```
â           # Take the cartesian product of the digits of the two (implicit) inputs
 €Â         # Bifurcate each value within the list (short for Duplicate & Reverse copy)
   9Ý       # Push the list [0,1,2,3,4,5,6,7,8,9]
     K      # Remove those integers (so all integers with leading 0s)
      W     # Take the minimum of this list (without popping the list itself)
       s    # Swap so the list is at the top of the stack again
        à   # Pop and push its maximum
         ‚  # And pair the minimum and maximum together
            # (after which it is output implicitly as result)
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 15 bytes
```
{∋ᵐpcℕ₁₀}ᶠ⟨⌋≡⌉⟩
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/pfXa6koGunoFSu9qhtw6Ompoe7Omsfbp3wv/pRRzeQLkh@1DL1UVPjo6aG2ofbFjyav@JRT/ejzoWPejofzV/5/390tKGRsY6CpaFRrI5CtIWFBZBtYAZiGxoY6CgACRDbyMhIRwFIxMYCAA "Brachylog – Try It Online")
```
{∋ᵐpcℕ₁₀}ᶠ⟨⌋≡⌉⟩
{       }ᶠ      find all possible outputs:
 ∋ᵐ               select a digit from each number
   p              permute them
    c             merge them to a number
     ℕ₁₀          that number is >= 10
                with the list of all possible numbers:
          ⟨⌋≡⌉⟩ [minimum, maximum]
```
First time using `⟨⟩`! :-⟩
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 11 10 bytes
```
p;p@ḷ/ƇṢ.ị
```
[Try it online!](https://tio.run/##y0rNyan8/7/AusDh4Y7t@sfaH@5cpPdwd/f/w8uV/v@P5oo21DHSMY7V4Yq20AFCEMNQx0DHAMQwAkoZARmxIHWWOoZgDpBhoGOGXR0A "Jelly – Try It Online")
Dyadic link. Input and output is a list of digits.
## Explanation
```
p;p@ḷ/ƇṢ.ị
p            Cartesian product
 ;           Join with
   @         Reverse arguments
  p            Cartesian product
      Ƈ      Filter by
     /         Reduce by
    ḷ            First argument
       Ṣ     Sort
        .ị   First and last element
```
*-1 byte by using the `.ị` technique to get the first and last element, thanks to caird*
[Answer]
# [Python 3](https://docs.python.org/3/), 81 bytes
```
lambda a,b:[m(k for i in a for j in b for k in(i+j,j+i)if'1'<k)for m in(min,max)]
```
[Try it online!](https://tio.run/##VcpNDsIgEIbhvadgN5Cy4CcxaOpJ1AXEEAeENk0XenpkujB2M3nzfDN/1udUbYuXW3v5Eh6eeRnO18Izi9PCkGFlfstEGbbMPTkOSaYBBUbQMGZBQ6GhYJXFv8W9zQvWlUcO2liQcNIGhDj81DlHqo471Up1pfuvxpiudHeq6dcq3bV9AQ "Python 3 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 62 bytes
```
a!b=(`foldl1`[s|i<-a,j<-b,s<-[[i,j],[j,i]],s>"1"])<$>[min,max]
```
[Try it online!](https://tio.run/##JY7RaoQwEEXf/Ypb2QeFyWKysFiI@7Zv/YMQMGK2jY2xqNAt9N/thL7cOVxmDvPhtk8f43G4l6Gr@scSxyh7s/0GLRxNWgy0aWFMoMmSmShYS9utlKWt9elm5pBodk97zC4kdBiXAjCOBnrSj4UW@F7WccMZjxB3v6Lq07Lfo597lCTKGmzBu9/fQvJ8@rWGtOOEit@pu85kC9fZfkh1IbxKBQEpmS5F27Y8mys310xtIZuGwJF3MslCKUXg4Oaf/gA "Haskell – Try It Online")
This is the same approach as Jitse's Python answer.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~233~~ \$\cdots\$ ~~189~~ 185
Saved 4 bytes thanks to [gastropner](https://codegolf.stackexchange.com/users/75886/gastropner)!!!  
Saved ~~9~~ 13 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!
```
#define d(a,i)for(qsort(a,i=3,1,L"\xf06be0f\xd02917beǃ");a[--i]<49;);
s;j;i;f(a,b)char*a,*b;{d(a,i)d(b,j)s=a[2];i=a[i]<b[j]?s=b[2],a[i]:b[j];j=*a;*b++=j>*b?j=*b,*a:*b;*a++=i;*a=s;*b=j;}
```
[Try it online!](https://tio.run/##bZPfb5swEMff81dYVJGAOBo/UgJ1aR@6ve0/AFTZxrSQFTLMJNYoT/vj@l8tOwxhkAYJzv7q7nN3@MzXL5yfTjepyPJSoFSnODeyqtZ/yqpuul3oYht/1@I2szwmrCxuU8sJ7C0TH380g9Bovc6T@01ADLKQpCA5ySCMGfyV1ibFJiOHnprqDBeGDGnkJCQHA2EsKpJHGTKQcCfcdQIpQpMSk61WYfFgskfYMmzSO0CZFMQcTCjBISzI8ZSXDXqjeakbi8MCwaMSo0bI5plGCQghOmi242oYab7vd8a2rM44g3EcJTpWb9yJ2Qa@diSXXDZyA1vFBpY34QYzrrtRu82tN03mOnOuaPeCNyIFsqrXxihQFXg@rIaqMbLtvnDQnB6H0UAEbdOvNhh5QxMYub22VbxZSv4q@E7UYy9x@82J2@Br3PpPXcywf4J3jITRQHr3y/MyFS2EWWRY3iOZv4sq08@dGF8GwRwVglYr5W2g/qz@F0OfeVXKBojDySm/hMzcEI3gF09E2dR8/xvGawg3yAWWzbHsOpZdxzLMPmH3NXSf6dpSYrSUaP2ANEwxYhOXfv4vUlS/msibphhAoGNtyZcccPDVYNDhJtgJXBwMZSWfOhLQyzgsl910J1PtwKPr4G2v6EhcLR@qj0s4ZuVyHoVqF4bWOedxcTz95dkP@iJP63fRCi4bynf/AA "C (gcc) – Try It Online")
Inputs two \$3\$-digit strings and returns the min and the max as \$2\$-digit substrings in the first \$2\$ digits of the first and second input string respectively.
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 38 bytes
```
Lw$`(.).*,.*(.)
$1$2¶$2$1
A`0.
O`
,,G`
```
[Try it online!](https://tio.run/##K0otycxLNPyvquGe8N@nXCVBQ09TT0tHTwtIc6kYqhgd2qZipGLI5ZhgoMfln8ClowNU99/QyFjH0tCIy8LCQsfSwIzL0MBAB4i5jIyMdIAYAA "Retina – Try It Online") Link includes test cases. Explanation:
```
Lw$`(.).*,.*(.)
$1$2¶$2$1
```
Take the cartesian product of the inputs and their reverses.
```
A`0.
```
Remove entries with leading zeros.
```
O`
```
Sort.
```
,,G`
```
Take the first and last result.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~12~~ 11 bytes
```
p;U$Ḍ>Ƈ9Ṣ.ị
```
[Try it online!](https://tio.run/##y0rNyan8/7/AOlTl4Y4eu2Ptlg93LtJ7uLv7v8vhdv1HTWv@/482NDLWUbA0NIrVUYi2sLAAsg3MQGxDAwMdBSABYhsZGekoAIlYAA "Jelly – Try It Online")
Input as a list of digits (which the Footer does for you)
-1 byte [thanks to](https://codegolf.stackexchange.com/questions/214981/make-a-minimal-and-maximal-2-digit-number-from-digits-of-two-3-digit-numbers/214988?noredirect=1#comment502676_214988) [Unrelated String](https://codegolf.stackexchange.com/users/85334/unrelated-string)
## How it works
```
p;U$Ḍ>Ƈ9Ṣ.ị - Main link. Takes x on the left and y on the right
p           - Cartesian product of the digits. Call this list X
   $        - Group the previous two commands into a monad f(X):
  U         -   Reverse each pair in X
 ;          -   And append it to X
    Ḍ       - Convert each pair back to an integer
      Ƈ     - Keep those which:
     >      -   Are greater than:
       9    -   9
        Ṣ   - Sort
         .ị - Take the first and last elements
```
[Answer]
# [Python 2](https://docs.python.org/2/), 70 bytes
```
lambda*l:[m(m(set(l[i])-{'0'})+m(l[~i])for i in(0,1))for m in min,max]
```
[Try it online!](https://tio.run/##VcpBCsIwEIXhvafILolGmElBWsGT1C4iGgxk0lKzUESvHicuxG4e/B9veuTrmGzxh2OJjk5nt477nhSp2yWr2IdBb58S5EtviPPN7cdZBBGSAoP6W8QlKCRD7j6UaQ4pK68k2kYa2aGVWq9@2rZtVdgtFAFY6/6rtZa17kKxfhtA1vIB "Python 2 – Try It Online")
**[Python 3](https://docs.python.org/3/), 70 bytes**
```
lambda a,b:[m(m({*a}-{'0'})+m(b),m({*b}-{'0'})+m(a))for m in(min,max)]
```
[Try it online!](https://tio.run/##VcpNCsIwEEDhvafIbmY0Qn5AquBJ1MUECQactJQulNKzx2Qj7eYtPt7wnV599iVe7@XNEp6sWIfLTVBw3vNynMHAQgfBQLpRWBETxX5UolJGSVkLf@hRhjHlCSOCdR40nK0Dot1fu65rak4btcZUbV2rc65q60Zte72xVcsP "Python 3 – Try It Online")
These could be shorter if we can take a list of digits as numbers.
[Answer]
# JavaScript (ES6), 80 bytes
Expects a pair of 3-digit strings. Returns a pair of 2-digit integers.
```
a=>[(g=n=>(a+[,a]).match(~~(n/10)+'\\d*,\\d*'+n%10)?n:g(n+d%7-2))(d=10),g(d=99)]
```
[Try it online!](https://tio.run/##dc9LCoMwEAbgvadwI0lq1CSCJoXYg6iL4KstNpYqXXp1m0ilpdLFzA/DxzBzVU81Vo/LfQr0UDdLKxclsxx2UssMKj/HqkThTU3VGc4z1BElyAdFUR@wbcDXnpmc9LGD2q@9NGAIwVqaGe5MCoHKpRr0OPRN2A8dbGEOKIsBdoGgDJQIuVHkUopdETu/kHO@QpJsMOEG8h2khFhoY9tIsNm6g4wxC228IWPYlPPnxi9IDYz3MBXrjTT@wNQ@s7wA "JavaScript (Node.js) – Try It Online")
### How?
We use `a+[,a]` to concatenate `a[]` with itself, with a comma in between. For instance, `['123', '912']` is turned into `'123,912,123,912'`. (We only need the first 3 entries, but the 4th one is harmless.)
We use the recursive function `g` to look for some 2-digit integer `n` such that the above string matches `~~(n/10)+'\\d*,\\d*'+n%10`. That is to say:
* \$\lfloor n/10\rfloor\$ (the 'left' digit of \$n\$)
* followed by some optional digits
* followed by a comma
* followed by some other optional digits
* followed by \$n\bmod 10\$ (the 'right' digit of \$n\$)
We add \$(d\bmod 7)-2\$ to \$n\$ between each recursive call, where \$d\$ is also the starting point:
* \$d=10\rightarrow (d\bmod7)-2=1\$, so we go from \$n=10\$ to \$n=99\$ (looking for the lowest valid integer)
* \$d=99\rightarrow (d\bmod7)-2=-1\$, so we go from \$n=99\$ to \$n=10\$ (looking for the highest valid integer)
[Answer]
# [Desmos](http://desmos.com/calculator), ~~9+68+147+30+49+64+27+27+8+8+51=488~~ 9+68+93+30+49+28+9+9+8+8+33+31+27=402 bytes
Before you even go on I just want to say that I tried my hardest to golf this, but in the middle of doing this I already knew this was far from a competing answer. But by that time though, I was too far in, so I decided to continue. Upvote for effort? Or not.
## Expression 1: 9 bytes
```
g=[0,1,2]
```
## Expression 2: 68 bytes
```
f(n)=\operatorname{floor}(\frac{\operatorname{mod}(n,10^g10)}{10^g})
```
## Expression 3: ~~147~~ 93 bytes
```
h(a,b)=\left\{s[1]p[1]=0:j(\min(s[k(s)+1],p[k(p)+1]),q(s)+q(p)),d(j(\min(s),\min(p)))\right\}
```
## Expression 4: 30 bytes
```
q(a)=\left\{k(a)=0:a,0\right\}
```
## Expression 5: 49 bytes
```
k(a)=\operatorname{total}(\left\{a=0:1,0\right\})
```
## Expression 6: ~~64~~ 28 bytes
```
l(a,b)=d(j(\max(s),\max(p)))
```
## Expression 7: ~~27~~ 9 bytes
```
s=d(f(a))
```
## Expression 8: ~~27~~ 9 bytes
```
p=d(f(b))
```
## Expression 9: 8 bytes
```
w=h(a,b)
```
## Expression 10: 8 bytes
```
z=l(a,b)
```
## Expression 11: ~~51~~ 33 bytes
```
m(a,b)=j(10w[1]+w[2],10z[2]+z[1])
```
## Expression 12: 31 bytes
```
j(a,b)=\operatorname{join}(a,b)
```
## Expression 13: 27 bytes
```
d(a)=\operatorname{sort}(a)
```
[Try It On Desmos](https://www.desmos.com/calculator/bgn7vdhzux)
[![](https://i.stack.imgur.com/0DYnP.png)](https://i.stack.imgur.com/0DYnP.png)
The function \$m(a,b)\$ is the function where you need to input the two numbers in.
Prettified version: [Try It On Desmos!](https://www.desmos.com/calculator/lw1da4lh3r)
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 19 bytes
```
q~m*_Wf%+:iA,-$(\W=
```
[Try it online!](https://tio.run/##S85KzP3/v7AuVys@PE1V2yrTUUdXRSMm3Pb/fyULCwslBSVLAzMlAA "CJam – Try It Online")
Takes input as two strings and outputs two integers.
```
q~                    e# Push inputs                      "888" "906"
  m*                  e# Cartesian product                ["89" "80" "86" "89" "80" "86" "89" "80" "86"]
    _Wf%              e# Make a reversed copy             ["89" "80" "86" "89" "80" "86" "89" "80" "86"] ["98" "08" "68" "98" "08" "68" "98" "08" "68"]
        +:i           e# Join and parse to integers       [89 80 86 89 80 86 89 80 86 98 8 68 98 8 68 98 8 68]
           A,-        e# Remove the numbers from 0 to 9   [89 80 86 89 80 86 89 80 86 98 68 98 68 98 68]
              $       e# Sort                             [68 68 68 80 80 80 86 86 86 89 89 89 98 98 98]
               (\     e# Uncon from left                  68 [68 68 80 80 80 86 86 86 89 89 89 98 98 98]
                 W=   e# Get the last element             68 98
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 30 bytes
```
Ｆ²⊞υＳ⟦⌊Ｅυ⁺⌊⁻ι0⌊§υ¬κ⌈Ｅ⟦υ⮌υ⟧⭆ι⌈λ
```
[Try it online!](https://tio.run/##RY1PC8IwDMXv@xRlpwQqVK87edxhUvQ4diizumLXjv4Z@/a1VZyBQPJ@7yXjJNxohU7pYR2BExIe/QSRktYsMdyCU@YJiE3F8xSg75RRc5yhE0txcR097JoyeVOU1KxGpOSnn0Nr7nIr/osN8MJPZS62/Vaf4VWu0nkJEQdKvq8LUn@nLsEBm5SOjFW502HVbw "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｆ²⊞υＳ
```
Input the two numbers as a pair of strings.
```
⟦
```
Separate the two outputs.
```
⌊Ｅυ⁺⌊⁻ι0⌊§υ¬κ
```
For each string, string take the minimum digit with `0` excluded and the minimum digit of the other string, then take the minimum result.
```
⌈Ｅ⟦υ⮌υ⟧⭆ι⌈λ
```
Of the pair and its reverse, take the maximum digit of each string, then take the maximum result.
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt#L187), ~~33~~ 32 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
─■myG‼<≥xα─6ö6‼≥<3≥\;]─gÅ£(_╓\╙α
```
Input as a paired list of digits.
Sometimes this language is so frustrating to work with.. :/ It has a cartesian builtin, but it only works on single lists (creating pairs of itself). It also has a convenient `‼` builtin to apply two commands separately to the stack, but this isn't implemented (yet?) for the minimum/maximum builtins (otherwise the `_╓\╙α` could have been `‼╓╙α`)..
[Try it online.](https://tio.run/##y00syUjPz0n7///RlIZH0xbkVro/athj86hzacW5jUAhs8PbzIACQL6NMZCIsY4FCqYfbj20WCP@0dTJMY@mzjy38f//6GgLHSCM1Ym21DHQMYuN5YqONgSyDIAiEBokYqQDhEARCA0SMQar1gHqNtIxgeoy0jEGm2OhY45TDRCC1QBhbCwA)
**Explanation:**
```
─           # Flatten the list of list of digits
 ■          # Take the cartesian product of this flattened list
  m         # Map over each pair:
   y        #  And join them together to a single integer
            # (note: since we're joining integers, the `m` implicitly converts them to
            # integers as well, removing potential leading 0s)
    G       # Push 12
     ‼      # Apply the following two commands separated on the stack:
      <     #  Slice to only keep the first 12 items in the list
       ≥    #  Slice to remove the first 12 items from the list and keep the remainder
        x   # Reverse the second list
         α─ # Merge the lists together again (wrap in a pair; flatten)
6ö          # Loop 6 times, using the following 7 commands as body:
  6         #  Push 6
   ‼        #  Apply the following two commands separated on the stack:
    ≥       #   Slice to remove the first 6 items from the list and keep the remainder
     <      #   Slice to only keep the first 6 items in the list
      3≥    #  Slice to remove the first 3 items of this sextet
        \   #  Swap the top two lists on the stack so the remainder is at the top
  ;         # After the loop: discard the top of the stack (the final remainder)
   ]        # Wrap all triplets into a list
    ─       # And flatten it
```
We now have all possible pairs (including their reversed pairs).
```
g           # Filter this list of pairs by,
 Å          # using the following 2 commands as body:
  £         #  Get the length of this integer
   (        #  Decrease it by 1
            #  (so 0 for single digit numbers; 1 for intended two-digit numbers)
    _       # Duplicate this list of pairs
     ╓      # Pop and get its minimum
      \     # Swap so the duplicated list is at the top
       ╙    # Pop and get its maximum
        α   # And pair them together
            # (after which the entire stack joined together is output implicitly)
```
[Answer]
# Scala, 78 bytes
```
a=>b=>{val z=for(x<-a;y<-b;c<-Seq(""+x+y,""+y+x)if"09"<c)yield c;z.min->z.max}
```
[Try it online!](https://scastie.scala-lang.org/ysthakur/yMNczRpGSYunrPUN9CFq4A/30)
Apparently, just storing it in a variable is shorter than folding over all the permutations. Accepts two strings (curried) and returns a 2-tuple of strings.
# Scala, 109 bytes
```
a=>b=>((-1>>>1,0)/:(for(x<-a;y<-b;c<-Seq(""+x+y,""+y+x)if"09"<c)yield c.toInt)){(t,|)=>(t._1 min|,t._2 max|)}
```
[Try it online!](https://scastie.scala-lang.org/ysthakur/yMNczRpGSYunrPUN9CFq4A/26)
[Answer]
# [Zsh](https://www.zsh.org/), 90 bytes
```
for d (${(o)=${(s::)@}})((e&~a&&(a=e,b=d),${z=$d},f=e,e=d))
<<<${z/0/$a}${z/[^0]/$b}\ $d$f
```
[Try it online!](https://tio.run/##LYrLCsMgEEX3foWLQWZA0FgoJij0P/oAg0p3gWaXYH/djtDFuRwO99jfvSJhr9tHZolw4kaRd18WurVGiEV9k1KYYtFrzKThPCLkpiuHwoFECIGjsQZSG3J/2aeBtT0kZKidhKhychc5T47Ney9nex3N2gGbc27w/7H1Hw "Zsh – Try It Online")
`${(o)=${(s::)@}}` sorts the digits, which we loop over. By the end of the loop, we have the following parameters set:
* `z`: The smallest digit
* `a`: The smallest non-zero digit
* `b`: The second-smallest non-zero digit
* `d`,`e`: The largest digit
* `f`: The second-largest digit.
If `z` is zero, then the first number is `$a$z`. If `z` is non-zero, then the first number is `$z$b`.
[Answer]
# [Perl 5](https://www.perl.org/), ~~98~~ 94 bytes
```
sub{@i="@_"=~/./g;(sort grep!/^0/,map{/./;$i[$&].$i[$'],$i[$'].$i[$&]}<{0,1,2}{4,5,6}>)[0,-1]}
```
[Try it online!](https://tio.run/##ZZDRToMwFIbveYojaUabVGjLIGyI4QW8825BorEQjFsRmHMheOkD@Ii@CLZjCZme9OQ0//fnP8mpZfMajNsjKpKx3T/1aZXYaW4nn57rlTFuVdNB2cj6yntgHt0@1r0GMao2aJG5ZjgZnYY7icNNzyinYuiXNKDhcEs2jF7zbBhja99KuJdtt17fqUbGVqEavHk7YGBcgL8MgPsQCCAZtUDXCXHhw0pjzmHlX6IoimDFQgj1iP4go7EIQvYPccbObTIvkBDi3OaRjFj9CW6PGKmdpKg7KJrKj5okKcrjM4O0VB0ksEDFbCMTrVoML6raYQccanxkWmdq1k3irNsFBpMDJgcI/Hx9w7QD3lv9025bxw/Wszblnb5ntSvj8Rc "Perl 5 – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 13 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
I/O as an array of digit arrays.
```
rï cá fÎÍé ¯2
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&header=Tm3s&code=cu8gY%2bEgZs7N6SCvMg&footer=Vm3s&input=OTAxCjEwOQ)
```
rï cá fÎÍé ¯2     :Implicit input of array
r                 :Reduce by
 ï                :  Cartesian product
   c              :Flat map
    á             :  Permutations
      f           :Filter by
       Î          :  First element (0 is falsey)
        Í         :Sort
         é        :Rotate right
           ¯2     :Slice to second element
```
[Answer]
# APL+WIN, 30 bytes.
Index origin = 0. Prompts for input numbers as strings:
```
(⌊/n~⍳10),⌈/n←,⍎¨(⌽¨n),n←⎕∘.,⎕
```
[Try it online! Thanks to Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcQJanP5BlwPWooz3tv8ajni79vLpHvZsNDTR1HvV06OcBJXUe9fYdWgGU23toRZ6mDkgIqO9Rxww9HSD9H6iT638al7qhkbE6l7qloZE6F5BnYWEB4hmYgXmGBgbqUBLIMzICqoGQAA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~77~~ ~~74~~ ~~70~~ 53 bytes
-17 bytes thanks to [Dingus](https://codegolf.stackexchange.com/users/92901/dingus)!!
```
->x,y{((x-[0]).product(y)+(y-[0]).product(x)).minmax}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf165Cp7JaQ6NCN9ogVlOvoCg/pTS5RKNSU1ujElWoQlNTLzczLzexovZ/QVFmXolCWnS0oY6RjnGsTrSlDpAVG8tVUFpSzIUka6BjAJSF0OiylkBRM6CshQ4QYsgaAU02AspCaEyTIfZilzXXsQSaCLLXGC77HwA "Ruby – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 62 bytes
```
q l=[minimum,maximum]<*>[filter(>"1")$mapM id=<<[l,reverse l]]
```
[Try it online!](https://tio.run/##JYzLasMwFET3/orBeJGU62ApEFyQvMuu@QIhiIrVVlSSE9nN4@tdiWxmDsO958fMv9b7db3CSxVcdOEvUDCP0lq8DerL@cWmzVCzetsEcznBjVII5SnZm02zhdd6DcZFSIxTBShDn/Sgp4ZocZ/SOGOHlwabc5yWo7fhjJraegvRDPi2y4eLNr9ekosLGlyLQ0upiibvRb8yvie8M44WjGXaV33f5@4OeTkU6ivWdYQc5aYQqzjnhBx5edE/ "Haskell – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 77 bytes
```
MinMax@Select[FromDigits/@Join@@Permutations/@Tuples[IntegerDigits/@#],#>9&]&
```
[Try it online!](https://tio.run/##NYpBB8MwGED/Sig9haQZ0x42OdTYKGW7VQ9Rnyw0yaRfGZHfnqWHHR7P86zCN1iFZlFZX/Jg3KC@8gkrLDjdgre90QY3Jh/eOClHCHbHsntX2mv/rLBNd4egIfzPaqbVtavnOo/BOCRMaiZJjI04UdI1IlES27Ytzs@HN5zTwqFCCFpIKecf "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 17 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
ïV cVïU)Íf¨A é v2
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=71YgY1bvVSnNZqhBIOkgdjI&input=IjEwMCIKIjIwMCI)
```
ïV             - pair each digits
   Í           - sort
    f¨A        - remove if <10
        é      - rotate array
          v2   - return first 2 elements ( Max , Min )
```
* Thanks to @Shaggy for spotting an error, fixed by adding `cVïU`
[Answer]
# [Perl 5](https://www.perl.org/) `-MList::Util=min,max -p`, 89 bytes
```
s/.\K/,/g;s/ /}{/ for($b=reverse),$_;$_=min(@a=grep$_>9,glob("{$_}"),glob"{$b}").$".max@a
```
[Try it online!](https://tio.run/##HY27CoMwAEV3vyJIBoWYV7H4wOLeduxWCApRAtGEREpB/PWmaYfDPXe510qnyxA8wc8rQWRuPQHk2AmYjMvg2Dn5ks7LHEHRQtEtas36oZudtFBcajRrM2bpDsWR5v8SfYyOYYqX4d0PIdSMA8ZPSVVVoKbnhFEKIgnnHEQ@xm7KrD4U9xJTRmPelN@a5rEp/ftDcScUVn8B "Perl 5 – Try It Online")
[Answer]
# [Bash](https://www.gnu.org/software/bash/), 126 153 158 bytes
```
for n in {10..99}; {
t=$[n/10]
o=$[n%10]
([[ $1 =~ $t && $2 =~ $o ]]||[[ $2 =~ $t && $1 =~ $o ]])&&A+=($n)
}
echo $A-${A[-1]}
```
[Try it online!](https://tio.run/##TcmxCsIwFAXQ/X3FHZ6hRVqbWoUgGfIdIYOKUpcEtFsaf/1JHMTtwLmcX7PIPT0R8YjIeuh7Y8oJmRbLPu70EChVbaoa78Ea9g1eoBR4/DohhHWtN/6d/l2rlNvahmNLhW7XOYFdx9n5TodCIjIdJznszQc "Bash – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 76 bytes
```
(a,b)=>[(e=a.map(c=>b.map(d=>[c+d,d+c])).flat(3).sort()).find(x=>x>9),e[17]]
```
[Try it online!](https://tio.run/##LY7RboMgFIbveYpzV0iRCiadTYN3ewpHUkTsXKgYJY3Lsmd3x7qbcz6@/Jz8X/ZpZzf1Y8qG2Pq10yu1vGG6qqnXVjzsSJ2umhe0aN2x5e3RGcZEF2yiBRNznBLd3v3Q0kVXS3Vh3NfyzZg1@Tk5O3vQcCNSFRwuUkEGUiIVpCxL3PkZzXmjksg854Bjy2wkiVKKAw40O@13diPRFIrcRJr6B8UuY@gTPXwMB@wTp3frPmkAXcEPAXjaCWrLoeGwcPg2WCr8/zjVHDJzPLEr5lwc5hi8CPFO93hHayGENRy23RiG8DqB@V92Xf8A "JavaScript (Node.js) – Try It Online")
Input as two lists of character, output as two strings.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~147 144~~ 141 bytes
```
#define g(x,d)x%q!=d&x/q%q!=d&x/100!=d
v,d=1,q=10;f(a,b){for(v=q;g(a,v/q)|g(b,v%q)&&g(b,v/q)|g(a,v%q)||printf("%d ",v)&&(v=99,d=-d)<0;v+=d);}
```
[Try it online!](https://tio.run/##dY/RboMwDEXf@xUeEyjRgoiD1IKy/MleKGkQ0saWbsqQSn99mRtU7YW9WNe@x1d2Xw59H@OjPblxOsHAZmH5nPsHY4u58neBUpLYBWENCm9Qasc6ceQX935mwXg9UBsqz5eBHUXIPS@KpNZRl0bL8nEepy/HstxCJgIxtNu2FFpa/ix1eDKW62skCN66cWIcLjsAx1DVAlpUXMM94mXKqKsqQCSrTljTNKTlfgvb36xmTZNSAJXNtJuFCVNKCaCyha3W323/YEhYvWKHlg7Aehs7pBeu8ad3r93wGcvvXw "C (gcc) – Try It Online")
### How?
The macro `g(x,d)` checks whether the digit `d` appears in the 3-digit integer `x` by testing \$x\bmod 10\$, \$\lfloor x/10\rfloor\bmod 10\$ and \$\lfloor x/100\rfloor\$. It returns a falsy value if successful.
We look for the first `v` such that \$\lfloor v/10\rfloor\$ appears in `a` and \$v \bmod 10\$ appears in `b`, or the other way around. We do it once by going from \$v=10\$ to \$v=99\$ and once by going from \$v=99\$ to \$v=10\$, to get the lowest and highest valid integers respectively.
[Answer]
# [R](https://www.r-project.org/), ~~138~~ ~~134~~ ~~128~~(thanks pajonk) ~~121~~ 117 bytes
```
k=t(t(expand.grid(strsplit(scan(,""),""))));class(k)=class(1);a=c(A<-k[,1],B<-k[,2]);b=c(B,A);range(10*a[a>0]+b[a>0])
```
[Try it online!](https://tio.run/##JYhBCoMwEEWvIq5mbCqJGytpCnoNyWKMIhIJksmit4/Wfni8x485e5MgwfI9KMz1GrcZOEU@9i0BOwogyhJ/XNNuJ2bwaP6hUJNx0L@ffhTKiuGOxqKernsQPepIYV1AyYpG@kj7mG5hbrtXoWSTTw "R – Try It Online")
Another solution that takes input as a list of digits, allowed per the rules:
# [R](https://www.r-project.org/), ~~110~~(thanks pajonk) ~~103~~ ~~99~~ 93 bytes
```
i=scan();k=expand.grid(i[1:3],i[4:6]);a=c(A<-k[,1],B<-k[,2]);b=c(B,A);range(10*a[a>0]+b[a>0])
```
[Try it online!](https://tio.run/##HchLCoAgFEDReatwqGWhFf3MQLchDl4lIYGETdq9RaN7OTElL@8NAibilO65IOzVEf2OveFTY6k37dRZIkBuWM3laSi3VP9Tf7x@rKkiIkI4HOYsBwMLs8X6h6QejWjIOGKoTi8 "R – Try It Online")
[Answer]
# C (MinGW), ~~150~~ 146 bytes
-4 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)
The TiO link needs `-lm` but MinGW does not.
```
M,m,x,y,c,t=10;f(a,b){for(M=0,m=99;a;a/=t)for(c=b;c;c/=t)M=fmax(fmax(x=a%t*t+c%t,M),y=c%t*t+a%t),m=y<m&y>9?y:m,m=x<m&x>9?x:m;printf("%d %d",m,M);}
```
[Try it online!](https://tio.run/##TY9RboMwEES/wyksS1R2ulEx0Ajiuj0BN@iPMYFGipMqQRUoytVLd52g9GeZecwOi1t1zk1TBR4GGMFBb1SiW2Ghlpf2eBKVScCbstRW2xfTS2LO1NppR7YyrbeDCGMwNu6X/bOLe6gkjMYFi1Bixfjmn8b38mPceHQDugHdsPH6@7Q79K3gccPihuMlldTX6ee4a1gn8BWzwOhRA3Nf9sSWWxldosVjDXCPrRgHStZSRwv6gZuaU0zEZ/l5wMwW8TWKqNHb3UGEsk6oNANWqhQYVwpVxmm9E0VRoEvWyNekijtXSQIsDK5IqTtPCZWBp6TSmadYHQa/qbmHUlk@9@QPjvfkr/RdlQNbZ//5rYeOzUL@Ov26dm@787Ta@z8 "C (gcc) – Try It Online")
]