[Question]
  [
### Introduction
In this challenge your task is to generate the ISBN-10 code for books given its ISBN-13 code, assuming that such a code exists. Such an ISBN-13 code consists of several parts separated by `-`:
```
978-GG-PPPP-TTT-C
```
The letters `G` (group), `P` (publisher), `T` (title) and `C` (checksum) all stand for one digit. For the purpose of this challenge the grouping and the computation of `C` (see [this challenge](https://codegolf.stackexchange.com/questions/342/calculate-isbn-13-check-digit)) are not interesting and we'll drop all hyphens to make this task simpler.
An ISBN-10 number has a very similar layout:
```
GG-PPPP-TTT-c
```
The letters `G`,`P` and `T` are the same as for the 13 digits ISBN, however `c` is different (and is computed using a different algorithm). The digit `c` is chosen in a way such that the following equivalence holds (digits in order):
```
10*G + 9*G + 8*P + … + 3*T + 2*T + 1*c = 0 (mod 11)
```
### Example
Let us consider the ISBN number `9780345391803`: To get its corresponding ISBN-10 code we simply drop the leading `978` and the checksum `3` yielding `034539180`.
Next we need to compute the new checksum:
```
10*0 + 9*3 + 8*4 + 7*5 + 6*3 + 5*9 + 4*1 + 3*8 + 2*0 = 185
```
The next number divisible by `11` is `187`, so the new checksum is `2` and thus the resulting ISBN-10 code `0345391802`.
### Rules
* Your input will always have a corresponding ISBN-10 number (ie. it is exactly 13 digits long and starts with `978`)
* The input doesn't necessarily have to be a valid ISBN-13 (eg. `9780000000002`)
* You're guaranteed that the resulting ISBN won't end with `X`
* You may take input as an integer or string (with or without hyphens) however a precomputed list of digits are not allowed
* Your output must be a valid ISBN-10 number (with or without hyphens)
* Your output may be an integer or string (again no lists of digits)
### Testcases
```
9780000000002 -> 0000000000
9780201882957 -> 0201882957
9781420951301 -> 1420951300
9780452284234 -> 0452284236
9781292101767 -> 1292101768
9780345391803 -> 0345391802
```
Note the leading zeroes!
  
[Answer]
## [Retina](https://github.com/m-ender/retina/wiki/The-Language), ~~44~~ ~~39~~ 28 bytes
```
>,L3,-2`.+
.
$.>`**
_{11}
_
```
[Try it online!](https://tio.run/##PcqxDsIwDATQ3d8BEipt5LMdEi9dWfgEpKZDBxYGxFbx7aHN0FtOT3ef5ft6z6jh/LzcSx37h/aDlHClQKcwlq6jaQV@RFOtnjILI2fxmGgTTNgjlLGLLYpkE7W2iQsY6daerBbVsXXTkT8 "Retina – Try It Online")
### Explanation
Time to show off some new Retina features. :)
```
>,L3,-2`.+
```
We match the entire input with `.+`, return that match `L`, but select only the characters 3 (zero-based) to -2 (penultimate), inclusive. We also print the result without a trailing linefeed (`>`).
Now, subtracting things in Retina is a bit annoying. But luckily, we're working modulo 11, so we can just invert the coefficients of the linear combination (mod 11) and add everything up. In other words, if the constraint is:
```
10*G + 9*G + 8*P + … + 3*T + 2*T + 1*c = 0 (mod 11)
```
then we get:
```
c = 1*G + 2*G + 3*P + … + 8*T + 9*T (mod 11)
```
That simplifies things a lot here:
```
.
$.>`**
```
We replace each character with that thing at the bottom. `*` is Retina's repetition operator. It's right-associative and it has implicit operands `$&` on the left and `_` on the right, so the substitution is actually short for `$.>`*$&*_`. `$&*_` creates a string of **d** underscores, where **d** is the digit we're currently replacing. Then `$.>`` is the length of the string up to and including the match.1 Hence, the entire expression results in a unary representation of the **n**th term of our linear combination.
```
_{11}
```
Doing the actual modulo is trivial in unary: we just drop all complete sets of 11 underscores.
```
_
```
Finally, we count how many underscores remain and print the result, which completes the ISBN-10.
---
1 How does `$.>`` give the length of the string up to and including the match? You might be familiar with `$`` in regex substitutions, which gives you the string up to (but excluding) the match. By inserting a `>`, we can shift the context of the `$`` to the *separator* between the current match and the next (which is an empty string between the current digit and the next). That separator's `$`` will include the current match. So `$>`` is a shorter way to write `$`$&`. Finally, for all `$x`-type substitution elements, Retina lets you insert a `.` after the `$` to get its length.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~17~~ ~~15~~ ~~13~~ 12 bytes
```
¦¦¦¨DSƶO11%«
```
[Try it online!](https://tio.run/##MzBNTDJM/V9TVvn/0DIwXOESfGybv6Gh6qHV/yuVDu9X0LVTOLxfSee/pbmFgbGJqbGlIZDmAvGMDAwtLIwsTc1BPEMTIwNLU0NjA0OwnImpkZGFiZGxCVjOyNLI0MDQ3AysEmEKAA "05AB1E – Try It Online")
**Explanation**
```
¦¦¦            # remove the first 3 characters
   ¨           # remove the last character
    D          # duplicate
     S         # split to list of digits
      ƶ        # multiply each by its 1-based index
       O       # sum
        11%    # mod by 11
           «   # concatenate
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~96~~ 84 bytes
```
$y=-(([char[]]($x="$args"-replace'^978|.$')|%{--$a*[int]"$_"})-join'+'|iex)%11;$x+$y
```
[Try it online!](https://tio.run/##DcvRCoIwFADQfxlXtiU3GhYm4ZeMFUMuuRgqM2jS@vabT@fpLPOH0jpSjMyw9aiUHUafrHMKci/Ap@cqMNES/UDy3rXXcgSpS/VFBH@wYXo7AQ/x0/iawyRrWQJlXRlzg1zDxsz7OTXnS9OZ3T8 "PowerShell – Try It Online")
Takes input `"$args"`, does a regex `-replace` to get only the pertinent part, stores that into `$x` as a string. Then we cast that as a `char`-array and loop through each letter. Inside the loop, we pre-decrement `$a` (which defaults to `0`) and multiply out according to the checksum calculation. Note the cast to `int`, else this would use ASCII values.
We then `-join` those numbers together with `+` and pipe that to `iex` (`Invoke-Expression` and similar to `eval`). We take that `%11` and store that checksum into `$y`. Finally, we string concatenate `$x + $y`, and leave that on the pipeline. Output is implicit.
*Saved 12 bytes thanks to Emigna.*
[Answer]
# [Octave](https://www.gnu.org/software/octave/), ~~46 41 39~~ 37 bytes
```
@(a)[c=a(4:12) 48+mod(7+c*(1:9)',11)]
```
[Try it online!](https://tio.run/##PYxBCsIwEEX3niIbSWIlzEwmTaZQ8B7iIlS7k26K149imszm83i82ZY9f15lnZ1z5WayvS9zNjwhWcVpeG9PE4flYnASq6@I9lFWoyUmaEfaqrPqCKfDE2BKJCFW3/HwyAQS0AP@fcfecyBKTJ5r33BsPQkhYBzr/46p9Z6DF/xt7RtS@QI "Octave – Try It Online")
The code takes input as a string, and returns a string.
The code breaks down as follows:
`@(a)` creates an anonymous function.
With `[c=a(4:12) ... ]` we extract the characters that form the main code, saving a copy to `c` for later use, and adding another copy to the final output string.
Based on @MartinEnter's clever way of swapping `10:-1:2` into `1:10`, we can easily generate that range and transpose it to get a column vector. `c*(1:10)'` does array multiplication of the row vector `c` and range column vector. This is equivalent to doing an element-wise multiplication then summing.
The checksum would normally be `mod(11-sum,11)` to calculate the number required for the sum to be a multiple of 11. However, because `c` was a character string, the sum will actually be larger than it should be by 2592 (48\*54) because we multiplied by numbers that were 48 larger than the actual value. 
When we perform the modulo, it will automatically get rid of all but 7 of that 2592. As such, and accounting for the negation of the range, the actual calculation becomes `48+mod(7+sum,11)`. We add on 48 to the result to convert back to an ASCII character.
The checksum character is appended to the end of the result, and the value returned.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
ṫ4ṖȮV€xJS%11
```
This is a full program that uses strings for I/O.
[Try it online!](https://tio.run/##ASwA0/9qZWxsef//4bmrNOG5lsiuVuKCrHhKUyUxMf///yc5NzgwMjAxODgyOTU3Jw "Jelly – Try It Online")
### How it works
```
ṫ4ṖȮV€xJS%11  Main link. Argument: s (string of length 13)
ṫ4            Tail 4; discard the first three characters.
  Ṗ           Pop; discard the last characters.
   Ȯ          Output; print the result to STDOUT and return it.
    V€        Eval each; turn digit characters into digits.
       J      Indices; yield [1, ..., 13].
      x       Repeat the first digit once, the second digit twice, etc.
        S%11  Take the sum, modulo 11.
              (implicit) Print the checksum to STDOUT.
```
[Answer]
# JavaScript (ES6), ~~59~~ 56 bytes
```
s=>(s=s.slice(3,-1))+[...s].reduce(n=>n+s[i++]*i,i=0)%11
```
```
f=
s=>(s=s.slice(3,-1))+[...s].reduce(n=>n+s[i++]*i,i=0)%11
//s=>(s=s.slice(3,-1))+(n=0,[...s].map((c,i)=>n+=c*-~i),n)%11
//s=>(s=s.slice(3,-1))+(n=0,[...s].map(c=>n+=c*i++,i=1),n)%11
//s=>(n=0,[...(s=s.slice(3,-1))].map((c,i)=>n+=c*-~i),s+n%11)
//s=>(s=s.slice(3,-1,n=i=0))+eval(`for(c of s)n+=c*-~i++`)%11
console.log(...[
  '9780000000002',
  '9780201882957',
  '9781420951301',
  '9780452284234',
  '9781292101767',
  '9780345391803'
].map(f))
```
-3 bytes thanks to [@Shaggy's suggestion](https://codegolf.stackexchange.com/questions/153624/converting-isbn-13-to-isbn-10/153655#comment375454_153655).
[Answer]
# [Perl 5](https://www.perl.org/), 49 + 1 (`-p`) = 50 bytes
```
s/^...|.$//g;$\=(eval s/./"-$&0+".$i++*$&/ger)%11
```
[Try it online!](https://tio.run/##NYxNboMwFIT3PcUTdZOmCP887ICFuEWXUSUWDrFisIWddtOz1wWqzmY0M58mmMWpnCP7oJR@U8LY2JFL/2o@BweRUVZU5MDLghJblm/kwEaznF6EyCtF@@IyFx2xPe/gOd1shGm4mwg2wZdf7nD1C0wPl2xwBuwcHilSgPebgThMBka/shuT1uZYuSP4kKyfs25a/i982hJy0baoVbMlIZFrJWou9k0qxFZiLfcNNQoumvNO8lqqWovVf/6uY66C@wU "Perl 5 – Try It Online")
[Answer]
# [Pyth](https://pyth.readthedocs.io), 16 bytes
```
%s.e*ksbpP>Q3hT
```
**[Try it here!](https://pyth.herokuapp.com/?code=%25s.e%2ahksbpP%3EQ3hT&input=%229780345391803%22&debug=0)**
# [Pyth](https://pyth.readthedocs.io), 17 bytes
```
%s*VsMKpP>Q3SlK11
```
**[Try it here!](https://pyth.herokuapp.com/?code=%25s%2aVsMKpP%3EQ3SlK11&input=%229780345391803%22&debug=0)**
### Explanation
```
%s.e*hksbpP>Q3hT || Full program. Uses string for input and output.
            Q    || The input.
           > 3   || With elements at indexes smaller than 3 trimmed.
          P      || Pop (remove the last item).
         p       || Print the result without a linefeed, but also return it.
  .e             || Enumerated map. For each (index, value), assign two variables (k, b).
       sb        || b converted to an integer.
    *hk          || And multiplied by k + 1.
 s               || Summation.
%                || Modulo by:
               T || The literal 10.
              h  || Incremented by 1.
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt/), ~~16~~ 15 bytes
Came up with this down the pub the other night and forgot all about it.
```
s3J
U+¬x_*°TÃuB
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=czNKClUrrHhfKrBUw3VC&input=Ijk3ODAzNDUzOTE4MDMi)
* 1 byte saved thank to [ETHproductions](https://codegolf.stackexchange.com/users/42545/ethproductions)
[Answer]
# [Hexagony](https://github.com/m-ender/hexagony), ~~77~~ 61 bytes
```
,,,,'~'11=\.A&.=\./';"-'"{4.8}}\'.A.>.,<\'+'%!@}/=+'+{./&{{&/
```
[Try it online!](https://tio.run/##y0itSEzPz6v8/18HCNTr1A0NbWP0HNX0gKS@urWSrrpStYmeRW1tjLqeo56dno5NjLq2uqqiQ62@rba6drWevlp1tZr@//@W5hYGxiamxpaGQBoA "Hexagony – Try It Online")
---
Colored:
[![](https://i.stack.imgur.com/oI4fh.png)](https://i.stack.imgur.com/oI4fh.png)
---
Here is a larger version. There are some path crossings, but because all of those cells are `.` (no-op in Hexagony), you don't need to worry about them:
(I also tried to keep the old mirrors, but sometimes I need to change something)
[![](https://i.stack.imgur.com/obLU6.png)](https://i.stack.imgur.com/obLU6.png)
The linear command executed is:
```
,,,,'48}}
,
while memory > 0:
    ';"-'"{+'+{=A&=''A
    if memory < 0:
        undefined behavior
    &{{&}
    ,
'"''+~'11='%!@
```
---
Explanation: Instead of keeping a counter and do multiplication at each digit, this program:
* keep a "partial sum" variable and "total sum" variable (`p` and `t`)
* for each digit read: add it to partial sum, and add the partial sum to total sum.
* print `(-p-t)%11`, where `%` always return positive results.
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), ~~29~~ ~~25~~ ~~24~~ 23 bytes
**Solution:**
```
x,$11!7+/(1+!9)*x:-1_3_
```
[Try it online!](https://tio.run/##y9bNz/7/v0JHxdBQ0VxbX8NQW9FSU6vCStcw3jheydLcwsDE1MjIwsTI2ETp/38A "K (oK) – Try It Online")
**Examples:**
```
x,$11!7+/(1+!9)*x:-1_3_"9780000000002"
"0000000000"
x,$11!7+/(1+!9)*x:-1_3_"9780345391803"
"0345391802"
x,$11!7+/(1+!9)*x:-1_3_"9781292101767"
"1292101768"
x,$11!7+/(1+!9)*x:-1_3_"9780452284234"
"0452284236"
```
**Explanation:**
Evaluation is performed right-to-left. 
Two tricks taken from other solutions:
* multiply by 1 2 3... instead of 10 9 8...
* multiply ASCII values and then add 7 to the sum to balance out
Breakdown:
```
x,$11!7+/(1+!9)*x:-1_3_ / the solution
                     3_ / drop three items from the start
                  -1_   / drop one item from the end
                x:      / save this as variable x
               *        / multiply by
         (    )         / all this together
            !9          / til, !9 => 0 1 2 3 4 5 6 7 8
          1+            / add 1 => 1 2 3 4 5 6 7 8 9
      7+/               / sum (+) over (/), start from 7
   11!                  / mod by 11
  $                     / convert back to a string
x,                      / join with x
```
**Notes:**
* **-4 bytes** thanks to [Martin Enders's](https://codegolf.stackexchange.com/a/153631/69200) "*just invert the coefficients*" magic.
* **-1 byte** thanks to [Tom Carpenter](https://codegolf.stackexchange.com/a/153641/69200) for removing the need to convert to integers (by adding `7` to the sum)
* **-1 byte** start the accumulator at 7
[Answer]
# C (gcc), ~~96 95 87 86~~ 85 bytes
(-1 thanks to ceilingcat)
```
*f(s,r,c,d)char*s,*r;{for(d=13;--d;s+=*++s<48)r=d>8?c=3,s:r,c-=~d**s;*s=58-c%11;s=r;}
```
[Try it online!](https://tio.run/##jdDNTsQgFAXgvU9BJjFpaU/CvYClIvogxsWEZnQWjgbGVVNfvcLClTHhLmBzf06@iNcY912eujymMY5LH9@OSeZRJr@ePlK3BNIeWHweghyG/GBcn8Ly6J5i0GO@L0MI34uU2cscrEO8JfI5JL/t58tVvB/Pl64X640otYq6XeTnFxHEYZ6c@i0@ePH5dc1dCdL3Xmz/9LMi53i2U1s/GVazJa2ocb@xzM6wNo37eWZSNN015lHaWD1T@dv6oRQqT33ArTOMqoTChMZcIIMqhUIFar1jULVQuGBa7zCqGApZczZV1hc1FDb8ddv2Hw)
To be called as `f(s)`, where `s` is a pointer to the first element of a modifiable character array. Modifies the input array, returns a pointer into the input array.
[Answer]
# [Python 2](https://docs.python.org/2/), 62 bytes
```
lambda n:n[3:12]+`-sum(i*int(n[13-i])for i in range(2,11))%11`
```
[Try it online!](https://tio.run/##NY5BDoIwFETXeopuTFuFpP@3FUqCF0ESMIo2kQ9BXHj6CsbOZpJ5M8mMn/kxEIauPIdn21@uLaOCKl0A1ocmfb174feeZkEV6NTXshsm5pknNrV0vwlMAKTcATRhJbSSirssV1HIE/YLUEGeo7PZPwCDylnQCmLDWMTcoDaxgQ5BQXaME6WN1Q4W53Wx3YzT8oxRwssTTzpBMnwB "Python 2 – Try It Online")
Takes a string as input; and outputs a string.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
ṫ4ṖµV€×JS%11;@
```
[Test suite!](https://tio.run/##y0rNyan8///hztUmD3dOO7Q17FHTmsPTvYJVDQ2tHYDC@0D8diAR@f9/tKW5hYGxiamxpSGQ1lEAcY0MDC0sjCxNzcFcQxMjA0tTQ2MDQ4isiamRkYWJkbEJRNbI0sjQwNDcDKIYYVQsAA "Jelly – Try It Online")
# [Jelly](https://github.com/DennisMitchell/jelly), 17 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
Ṛḣ⁵µVD×JḊSN%11;ḊṚ
```
[Try it online!](https://tio.run/##y0rNyan8///hzlkPdyx@1Lj10NYwl8PTvR7u6Ar2UzU0tAYygHL///9XsjS3MDA2MTW2NATSSgA "Jelly – Try It Online") or [Test suite!](https://tio.run/##y0rNyan8///hzlkPdyx@1Lj10NYwl8PTvR7u6Ar2UzU0tAYygHJA@X2PmtYcbgcSkf//R1uaWxgYm5gaWxoCaR0FENfIwNDCwsjS1BzMNTQxMrA0NTQ2MITImpgaGVmYGBmbQGSNLI0MDQzNzSCKEUbFAgA "Jelly – Try It Online")
Takes input and outputs as a string.
[Answer]
# [ECMAScript 6](https://www.ecma-international.org/ecma-262/6.0/), ~~86~~ 67 bytes
```
a=>(c=a.substr(3,9))+([...c].map(v=>g+=--i*v,e=i=g=11)?(e-g%e)%e:0)
```
[Try it online!](https://tio.run/##bY5BDoIwEEX3noKNoVUonWmB1qR6EOOiYiUYBALI9dGFZdXZ/OTl5WVedrFTNTbDnHb9w61Ps1pzJpWxbPrcp3kkItGUHsmVMVbd2NsOZDHn@mjStDksiTONqQ0AvRCX1ntH9@7E6Vr13dS3jrV9TZ4k1qXi/jCmNMqyaAN8F7CRg1Ko89LbGwjYIJHrHASHv72BYFvmiEqikL7tQRFqo0bgUBb@kw2oUFvIXGj4rW97gOsX "JavaScript (Node.js) – Try It Online")
---
Thanks for [Arnauld's comment](https://codegolf.stackexchange.com/questions/153624/converting-isbn-13-to-isbn-10#comment375235_153645), switched from `reduce` to `map` and got rid of `return` keyword.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), ~~72~~ 51 bytes
```
...(.*).
$1¶$1
r`.\G
$&$'
r`.\G
$*
1{11}
¶(1*)
$.1
```
[Try it online!](https://tio.run/##NYoxDsIwEAT7e4cBx8Xp9mxj3wvyiRRJQUFDEdEhvpUH5GOGWMo2u6PZ9fF@vpZ28ePcmNlzGJgc9s2B1pmnkdzV3c4ZCB/gS7RvHmEgx2jNSpUzSgepoFa1XA5CUrGMKOguZdWaNKbu1BSCcu9PiSlHw79/ "Retina 0.8.2 – Try It Online") Because I haven't learned Retina 1.0 yet. Explanation:
```
...(.*).
$1¶$1
```
Delete the unwanted characters and make a second copy of the appropriate digits.
```
r`.\G
$&$'
```
Suffix each digit in the second copy with its suffix. This effectively repeats each digit in the suffix by its position.
```
r`.\G
$*
```
Convert the digits in the second copy to unary thus adding them together.
```
1{11}
```
Reduce modulo 11. (There are only 9 digits in the first copy, so this can never affect it.)
```
¶(1*)
$.1
```
Convert the result back to decimal and remove the newline again.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~26~~ 24 bytes
```
∊⍕¨(⊢,11|⊢+.×⍳∘≢)3↓¯1↓⍎¨
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/8PBI86uh71Tj20QuNR1yIdQ8MaIKWtd3j6o97NjzpmPOpcpGn8qG3yofWGQPJRb9@hFQrqluYWBjBgpM5FngFGBoYWFkaWpuZkGmBoYmRgaWpobGBIrgtMTI2MLEyMjE3IdYGRpZGhgaG5GbleMDA2MTW2NATS6gA)
Tacit prefix function. Takes input as string.
2 bytes saved thanks to @ngn.
### How?
```
∊⍕¨(⊢,11|⊢+.×⍳∘≢)3↓¯1↓⍎¨    ⍝ Main function.
                       ⍎¨    ⍝ Execute each; turns the string into a vector of digits.
                 3↓¯1↓       ⍝ Drop (↓) the last (¯1) and the first 3 digits.
   (           ≢)            ⍝ Tally; returns the number of digits in the vector.
             ⍳∘               ⍝ Then (∘) index (⍳) from 1
            ×                ⍝ Multiply the resulting vector [1..9]
         ⊢+.                 ⍝ Dot product with sum with the original vector;
                             ⍝ This will multiply both vectors, and sum the resulting vector.
      11|                    ⍝ Mod 11
     ,                       ⍝ Concatenate
    ⊢                        ⍝ With the original vector
 ⍕¨                          ⍝ Format each; returns a vector of digits as strings.
∊                            ⍝ Flatten to get rid of the spaces.
```
[Answer]
# [Clean](https://clean.cs.ru.nl), ~~104~~ ~~102~~ 98 bytes
```
import StdEnv
$s#s=s%(3,11)
#i=sum[digitToInt d*p\\d<-s&p<-[10,9..]]+10
=s++[toChar(i/11*11-i+58)]
```
[Try it online!](https://tio.run/##VZFLU4MwFIXX8iuurTYgoCRAC05Z@ZjpjLs64wKyQKBtZkrCkODjz4upWLTZJN/NyTm5SbGvct7Xouz2FdQ54z2rG9EqWKvygb8ZF3IqE3lp@g7GljFliezqtGRbpp7Fiisor5osK5eunDVLN8WeE19fU2pjz0ikbadK3O3y1mQ3GF9h7DI7jCzar1XeKmMKm44XigkOCVxoVJVUUq9T48xMUbyIvOMgiDopGtFD1HJGEfFwFJE4XAyif/gnwgHx4hD7Hv4RjXjqFISERAHxg8HpiPMTJxIT7OHFfIgbMTpx8oPQj7GeB6cj6j4s44wahm7SnDyKFiYO402nnAlshQI0cdpKdnvNyIH3HSt2wOTtQbUxh50kEZ3SJ6wU3Ym2rQp1jqhOfWkF34JZfTS6VJWAqG0PSv0NyDrcDmUcWZBlYA6Z8OsES/f37WcwhBwqdd6AOf6QgI3Uyh8Z7b@KzT7fyt5dPfX3nzyvWaHh9Rs "Clean – Try It Online")
[Answer]
# [Kotlin](https://kotlinlang.org), 83 bytes
```
i.drop(3).dropLast(1).let{it+(11-(it.mapIndexed{i,c->(10-i)*(c-'0')}.sum()%11))%11}
```
## Beautified
```
i.drop(3).dropLast(1).let {
    it + (11 - (it.mapIndexed { i, c -> (10 - i) * (c - '0') }.sum() % 11)) % 11
}
```
## Test
```
data class Test(val input: String, val output: String)
fun f(i: String) =
i.drop(3).dropLast(1).let{it+(11-(it.mapIndexed{i,c->(10-i)*(c-'0')}.sum()%11))%11}
val tests = listOf(
        Test("9780000000002", "0000000000"),
        Test("9780201882957", "0201882957"),
        Test("9781420951301", "1420951300"),
        Test("9780452284234", "0452284236"),
        Test("9781292101767", "1292101768"),
        Test("9780345391803", "0345391802")
)
fun main(args: Array<String>) {
    for (c in tests) {
        val answer = f(c.input)
        val good = answer == c.output
        println("$good ${c.input} -> ${c.output} | $answer")
    }
}
```
## TIO
[TryItOnline](https://tio.run/##dZLbaoQwEIbvfYpBtjRpVZKou7p0F3pZKPSifYHgYQl1o5jYA9ZntxpX24Kdi4R/8vPNMJPXUhdC9lbKNYek4ErBS6Y0euMFCFk1eg/Puhby5MCYKhv9K4ctK28k5EgsGThYvfDSuqyQj839yAccxV6R6VboW0Spi4T2zrx6kGn2kaWtcBL3iChxBb5BiXtNrnHnqeaM8BWleDy63hqr66EzBQcohNJPObLgEqZjO95FZA5mO2AvitjYWTEzQqOIxeHOmH/UmpkGjMQh9QkdzYv6hxyEjEUB8wNDntV2ncxiRgndbU0bi4rWyX4Q+jEdbkOeFbOxdVnGmQuJeH1Se7iva/55Ny3miKE1uLysASXDbqdpzukxxhFzqd6zephxjhLPfAD85/1UlunwOtsOkHjTn1hc1VBOFxLZG+PdtBdOB+7RqMnfwRdsJow9leisrv8G)
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~69 68~~ 64 bytes
```
->n{v=n[3,9];c=11;v+"#{(c-v.chars.map{|i|i.to_i*c-=1}.sum)%11}"}
```
[Try it online!](https://tio.run/##TY/bboMwEETf8xWIqKIXsLxrE@xE9EeIVVHXafwQB4WLWgHfTh2ikO7L6IxGs5pL@/k7HfIpeXd9l7uCxVLtdA6w697Cdf@sk47oY3mpyams@sEOljTnD/uqkxxGUrenlyeAMRynYlVEMhMUKQiBMs2iOIj@kYpvAeBIZQqMwjWwEF0ClKeIgiPjc8OdNo8GlAgUss38YiHxaGA8ZRK8zg13wkitFDGlPvodsRmqtqmD0Dqv28Dfurfj3n2fb3TlQ2GVt8xPZXRjvrbeMp73zu/9Aw "Ruby – Try It Online")
[Answer]
# PHP, 64 bytes
Unfortunately, in PHP `(-$c)%11` is the same as `-($c%11)`; so I have to get the difference to at least the largest sum possible (55\*9 = 495 = 45\*11) instead of just using `-$c%11`.
```
for($f=11;--$f>1;print$d)$c+=$f*$d=$argn[13-$f];echo(495-$c)%11;
```
or
```
for($c=45*$f=11;--$f>1;print$d)$c-=$f*$d=$argn[13-$f];echo$c%11;
```
Run as pipe with `-nR` or [try them online](http://sandbox.onlinephpfunctions.com/code/9abfe74dde711b6a8f9eea6c49f2792ad60d2513).
[Answer]
# Java 10, 110 bytes
```
l->{var s=l+"";int c=0,i=3;for(;i<12;)c+=(13-i)*(s.charAt(i++)-48);return(l-(long)978e10)/10*10+(11-c%11)%11;}
```
Takes input and outputs as a `long` integer. Try it online [here](https://tio.run/##nZJBS8MwGIbP3a8IBSFZ7cyXdq6lVlBPgnrZUTzELm7RmI4kq4jst8@0aydeWyjpm4Sn7wfPO294/L76OGx3r0pWqFLcWvTIpUY/k0BqJ8wbrwS6X94@3dW6EcbvtEeBqvUaSfuqgeK/74QUk2A/CXqcddz5panlCn16KF46I/X6@QVxs7akA/1Ht5S/VKKDiq9/Gm6QLVUUhoWvhKqSnssyKd5qgwt5BawgVVRiSGJJptjOqg03Nw7LKCJxmpHCCLczGqu4K0ryRSaAkgugU6ARBoirMwDi32J/CAI/QLD8tk58zuqdm219Yac03vIV/ldu1g/vcXR42AMhUYhOmYZkDI5RyDKWzxc97pRH4SBlNJ9DQuGIO@WR7dI5Y1nKkrRvN@TLce1YzoDC4rIf9pSzce2SdJ7k4Ne@3ZBZOKhpZMOdGNw8GolaZqexOlrZb1uvYOed3/raSCW8Xkrotdtggq6Q18gfBO0tGtn20tE1ZLt/7Q@/).
Ungolfed version:
```
l -> { // lambda taking a long as argument
    var s = l + ""; // convert the input to a String
    int c = 0, // the check digit
    i = 3; // variable for iterating over the digits
    for(; i < 12 ;) // go from the first digit past 978 to the one before the check digit
        c += (13 - i) * (s.charAt(i++) - 48); // calculate the check sum
    return (l - (long) 978e10) // remove the leading 978
           /10 *10 // remove the original check digit
           + (11 - c % 11) % 11; // add the new check digit
}
```
]