[Question]
  [
## Introduction
In this challenge you should split an integer into two pieces. Since nobody likes getting the smaller piece of cake, your goal is to be as fair as possible. For example if you wanted to split the integer `7129` into two pieces, there are 3 possible ways of doing so.
`7,129`, `71,29` and `712,9` are all possibilities, but `71,29` is the fairest way of splitting it into two pieces because it minimizes the difference between the two:
```
7 129 -> |7-129| = 122
71 29 -> |71-29| = 42
712 9 -> |712-9| = 703
```
## Challenge
Given an integer determine the best possible way of partitioning it as described above and **report the resulting difference.**
## Rules
* Splitting only makes sense for integers of length at least two, the input will always be ≥ 10
* Input can be either an integer, list of digits or a string
* You don't have to handle invalid input
## Testcases
You only need to report the resulting difference, the partitioning is only here for illustration:
```
10 -> 1,0 -> 1
11 -> 1,1 -> 0
12 -> 1,2 -> 1
13 -> 1,3 -> 2
101 -> 1,01 -> 0
128 -> 12,8 -> 4
313 -> 3,13 -> 10
1003 -> 1,003 -> 2
7129 -> 71,29 -> 42
81128 -> 81,128 -> 47
999999 -> 999,999 -> 0
9999999 -> 999,9999 or 9999,999 -> 9000
```
  
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), ~~12~~ 11 bytes
My first Brachylog answer
Take input as a string
```
{~cĊịᵐ-ȧ}ᶠ⌋
```
[Try it online!](https://tio.run/##ASsA1P9icmFjaHlsb2cy//97fmPEiuG7i@G1kC3Ip33htqDijIv//yIxMDAxIv9a "Brachylog – Try It Online")
### Explanation:
`ᶠ` will **f**ind all possible outputs for the predicate in `{…}` and store them in a list. `~c` says that the output is a list that, when **c**oncatenated, is equal to the input. Next `Ċ` asserts that the the output of `~c` has length 2.
`ịᵐ` converts both elements of the output into integers (this gets rid of leading `0`s), `-ȧ` takes the absolute difference of the two elements.
Once we have our list of all possible outputs, we get the minimum element with `⌋`
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes
### Code:
```
ā¤âε£ÆÄ}W
```
Uses the **05AB1E** encoding. [Try it online!](https://tio.run/##AR4A4f8wNWFiMWX//8SBwqTDos61wqPDhsOEfVf//zcxMjk "05AB1E – Try It Online")
### Explanation
```
ā            # Get the array [1, 2, .., len(input)]
 ¤â          # Cartesian product with the last element, (e.g. for input 12345:
               [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]])
   ε   }     # For each element:
    £        #   Get the substrings (12345 [3, 5] £ --> [123, 45])
     Æ       #   Reduce by subtraction
      Ä      #   Get the absolute value
        W    # Take the minimum of all results
```
[Answer]
# [Haskell](https://www.haskell.org/), 48 bytes
```
f n=minimum[abs$n`div`10^k-n`mod`10^k|k<-[1..n]]
```
`[1..n]` makes this too slow for the larger test cases.
[Try it online!](https://tio.run/##LYdBDoIwEAC/sgeOQLpwUBN5hcempjVA2LS7EEv14t9rgx5mMrO46KcQcp5BBiYhTqzdI1ZiR3pZVHffiOV1PPLjr43GthVjMjsSGGBL@21/QgVJAskUS7HbIC7r@58zaFQ1IBa6Ql9Qx5xr6H@rik/YXUz@Ag "Haskell – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 64 bytes
```
lambda n:min(abs(int(n[i:])-int(n[:i]))for i in range(1,len(n)))
```
[Try it online!](https://tio.run/##LY7NCoMwEITvPkXoKYG0ZKOgWfBJrIfY2jZU19@LiM9uE@sclm@HgZl@mT8d6X3I73tj2@ppGWHriNtq4o5mToXDUlz/iK4U4tWNzDFHbLT0rjnIpiZOQoj9Yad6yldQCBIAlQQdKEYtQYU/9gzeVip4KWiDiZYZgM4wSaU55HPmJKOU2qJQ@K2XUHk0YMS8@jFsuqwbQ3aey81HWztzn5ZHtPBUyoFP8xhMEVb@AA "Python 2 – Try It Online")
[Answer]
# [Perl 6](https://perl6.org), 40 bytes
```
{min map {abs [-] @$_},m:ex/^(.+)(.+)$/}
```
[Test it](https://tio.run/##RY7daoNAEIXv5ymGIEXR6I4pSayk5Lb3vesfRqcguKtkbUkRn6x3fTHrGGsXlplzvnPYbfhcbYcPy/i5DfMU9Bfe5HXBeBg6XRrUWYNddrL4tH7Bo/PWB/qOL9GrG/qeXCfqh7FzbNm2eMCqNGxd7@c7zGt9cqPnwo9EPZg2BXnlccyl0FSZQX8qpfBen@f@@h5dpzSBw5eG85YLDztALC3KlwR5AS4wwNXoSGmxVtAPpMQiIJKpgOJZb2TGQGoBe1luYXNFNFpKzakdxclEY9jTX3IHyXSu/eRfJEqpXw "Perl 6 – Try It Online")
## Expanded:
```
{  # bare block lambda with implicit parameter ｢$_｣
  min
    map
      {
        abs
          [-]    # reduce with &infix:«-»
            @$_  # the input of this inner block as a Positional
      },
      # split ｢$_｣ into 2 in every possible way
      m
      :exhaustive
      /^ (.+) (.+) $/
}
```
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), ~~195~~ ~~189~~ ~~154~~ ~~117~~ 112 bytes
*35 bytes saved thanks to Eminga*
```
A*H:-findall(X,(between(0,A,I),r(A,I,X)),L),sort(L,[H|_]),!.
r(A,B,C):-Z is 10**B,divmod(A,Z,X,Y),C is abs(X-Y).
```
[Try it online!](https://tio.run/##FckxCoMwGAbQvaewW/7wJUTo5KYuFjxAtJSiJC2B1JRE6tK7pzq94X1i8OEl0uZyrnlXiadbzOQ902CzXTdrF6ZQ40qIbAeaCD0hhbiyHrfu97gTzvJ0bIOWKjEWLhWl4ryBcd93MPuM0BgI7VHTnJgWA8mcS3XhWv4B "Prolog (SWI) – Try It Online")
This is my first try at prolog golfing so it may be a bit horrendous. Here is how it works.
At the highest level we have `*`. `*` takes `A` and `H`, and determines if `H` is the smallest way to split `A`.
```
    A*H:-
      findall(X,(between(0,A,I),call(r,A,I,X)),L),
      sort(L,[H|_]),
      !.
```
The first line here uses a technique from [this SO post](https://stackoverflow.com/a/47868877/4040600), to essentially perform a map of the predicate `r(A)` over the integers from `0` to `A`. Since `r` confirms the values of each partitions this will give us the values of all possible partitions, plus a whole load of extra junk. All these partitions will be stored in `L` in no particular order. Once that is done we sort the list to find the smallest element. We then use a cut to prevent backtracing.
Next we have the definition of `r`.
First `r` calculates the two results of the split naming them `X` and `Y`.
```
r(A,B,C):-
  Z is 10**B,
  divmod(A,Z,X,Y),
  C is abs(X-Y).
```
Then we assert that `C` is the difference of them and is positive.
```
  C is abs(X-Y).
```
[Answer]
# C, 94 bytes
```
c,r,d,a;f(n){for(c=1,r=0,d=n<11?1:n;n;r+=n%10*c,c*=10,n/=10)a=abs(r-n),d=r&&a<d?a:d;return d;}
```
[Try it online!](https://tio.run/##fc2xDoIwEAbgnadoTCAtltiDQaA0vIhLbcUweJoTJ8KzY8PgYso/3HDf5T9X3J1bVydJemn1wFHMw5O4MyDJKOkNdgA9tKhR09FgCip30uUGlMRTmMIae31zKlCEa8oy2/netl7TbfoQMq@XdcSJPeyIXCRzwkJeFFYDP6T@ggfJBh56hI4QxKmMUxUntddYR63a7VRxPEPZRLGGvZ/Nln8OyH68@bJ@AQ)
[Answer]
# [Python 2](https://docs.python.org/2/), 51 bytes
```
f=lambda n,k=1:min(abs(n/k-n%k),k/n*n or f(n,10*k))
```
[Try it online!](https://tio.run/##NY1BCoMwEEXX7Sn@JmgkYiYKGsHeRSlSSR3F6qKnt9OUDrwZ3mze@t4fC7vzHLtnPw/3HmxCR@08cdoPr5SLkLMK2oSCM8ayYUzZkM2C1ucoypgYZA2IBCeUgo3SGJQ/tbJrct6gofj3cf7Xt9fLuk28I1H1gfwGVR0JFKT1DUrrAw "Python 2 – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~68~~ 65 bytes
```
f x=minimum[abs$read(take i x)-read(drop i x)|i<-[1..length x-1]]
```
[Try it online!](https://tio.run/##HcexCoAgEADQXznCoQaDa2qoLxGHC7WO1MQMHPp3g972DrpP631rDuoaOHJ4gqLtFtmS6QudFhjqIP@afKW/Ly9S4Th6G/dyQJWodQvEcU2ZYxEOuhlxmrv2AQ "Haskell – Try It Online")
## Explanation
```
minimum              -- Minimum of ...
 [abs$               -- The absolute value of ...
  read(take i x)     -- The first i characters of x
  -                  -- Minus ...
   read(drop i x)    -- The last i characters of x
 |i<-[1..length x-1] -- From i=1 to i=length x - 1
 ]
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~9~~ 8 bytes
```
ḌÐƤḊạḌƤṂ
```
[Try it online!](https://tio.run/##y0rNyan8///hjp7DE44tebij6@GuhUAOkLmz6f/RPS6H2x81rVFx///f0EBHwdAQiI2A2BiIDcAcCx0FYwjXAEiaGxpZ6ihYGILFLcEARlsCAA "Jelly – Try It Online")
-1 byte thanks to Dennis. Input is a list of digits. 
**Explanation**
```
ḌÐƤḊạḌƤṂ
ḌÐƤ          Convert to integer from decimal for all Ƥostfixes. [1,2,3]->[123,23,3]
   Ḋ         Remove the first element ->[23,3]
     ḌƤ      Convert to integer from decimal for all Ƥrefixes [1,2,3]->[1,12,123]
    ạ        Absolute difference. [23,3]ạ[1,12,123]->[22,9,123]
       Ṃ     Minimum
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 14 bytes
```
Ｉ⌊Ｅθ↔⁻Ｉ…θκＩ✂θκ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwzczLzO3NFfDN7FAo1BHwTGpGCRUWgyRda5Mzkl1zsgHy2VrauoogIWDczKTU6FCEGD9/7@hkcV/3bIcAA "Charcoal – Try It Online") Link is to verbose version of code. Conveniently I get to use the 2-arg variant of `Slice`. Explanation:
```
   θ            Input string
  Ｅ             Map over characters
        θ   θ   Input string
         κ   κ  Current map index
       …        Mold to length (i.e. head)
           ✂    Slice (i.e. tail)
      Ｉ   Ｉ     Cast to integer
     ⁻          Subtract
    ↔           Absolute value
 ⌊              Minimum
Ｉ               Cast to string
                Implicitly print
```
[Answer]
# [Funky](https://github.com/TehFlaminTaco/Funky), ~~159~~ ~~134~~ 99 bytes
```
s=>{S={}fori=1i<#s i++{S[#S]=(((v=s::sublist)(0,i)::[[email protected]](/cdn-cgi/l/email-protection)(i)::reduce@..)^2)^.5};math.min...S}
```
Actually fitting the spec is shorter it seems.
[Try it online!](https://tio.run/##VcdLCsIwEADQqxS6maE62IJQoiPeIUuxoLHFQRsln4KEnD26lbd6U7SPTzFcPB@S5pSnlxNuZV/7Spom6VOtzwwAC3ulfLw@xQeEzUpQKTfeohmPROsF/o5DhwNt826@hDvNYolI5/J2YgMYSH3V/nRVnxHLFw "Funky – Try It Online")
[Answer]
## [Retina](https://github.com/m-ender/retina), 36 bytes
```
\B
,$'¶$`
\d+
$*
(1*),\1
Om`^.*
\G1
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wP8aJS0dF/dA2lQSumBRtLhUtLg1DLU2dGEMuLv/chDg9La4Yd8P//w0NuAwNuQyNuAyNuQwNQCwLLmMw28CYy9zQyJLLEggA "Retina – Try It Online")
### Explanation
```
\B
,$'¶$`
```
This generates all possible partitions on separate lines, as well as a trailing line with the original input.
```
\d+
$*
```
Convert each number in each partition to unary.
```
(1*),\1
```
Remove a maximal and equal amount of `1`s from both parts of each partition (i.e. remove the minimum, and subtract it from the maximum, which gives the absolute difference).
```
Om`^.*
```
Sort the lines.
```
\G1
```
Count the `1`s on the first line, which gives the minimal absolute difference.
[Answer]
# [J](http://jsoftware.com/), 32, 27 23 bytes
-5 bytes thanks to FrownyFrog! -4 bytes if input is a string.
```
[:<./}:@(".\)|@-1}.".\.
```
[Try it online!](https://tio.run/##y/qfbmulYKAAxP@jrWz09GutHDSU9GI0axx0DWv1gCy9/5pcSnoK6mm2euoKOgq1VgrpXFypyRn5CmkK6oYG6goIjiEyxwiZY4zMMUBVZ4HEM0ZTaYDMNTc0skTiWhii6rUEA3U0PlDHfwA "J – Try It Online")
Original:
Takes a number as input
```
(".\(}:@[([:<./|@-)}.@])".\.)@":
```
## How it works:
```
                             @": - convert the number to list of chars and
(".\                    ".\.)    - form all prefixes/suffixes and convert them to numbers
    (}:@[          }.@])         - drop the last prefix / first suffix
         (     |@-)              - find the absolute differences
          [:<./                  - find the minimum
```
[Try it online!](https://tio.run/##y/qfbmulYKAAxP81lPRiNGqtHKI1oq1s9PRrHHQ1a/UcYjWBwnqaDkpW/zW5lPQU1NNs9dQVdBRqrRTSubhSkzPyFdIUDA0U4ExDBNMIwTRGMA2QVVjA2cYoagwQHHNDI0s4x8IQWY8lGKBxLRX@AwA "J – Try It Online")
[Answer]
# JavaScript (ES6), 64 bytes
Takes input as a string.
```
f=([c,...s],l=0)=>c?Math.min(Math.abs((l+=c)-s.join``),f(s,l)):l
```
### Test cases
```
f=([c,...s],l=0)=>c?Math.min(Math.abs((l+=c)-s.join``),f(s,l)):l
console.log(f("10"     )) // -> 1
console.log(f("11"     )) // -> 0
console.log(f("12"     )) // -> 1
console.log(f("13"     )) // -> 2
console.log(f("101"    )) // -> 0
console.log(f("128"    )) // -> 4
console.log(f("313"    )) // -> 10
console.log(f("1003"   )) // -> 2
console.log(f("7129"   )) // -> 42
console.log(f("81128"  )) // -> 47
console.log(f("999999" )) // -> 0
console.log(f("9999999")) // -> 9000
```
### Commented
```
f = ([c, ...s],           // c = current character, s = array of remaining characters
                l = 0) => // l = left part of the integer, initialized to 0 (see footnote)
  c ?                     // if c is defined:
    Math.min(             //   return the minimum of:
      Math.abs(           //     1) the absolute value of:
        (l += c) -        //       the updated left part
        s.join``          //       minus the right part
      ),                  //     end of Math.abs()
      f(s, l)             //     2) the result of a recursive call
    )                     //   end of Math.min()
  :                       // else:
    l                     //   stop the recursion by returning l (now equal to the input)
```
---
# Non-recursive (ES7), 65 bytes
Takes input as a string.
```
s=>Math.min(...[...s].map(c=>((l+=c)-s.slice(++i))**2,i=l=0))**.5
```
### Test cases
```
let f =
s=>Math.min(...[...s].map(c=>((l+=c)-s.slice(++i))**2,i=l=0))**.5
console.log(f("10"     )) // -> 1
console.log(f("11"     )) // -> 0
console.log(f("12"     )) // -> 1
console.log(f("13"     )) // -> 2
console.log(f("101"    )) // -> 0
console.log(f("128"    )) // -> 4
console.log(f("313"    )) // -> 10
console.log(f("1003"   )) // -> 2
console.log(f("7129"   )) // -> 42
console.log(f("81128"  )) // -> 47
console.log(f("999999" )) // -> 0
console.log(f("9999999")) // -> 9000
```
### Commented
```
s =>                            // given s
  Math.min(...                  // get the minimum value in the result of this map():
    [...s].map(c =>             //   for each character c in s:
      ((l += c)                 //     append c to l (the left part)
                - s.slice(++i)) //     and subtract the right part from it
      ** 2,                     //     square the result
      i =                       //     start with i = 0 (split position)
      l = 0                     //     and l = 0 (left part, see footnote)
    )                           //   end of map()
  )                             // end of Math.min()
  ** .5                         // return the square root of the smallest square
```
---
**Note**: In both versions, `l` is coerced to a string on the first iteration. Normally, we should be careful about leading zeros in a numeric literal: `0123 - 10 === 73` because `0123` is parsed as an octal value (this is now deprecated, but still valid in non-strict mode). But `'0123' - '10' === 113`, the leading zero being this time ignored. So, it's sound to do so.
From the [specification](https://www.ecma-international.org/ecma-262/6.0/#sec-tonumber-applied-to-the-string-type) of the abstract operation `ToNumber` applied to a string:
> 
> A StringNumericLiteral that is decimal may have any number of leading
>  0 digits
> 
> 
> 
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 27 bytes
```
{⌊/|-/⍎¨↑⊂∘⍵¨↓1,∘.=⍨⍳¯1+≢⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24TqRz1d@jW6@o96@w6teNQ28VFX06OOGY96t4J4kw11gBw920e9Kx71bj603lD7UecioFwtUK@CuqGBOheIMoRQRhDKGEIZwEQtwLQxXNwAwjA3NLIEMywMYWoswQCJaakOAA "APL (Dyalog Unicode) – Try It Online")
**How?**
`¯1+≢⍵` - length of `n` minus 1
`∘.=⍨⍳` - identity matrix
```
      1,∘.=⍨⍳3
1 1 0 0
1 0 1 0
1 0 0 1
```
`1,` - prepend `1` for each row
`↓` - split by rows
`⊂∘⍵¨` - for each, partition the string by it
```
      1 0 1 0 ⊂ '7129'
┌──┬──┐
│71│29│
└──┴──┘
```
`↑` - flatten
`-/` - reduce each pair with subtraction
`|` - take absolute values
`⌊/` - minimum
---
# [APL (Dyalog)](https://www.dyalog.com/), 35 bytes
```
{⌊/|-/⍎¨(⊂∘⍵⍤1)1,∘.=⍨⍳¯1+≢⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24TqRz1d@jW6@o96@w6t0HjU1fSoY8aj3q2PepcYahrqADl6to96Vzzq3XxovaH2o85FQLlaoE4FdUMDdS4QZQihjCCUMYQygIlagGljuLgBhGFuaGQJZlgYwtRYggES01IdAA "APL (Dyalog Unicode) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
ŒṖṖLÐṂḌIAṂ
```
[Try it online!](https://tio.run/##y0rNyan8///opIc7pwGRz@EJD3c2PdzR4@kIpP9bH25XedS0xv3/f0MDHQVDQyA2AmJjIDYAcyx0FIwhXAMgaW5oZKmjYGEIFrcEAxhtCQA "Jelly – Try It Online")
-3 bytes thanks to dylnan
## How it works
```
ŒṖṖLÐṂḌạ/€Ṃ - Main link. Argument: n (integer)    e.g    7129
ŒṖ          - Partitions of n's digits;                  [[7, 1, 2, 9], [7, 1, [2, 9]], [7, [1, 2], 9], [7, [1, 2, 9]], [[7, 1], 2, 9], [[7, 1], [2, 9]], [[7, 1, 2], 9], [7, 1, 2, 9]]
  Ṗ         - Remove the final element                   [[7, 1, 2, 9], [7, 1, [2, 9]], [7, [1, 2], 9], [7, [1, 2, 9]], [[7, 1], 2, 9], [[7, 1], [2, 9]], [[7, 1, 2], 9]]
    ÐṂ      - Keep the lists with the minimum...         [[7, [1, 2, 9]], [[7, 1], [2, 9]], [[7, 1, 2], 9]]
   L        -   length
      Ḍ     - From digits                                [[7, 129], [71, 29], [712, 9]]
        /   - Reduce...
         €  - ...each...
       ạ    - ...by absolute difference                  [122, 42, 703]
          Ṃ - Take the minimum                           42
```
[Answer]
# [Python 2](https://docs.python.org/2/), 58 bytes
```
lambda n:min(abs(n%10**i-n/10**i)for i in range(len(`n`)))
```
[Try it online!](https://tio.run/##PYlBCsIwEEX3nmI2QqaMmEkWNgVv4qIpNjrQTkvajaePNIh/8x7vr5/9vagr6f4oU5yHZwTtZlETh83omW3TyEWvlZiWDAKikKO@RjONanrtEbH8H7bETOyIPbE9rCVf3Xq6sQvU8tFC3Q@hOwGsWXSHZATLFw "Python 2 – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 15 bytes
```
hSmaFvMdfqlT2./
```
[Try it online!](https://tio.run/##K6gsyfj/PyM4N9GtzDclrTAnxEhP//9/JXNDI0slAA "Pyth – Try It Online")
[Answer]
# [MATL](https://github.com/lmendo/MATL), 15 bytes
```
"GX@:&)UwU-|vX<
```
Input is a string representing the integer.
[Try it online!](https://tio.run/##y00syfn/X8k9wsFKTTO0PFS3pizC5v9/dQtDQyMLdQA "MATL – Try It Online") Or [verify all test cases](https://tio.run/##y00syfmfEOH1X8krwsFKTTO0PFS3pizC5n@sS8h/dUMDdS51Q0MQYQQijEGEAYRvASSNoSIGIMrc0MgSSFkYQuQswQDOsFQHAA).
### Explanation
```
"         % Implicit input. Do the following as many times as input length
  G       %   Push input
  X@      %   Push iteration index (1-based), k
  :       %   Range: gives [1 2 ... k]
  &)      %   Two-ouput reference indexing: gives a substring with the first
          %   k characters in the input and then a substring with the rest
  U       %   Convert to number
  wU      %   Swap, convert to number
  -|      %   Absolute difference
  v       %   Vertically concatenate stack. This concatenates the obtained
          %   absolute difference with the minimum so far; does nothing in 
          %   the first iteration
  X<      %   Minimum of array
          % Implicit end. Implicit display
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 66 bytes
```
Min@Abs[#-#2&@@FromDigits/@#&/@ReplaceList[#,{a__,b__}:>{a}|{b}]]&
```
Takes a list of digits.
[Try it online!](https://tio.run/##XYrLCsIwEEX3@Y1AFzLS18JWUEYQVwritpSQllQDpkqTXcy3x4ZAEZnFOffeUdw8hOJG9twPO3@RIx463dA1LRLE0/RSR3mXRqdIkxRv4v3kvThLbRoKljMGHWNuu7fcfWzn2jbx10mOBldDipYQm0PmICCPKCLKiGypoQpSws@URd1AmOug1azLbw3L/cW5IMT5Lw "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Clean](https://clean.cs.ru.nl), ~~106~~ 83 bytes
```
import StdEnv
@n#f=toInt o(%)n
=hd(sort[abs(f(0,i)-f(i+1,size n))\\i<-[0..size n]])
```
Defines the function `@`, taking a string.
Mostly self-evident, the only tricky bit is `f=toInt o(%)n`: This takes the `toInt` class of functions, and composes it (`o`) with the curried slice operator class (`%`) already supplied with the first argument (`n`). Since there is only one type (`String`, equivalent to `{#Char}`) which has overloads for both `%` and `toInt` the line actually compiles, whereas normally it's hard to compose functions when golfing due to the lack of contextual information given to the compiler.
[Try it online!](https://tio.run/##TU87a8NADN79KwShcEflcBcPjSGGDO0Q6ObR9nD1IxXYOuNTCu2P79V5DNWg7yU@UDv2juPku8vYw@SII02zXwRK6d74KznyZijEn1jAqyfNSfHZqbAeVO4jqEEZJJ0Oip4tBvrpgbWuazqkldlu70bT6FiKWyTZEM8XCVBAZQ1ai3aHNkNrrmyP2Y2bDF/sLse9vXr5bR6QN/8rxJeyEJ@BoK7XdUjhHjZJsX4yw/Gh4287jO4cYnp6j6/f7CZqwx8 "Clean – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
JṬ€œṗ€⁸Ḍạ/€Ṃ
```
A monadic link taking a list of digits and returning the integer.
**[Try it online!](https://tio.run/##y0rNyan8/9/r4c41j5rWHJ38cOd0IP2occfDHT0Pdy3UB3Ie7mz6//9/tLmOoY6RjmUsAA "Jelly – Try It Online")**
### How?
```
JṬ€œṗ€⁸Ḍạ/€Ṃ - Link: list of digits     e.g. [7,1,2,9]
J            - range of length               [1,2,3,4]
 Ṭ€          - untruth €ach                  [[1],[0,1],[0,0,1],[0,0,0,1]]
      ⁸      - chain's left argument         [7,1,2,9]
   œṗ€       - partition at truthy for €ach  [[[],[7,1,2,9]],[7,[1,2,9]],[[7,1],[2,9]],[[7,1,2],9]]
       Ḍ     - undecimal (vectorises)        [[0,7129],[7,129],[71,29],[712,9]]
         /€  - reduce €ach by:
        ạ    - absolute difference           [7129,122,42,703]
           Ṃ - minimum                       42
```
[Answer]
# Pyth, 10 bytes
```
hSaMv<./Ql
```
[Test suite](https://pyth.herokuapp.com/?code=hSaMv%3C.%2FQl&test_suite=1&test_suite_input=%2210%22%0A%2211%22%0A%2212%22%0A%2213%22%0A%22101%22%0A%22128%22%0A%22313%22%0A%221003%22%0A%227129%22%0A%2281128%22%0A%22999999%22%0A%229999999%22&debug=0)
Takes input as a string.
This uses one of Pyth's more recent features, which is that applying a function to a list defaults to mapping the function over the list, if no other behavior is defined. This means that `v` applied to a list of list of strings evaluates all of the strings.
```
hSaMv<./Ql
hSaMv<./QlQ    Implicit variable
      ./Q      Form all partitions of the input string.
               Split it in all possible ways, maintaining the order.
               Partitions are ordered from shortest to longest.
     <   lQ    Take the prefix as long as the input string.
               This keeps just the splits into one and two pieces.
    v          Evaluate. All strings are converted to numbers.
  aM           Map the absolute difference function.
hS             Minimum
```
Note that the list of splits allows the split into 1 piece, but the value of this will always be larger than the minimum, so it is safely ignored.
[Answer]
# [Tcl](http://tcl.tk/), 116 bytes
```
foreach d [split [set b [set R $argv]] {}] {append L $d
regexp .(.+) $R - R
set b [expr min($b,abs($L-$R))]}
puts $b
```
[Try it online!](https://tio.run/##LYuxCsIwFEX3fMUd3pCg7e4/dMoqGZImrYVaH0kUQfrtrxE9cDlw4dRxFZkeOfnxhohr4XWpTaki/GRBPs8v5/DZ2zxz2iIGUFQ5zenN6HV/MiCLDlb9y/Zn3JdNUzj7UDQNHVlj3K74WQsoiMjlywE "Tcl – Try It Online")
**Explanation**
```
b ← R ← input number
for each digit (d) in the input number:
  L += d
  strip first digit off of R using a regular expression
  b ← min( b, distance between L and R )
print b
```
It works by using a regex trick allowing a degenerate final case that will always compute to greater than the minimum difference. For “12345” the values are:
```
1 2345 → 2344
12 345 → 333
123 45 → 78
1234 5 → 1229
12345 5 → 12340 (degenerate case)
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 44 bytes
```
->a{((w=1)..a).map{((a%w*=10)-a/w).abs}.min}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6xWkOj3NZQU08vUVMvN7EAyE1ULdeyNTTQ1E3UL9fUS0wqrtXLzcyr/V@gkBZtaGAYywVimBsaWcb@BwA "Ruby – Try It Online")
[Answer]
# APL+WIN, 31 bytes
```
⌊/|(⍎¨m↓¨⊂n)-⍎¨(m←⍳¯1+⍴n)↑¨⊂n←⎕
```
Prompts for screen input of integer as a string.
Explanation:
```
m←⍳¯1+⍴n Create a list of numbers from 1 to length of string - 1
↑¨⊂n←⎕ Using m create a nested vector taking successively characters from the front of the string defined by m
⍎¨ Convert from character to integer
(⍎¨m↓¨⊂n) Using m create a nested vector dropping successively characters from the front of the string defined by m 
⌊/| take the minimum absolute value after subtracting the two vectors of integers
```
[Answer]
# [Perl 5](https://www.perl.org/), ~~51~~ 41 + 1 (`-p`) = 42 bytes
```
$\=$_;$\=$\>($"=abs$'-$`)?$":$\while//g}{
```
[Try it online!](https://tio.run/##K0gtyjH9/18lxlYl3hpExthpqCjZJiYVq6jrqiRo2qsoWanElGdk5qTq66fXVv//b2hk8S@/oCQzP6/4v66vqZ6BocF/3QIA "Perl 5 – Try It Online")
*inspired by @Nahuel-Fouilleul's comment*
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 112 107 + 18 = 125 bytes
```
n=>Enumerable.Range(1,n.Length-1).Min(i=>System.Math.Abs(int.Parse(n.Remove(i))-int.Parse(n.Substring(i))))
```
[Try it online!](https://tio.run/##nVA9a8MwFNz9K0QmCWJhJ0MTUhtCaaYYTDJ0KB1k98URxE@tnhwoJb/dVeLQD@hQ9QYN9@7e3VNNcW0s9B1pbNj2jRy0cq3xdRFFqFqgF1UDWyltl1QaIl0dIHqPmEd9UESstKaxqr0wA38GOeV0zY5GP7NCaeTkrA94fGLKNiQ@dV@OM67xqw7r28EwZhpdznYsYz1m@T12LVjlO8iNwgZ4Oka5BmzcPk6FLHyQzvLrmkK5vVxWxP0KWSpLwFFuoDVH4FqI@Du97aoh8DwRovfX/1LsziAZn/1gtQP/ScB3fJQmIyEWf5enYfJJmHwaJk9C28yC9NPgPkmY4SadzIMMszT0hvkF/7D89Jyi4T31Hw "C# (.NET Core) – Try It Online")
The count includes the 18 bytes in `using System.Linq;`. Takes input as a `string`.
* 5 bytes saved by Caius Jard!
[Answer]
# Common Lisp, 131 bytes
My first time participating in code golf and I decided to use Lisp, since I like it.
Here is my solution:
```
(defun f (s) (loop for i from 1 below (length s) minimizing (abs (- (parse-integer (subseq s 0 i)) (parse-integer (subseq s i))))))
```
Input needs to be a string, not integer or list.
]