[Question]
  [
# The Challenge
Given 3 numbers `X`, `Y` and `Z` in base `B`, find a `B`ase in which the addition of `X` and `Y` yields `Z`. The inputs `x = 20`, `Y = 12` and `Z = 32` could yield `5` because `20 + 12 = 32` in base 5.
* You may assume that there will always be a base in which the addition is correct (there are cases where no base exists, thanks to @[MasonWheeler](https://codegolf.stackexchange.com/users/16637/mason-wheeler) and @[Not that Charles](https://codegolf.stackexchange.com/users/13950/not-that-charles) for some examples of that).
* The lowest possible base is 1. You may use 1s or 0s as the digits in unary, but you may not mix those.
# I/O
* The digits of the input numbers will be non-negative integers.
* You may assume that the input numbers contain leading zeros, so the have a specific (or all the same) length.
* You may take the numbers in the most convenient format, as long as it's not preprocessed. This includes the overall format of the three input numbers and the format of the digits of each of those numbers. Please make it clear which format you use.
* If there are multiple possible bases, you can output all or just one of them.
* You may assume that the base and the input numbers will be within the numerical limits of your language.
# Rules
* Function or full program allowed.
* [Default rules](http://meta.codegolf.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods) for input/output.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) apply.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so lowest byte-count wins. Tiebreaker is earlier submission.
# Test cases
Input format here is a list of integers to represent each number. The three lists are separated by commas.  
Note that there are sometimes multiple bases possible. Only one (random) solution is outputted here.
```
[12, 103],[4, 101],[16, 204] -> 349
[4, 21, 25],[5, 1, 20],[9, 23, 17] -> 28
[16, 11],[25, 94],[41, 105] -> 147
[2, 140],[21, 183],[24, 100] -> 223
[8, 157],[1, 28],[9, 185] -> 227
[2, 158],[88],[3, 12] -> 234
[8, 199],[1, 34],[9, 233] -> 408
[3, 247],[7, 438],[11, 221] -> 464
[3, 122],[3, 2],[6, 124] -> 480
[6, 328],[3, 31],[9, 359] -> 465
[2, 1, 0, 0, 0, 0],[1, 2, 0, 0, 1, 0, 1, 0],[1, 2, 2, 1, 1, 0, 1, 0] -> 3
[16, 105],[16, 120],[33, 84] -> 141
[15, 60],[9, 30],[24, 90] -> 268
[2, 0],[1, 2],[3, 2] -> 5
[1, 3, 3, 7],[1, 2, 3],[1, 4, 6, 0] -> 10
[0],[1, 12, 8],[1, 12, 8] -> 16
[1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1],[1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1],[1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0] -> 2
[1],[1],[1,1] -> 1
```
You can generate additional test cases with [this Pyth program](http://pyth.herokuapp.com/?code=JEKE%2B%2Bj%5C%2C%5BjJQjKQj%2BJKQ%29%22%20-%3E%20%22Q&input=5%0A10%0A7&debug=0). Enter a base on the first line and the decimal values for `X` and `Y` on the following two lines.  
Also you can use [this Pyth program](http://pyth.herokuapp.com/?code=VQJO5000KO5000%3DHO500%2B%2Bj%5C%2C%5BjJHjKHj%2BJKH%29%22%20-%3E%20%22H&input=10&debug=0) to create multiple test cases at once by using random values. Just enter the desired amount of test cases in the input.
**Happy Coding!**
  
[Answer]
# Jelly, ~~16~~ ~~11~~ 7 bytes
```
_/N,‘FṀ
```
This approach is heavily based on [@beaker's Octave answer](https://codegolf.stackexchange.com/a/76224).
Input format is **Z, Y, X**, with little-endian digit order, using the digit **0** for unary.
[Try it online!](http://jelly.tryitonline.net/#code=Xy9OLOKAmEbhuYA&input=&args=WzE3LCAyMywgOV0sIFsyMCwgMSwgNV0sIFsyNSwgMjEsIDRd) or [run all test cases](http://jelly.tryitonline.net/#code=Xy9OLOKAmEbhuYAKw4figqw&input=&args=W1tbMjA0LCAxNl0sIFsxMDEsIDRdLCBbMTAzLCAxMl1dLCBbWzE3LCAyMywgOV0sIFsyMCwgMSwgNV0sIFsyNSwgMjEsIDRdXSwgW1sxMDUsIDQxXSwgWzk0LCAyNV0sIFsxMSwgMTZdXSwgW1sxMDAsIDI0XSwgWzE4MywgMjFdLCBbMTQwLCAyXV0sIFtbMTg1LCA5XSwgWzI4LCAxXSwgWzE1NywgOF1dLCBbWzEyLCAzXSwgWzg4XSwgWzE1OCwgMl1dLCBbWzIzMywgOV0sIFszNCwgMV0sIFsxOTksIDhdXSwgW1syMjEsIDExXSwgWzQzOCwgN10sIFsyNDcsIDNdXSwgW1sxMjQsIDZdLCBbMiwgM10sIFsxMjIsIDNdXSwgW1szNTksIDldLCBbMzEsIDNdLCBbMzI4LCA2XV0sIFtbMCwgMSwgMCwgMSwgMSwgMiwgMiwgMV0sIFswLCAxLCAwLCAxLCAwLCAwLCAyLCAxXSwgWzAsIDAsIDAsIDAsIDEsIDJdXSwgW1s4NCwgMzNdLCBbMTIwLCAxNl0sIFsxMDUsIDE2XV0sIFtbOTAsIDI0XSwgWzMwLCA5XSwgWzYwLCAxNV1dLCBbWzIsIDNdLCBbMiwgMV0sIFswLCAyXV0sIFtbMCwgNiwgNCwgMV0sIFszLCAyLCAxXSwgWzcsIDMsIDMsIDFdXSwgW1s4LCAxMiwgMV0sIFs4LCAxMiwgMV0sIFswXV0sIFtbMCwgMSwgMCwgMCwgMSwgMSwgMSwgMSwgMCwgMSwgMSwgMCwgMCwgMV0sIFsxLCAwLCAwLCAxLCAxLCAxLCAwLCAxLCAwLCAwLCAxXSwgWzEsIDAsIDAsIDEsIDEsIDEsIDAsIDAsIDAsIDEsIDAsIDAsIDAsIDFdXSwgW1swLCAwXSwgWzBdLCBbMF1dXQ).
### How it works
Rather than incrementally testing potential bases, this solves the polynomial that corresponds to the array **P := X + Y - Z**. This returns either the largest coefficient of **P ≠ 0** – which has to be a root, since there is at least one valid base – or the highest digit of **X**, **Y** and **Z**, incremented by **1**.
```
_/N,‘FṀ  Main link. Argument: [Z, Y, X]
_/       Reduce by subtraction; yield Z - X - Y.
         This works since Z must have at least as many digits as X and Y.
  N      Negate to yield X + Y - Z.
    ‘    Yield [Z, Y, X], with all digits increments by 1.
   ,     Pair the results to the left and to the right.
     F   Flatten the resulting, nested list.
      Ṁ  Compute the maximum.
```
[Answer]
# Pyth, 13 bytes
```
f!-FiRTQheSsQ
```
Expects Z, followed by X and Y.
[Test suite](https://pyth.herokuapp.com/?code=f%21-FiRTQheSsQ&input=%28%5B9%2C+23%2C+17%5D%2C+%5B5%2C+1%2C+20%5D%2C+%5B4%2C+21%2C+25%5D%29&test_suite=1&test_suite_input=%28%5B16%2C+204%5D%2C+%5B4%2C+101%5D%2C+%5B12%2C+103%5D%29%0A%28%5B9%2C+23%2C+17%5D%2C+%5B5%2C+1%2C+20%5D%2C+%5B4%2C+21%2C+25%5D%29%0A%28%5B41%2C+105%5D%2C+%5B25%2C+94%5D%2C+%5B16%2C+11%5D%29%0A%28%5B24%2C+100%5D%2C+%5B21%2C+183%5D%2C+%5B2%2C+140%5D%29%0A%28%5B9%2C+185%5D%2C+%5B1%2C+28%5D%2C+%5B8%2C+157%5D%29%0A%28%5B3%2C+12%5D%2C+%5B88%5D%2C+%5B2%2C+158%5D%29%0A%28%5B9%2C+233%5D%2C+%5B1%2C+34%5D%2C+%5B8%2C+199%5D%29%0A%28%5B11%2C+221%5D%2C+%5B7%2C+438%5D%2C+%5B3%2C+247%5D%29%0A%28%5B6%2C+124%5D%2C+%5B3%2C+2%5D%2C+%5B3%2C+122%5D%29%0A%28%5B9%2C+359%5D%2C+%5B3%2C+31%5D%2C+%5B6%2C+328%5D%29%0A%28%5B1%2C+2%2C+2%2C+1%2C+1%2C+0%2C+1%2C+0%5D%2C+%5B1%2C+2%2C+0%2C+0%2C+1%2C+0%2C+1%2C+0%5D%2C+%5B2%2C+1%2C+0%2C+0%2C+0%2C+0%5D%29%0A%28%5B33%2C+84%5D%2C+%5B16%2C+120%5D%2C+%5B16%2C+105%5D%29%0A%28%5B24%2C+90%5D%2C+%5B9%2C+30%5D%2C+%5B15%2C+60%5D%29%0A%28%5B3%2C+2%5D%2C+%5B1%2C+2%5D%2C+%5B2%2C+0%5D%29%0A%28%5B1%2C+4%2C+6%2C+0%5D%2C+%5B1%2C+2%2C+3%5D%2C+%5B1%2C+3%2C+3%2C+7%5D%29%0A%28%5B1%2C+12%2C+8%5D%2C+%5B1%2C+12%2C+8%5D%2C+%5B0%5D%29%0A%28%5B1%2C+0%2C+0%2C+1%2C+1%2C+0%2C+1%2C+1%2C+1%2C+1%2C+0%2C+0%2C+1%2C+0%5D%2C+%5B1%2C+0%2C+0%2C+1%2C+0%2C+1%2C+1%2C+1%2C+0%2C+0%2C+1%5D%2C+%5B1%2C+0%2C+0%2C+0%2C+1%2C+0%2C+0%2C+0%2C+1%2C+1%2C+1%2C+0%2C+0%2C+1%5D%29&debug=0)
Essentially, we test every possible base, starting at one more than the largest digit. The test is that we convert each number to the base in question, then fold subtraction over the numbers, and logically negate the result.
[Answer]
# Octave, ~~67~~ ~~75~~ ~~38~~ 32 bytes
Because "loop over ALL the things" is too much work.
```
@(x,y,z)max([m=max(x+y-z) z])+~m
```
Requires 0 padding to make the input arrays the same size, e.g.:
```
[2, 158],[88],[3, 12]
becomes
[2, 158],[0, 88],[3, 12]
```
Since `0` is used for padding, `1` is used as the token for unary.
(Thanks to [@DenkerAffe](https://codegolf.stackexchange.com/users/49110/denkeraffe) for clarification in the question.)
Sample run on [ideone](http://ideone.com/b2ypOu).
---
**Short Explanation:**
Take a case involving no carries:
```
   [ 8, 199]
 + [ 1,  34]
 -------------
     9, 233
 - [ 9, 233]
 -------------
     0,   0 --- no carries
```
In this case there are no restrictions on base as long as it's greater than any "digit". Simply take the max element of `z` (as `z >= x,y`) and add 1 (or any positive integer).
In the case of a carry-out (with no carry-in), we've exceeded the base in one of the columns and the difference between `x+y` and `z` is the base:
```
   [ 2, 140]
 + [21, 183]
--------------
    23, 323
 - [24, 100]
 -------------
    -1  223
     ^   ^------ base
     |---------- carry in
```
If the second column's sum also exceeded the base, requiring a carry-out as well as the carry-in, its value would be `base+(-1)`. We will have had a column somewhere to the right with a carry-out and no carry-in that has the correct (greater) base value.
[Answer]
## Haskell, ~~90~~ 73 bytes
```
f l=[b|b<-[1..],all(<b)$id=<<l,[x,y,z]<-[foldl((+).(b*))0<$>l],x+y==z]!!0
```
Usage example: `f [[3, 247],[7, 438],[11, 221]]` -> `464`.
Simply try all bases `b` (where `b` is greater than the maximum of the digits). Pick the first one where `x+y==z`.
Edit: @xnor saved many bytes by primarily getting rid of the `import Data.Digits`. 
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 20 bytes
```
`GY:@XJZQ2:"wJZQ-]]J
```
Input is in the format (note outer curly braces):
```
{[4, 21, 25],[5, 1, 20],[9, 23, 17]}
```
This works in [current version (15.0.0)](https://github.com/lmendo/MATL/releases/tag/15.0.0).
[**Try it online!**](http://matl.tryitonline.net/#code=YEdZOkBYSlpRMjoid0paUS1dXUo&input=e1s0LCAyMSwgMjVdLFs1LCAxLCAyMF0sWzksIDIzLCAxN119)
### Explanation
```
`        % do...while index
  G      %   push input. First time pushed nothing but asks for input implicitly
  Y:     %   unpack the cell array, pushing the three numeric arrays
  @      %   loop index: candidate base
  XJ     %   copy into clipboard J
  ZQ     %   evaluate polynomial: interpret third array in that base
  2:"    %   for loop: do this twice (subtract the other numbers from the third)
    w    %     swap, to process another array
    J    %     push base
    ZQ   %     evaluate polynomial: interpret array in that base
    -    %     subtract
  ]      %   end for loop. A result 0 indicates a solution has been found
]        % end do....while loop. Exit if top of stack is 0
J        % push found base. Implicitly display
```
[Answer]
# MATL, ~~13~~ 12 bytes
```
--X>t~1G+hX>
```
Translation of my [Octave answer](https://codegolf.stackexchange.com/a/76224/42892) into MATL. (My first MATL answer!)
* Input order is `Z, X, Y` (or `Z, Y, X` if you prefer, I'm easy)
* Input arrays are zero-padded to equal lengths
* Takes unattractives as 1
[Try it online!](http://matl.tryitonline.net/#code=LS1YPnR-MUcraFg-&input=WzExLCAyMjFdClszLCAyNDddCls3LCA0MzhdCg)
### Explanation
```
--X>t~1G+hX>
--            % M = Z - X - Y
  X>          % P = max(M)
    t~        % Duplicate and negate
      1G      % Push 1st argument (Z) 
        +     % ~P + Z
         h    % Concatenate [P (~P + Z)]
          X>  % Return max
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~28~~ 27 bytes (SBCS)
Saved 1 byte thanks to @[Adám](https://codegolf.stackexchange.com/users/43319/ad%c3%a1m)
```
{⍺←1+⌈/∊⍵⋄0=-/⍺⊥⍵:⍺⋄⍵∇⍨⍺+1}
```
[Try it online!](https://tio.run/##TYw9CsJQEIR7TzG9hLyfxKhgZaOt8QIBiU1AWxErQ4yJL2jhEQQ7G20sPcpe5LkPItjs7nwzO8k68xabJFstrd2SeVNxll06lT6VFZkX1bkYeb4zqhvrobvq3DnlgcydZVfubMpvZBqq9p@HpuJCzTWejXnOJ9PYpiBz1FBkngoCfEFCdVqsGQdQTEIMoDRkhNAFxC8RcELym0bEPECPS4RLQP@XiBZLhX67vg "APL (Dyalog Unicode) – Try It Online")
Takes a matrix with columns `x z y`, with all of them padded with zeroes to have the same number of digits.
Explanation:
```
{
⍺←1+⌈/∊⍵                 ⍝ First base
      ∊⍵                ⍝ Flatten the input into a single vector of digits
     ⌈/                  ⍝ Maximum digit (reduce with max)
  1+                    ⍝Add one to that to get the lowest possible base
0=-/⍺⊥⍵                ⍝If this base works
 :⍺                     ⍝Return it
    ⍺⊥⍵                ⍝Convert to base ⍺
  -/                    ⍝Reduce with subtraction (x - (z - y)) = x + y - z
0=                      ⍝Check if it's 0 (the equation works)
⍵∇⍨⍺+1                  ⍝Otherwise, call itself (∇) with the next base
}
```
```
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), 6 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ζÆ(I>M
```
Port of [*@Dennis*'s Jelly answer](https://codegolf.stackexchange.com/a/76232/52210), so make sure to upvote him as well! The I/O is also in the same format, except with the input wrapped inside a list instead of three loose inputs: \$[Z,Y,X]\$, with little-endian digit order, using the digit \$0\$ for unary.
[Try it online](https://tio.run/##MzBNTDJM/f//3LbDbRqedr7//0dHGxrpGMfqRFtYAAlDUwsdo9hYAA) or [verify all test cases](https://tio.run/##dVHLTcUwEGwleieQ5rAfO7EvvAqoIOQAEi0gpYFXAMXQAHeKoJGwu7ajd0ErK6sZ78ysQ/n1jd@Pj/16mX5vn9Pluh8/X9@3h/3p@cDjy7Guq1ACzxtWJkaKr4Jl2zCtKy8QRTVUCIzsTYb4xcZTRmJDa4I4y@xinSNICBa1EW@SIZ0suckWBJMXlM4I1JBSAi5jQLTl0NQGah0DYnHYsaQFi2umxSS6WILv1jRZZBCaa5PjYNRy9Ni@px@GWLnuQMhqIK14pCsJ2hxoPGY@H6L2d1AKy9mu5B49zIemjAAz2pLa7WwdK@5W9nMCPRu6D96i87lEIB7ojqN/cTo5Gn7Whkf4bH8).
The new 05AB1E version would require an additional leading `0` to overwrite the default space-filler of `ζ`. In the legacy 05AB1E version built in Python, the spaces are counted as 0 when we reduce by subtracting with `Æ`, though. Which would have given [an error in the new version](https://tio.run/##yy9OTMpM/f//3LbDbRqedr7//0dHGxrpGMfqRFtYAAlDUwsdo9hYAA), which is built in Elixir.
**Explanation:**
```
        #  i.e. input = [[12,3],[88],[158,2]]
ζ       # Zip/transpose the (implicit) input-matrix, swapping rows/columns,
        # using a space filler by default if the rows doesn't have matching lengths
        #  STACK: [[12,88,158],[3," ",2]]
 Æ      # Reduce each inner-most list by subtracting, counting the spaces as 0
        #  STACK: [-234,1]
  (     # Negate each
        #  STACK: [234,-1]
   I>   # Push the input again, and increase each value by 1
        #  STACK: [234,-1],[[13,4],[89],[159,3]]
     M  # Push the largest value on the stack, which also looks inside (nested) lists
        #  STACK: [234,-1],[[13,4],[89],[159,3]],234
        # (after which this top value is output implicitly as result)
```
]