[Question]
  [
[Sandbox](https://codegolf.meta.stackexchange.com/a/18107/64722)
# French License Plates
[French license plates](https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_France) come in a sequential order, following a specific pattern of numbers and letters : `AB-012-CD`
## Challenge
Write a program or function that, for a given number, outputs the corresponding [french license plate](https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_France) number. Your program should not handle any special case as specified in the linked page. It should be able to generate the full `26*26*1000*26*26 => 456 976 000` possible plates, or as far as your language can support.
The numbering system goes as follows:
* AA-000-AA to AA-999-AA (numbers evolve first);
* AA-000-AB to AA-999-AZ (then the last letter on the right);
* AA-000-BA to AA-999-ZZ (then the first letter on the right);
* AB-000-AA to AZ-999-ZZ (then the last letter on the left);
* BA-000-AA to ZZ-999-ZZ (then the first letter on the left).
### Input
* The plate number's index as an integer
### Output
* The corresponding french license plate number
### Additional information
* Letters have to be uppercase
* You can use both 0-based and 1-based indexing to generate the plates (meaning AA-000-AA can correspond to `0`or `1`, assuming all the other test cases use the same indexing.
This is [code-golf](https://codegolf.stackexchange.com/tags/code-golf/info), shortest answer in every language wins!
## Test cases (0-based indexing)
```
          0 -> AA-000-AA
          1 -> AA-001-AA
        999 -> AA-999-AA
       1000 -> AA-000-AB
    675 999 -> AA-999-ZZ
    676 000 -> AB-000-AA
456 975 999 -> ZZ-999-ZZ
```
  
[Answer]
# Pure [Bash](https://www.gnu.org/software/bash/) (no external utils), 64
* 2 bytes saved thanks to @NahuelFouilleul
```
x={A..Z}
eval f=($x$x-%03d-$x$x)
printf ${f[$1/1000]} $[$1%1000]
```
[Try it online!](https://tio.run/##PY5NC4JAGITv7694kRWVUFdKRVKhQ127Fx22/WAF01ApQfztpkXenpmBmbmzVk@cdZijasqCe63GNEXreD5ZU58NB8@7jCBfrESV2aQnvWvSrXAXcuDZFFWnkAzqSgI/oJTeRiQzm1@e5hbg@lELZJt@HYC3LkqJjWQCO9l2nLVyj6IGyXWNBvl76OZIbM9fj62JY4CoKzlRCCBJEljWIIrDhaM4WtQujJKf8QE "Bash – Try It Online") - takes about 10s to run over the 7 testcases.
* Line #1 is a simple assignment of a string to a variable
* Line #2 is a brace expansion to build an array of printf format strings, one for all 456,976 possible letter combinations, with the digits not yet specified. The `eval` is required to ensure variable expansion (of x) occurs before brace expansion.
* Line #3 indexes the array to get the appropriate format string and takes the digits portion as its parameter.
[Answer]
# [Perl 5](https://www.perl.org/) (-ap), 47 bytes
```
$_=AAAA000;$_++while$F[0]--;s/(..)(\d+)/-$2-$1/
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3tYRCAwMDKxV4rW1yzMyc1JV3KINYnV1rYv1NfT0NDViUrQ19XVVjHRVDPX//zczN7W0tPyXX1CSmZ9X/F83sQAA "Perl 5 – Try It Online")
---
# [PHP](https://php.net/), 74 bytes
```
for($a=AAAA000;$argn--;$a++);echo preg_replace('/(..)(\d+)/','-$2-$1',$a);
```
[Try it online!](https://tio.run/##HYzRCsIgGIXvfYoYgopz0yCHWEQ3PcUgZLktCP2xPf/sr3NxznfgcGCFer4C@pwLp@FyQ2mtPQ1lSUphSil8nNZ8gBKXR4nwDlPkrOddJ/j4lKJnLVP0qKhhLQ3C1/@6GVPjqyaGOOeIwU9ih9OP7WCx7Rm2V06fqu5f "PHP – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 79 78 77 bytes
```
lambda n:f"%c%c-{n%1000:03}-%c%c"%(*(65+n//1000//26**i%26for i in[3,2,1,0]),)
```
[Try it online!](https://tio.run/##XY7BaoNAEIbveYphYUHNiqvWLQoeNodCIYdAbjY9GN2lC2YjyQZSSp7drLEa29vM9883M@23@TrquJP5rmvKw74uQWcS4QpX/o/GIaU0o/HN7wHCjuewZKmDoOdBEDHPUzhi8ngCBUp/xCQiIaGfLnG7Wkgw4mwcpduLISCuraiMqN1sAVBW5lI2kIMcYtey9qS0cYaEAMrR07Hthm@3CJSc1HxKQTRnAeiNv69Rv2jxOEutxLlvH/U5t/wBwxGGM5im6YBtMZ@16mzHauTsNfljFMUzYb/O6t/dl4Slo1YUk9bdAQ "Python 3 – Try It Online")
I somehow never realised that the `f"string"` format shortcut exists until seeing Black Owl Kai's answer.
[Answer]
## Ruby, ~~61~~ ~~59~~ 55 bytes
```
->n{s='AA-AA000-';eval's.succ!;'*n;s[2]+=s[5,4];s[0,9]}
```
Also 55 bytes:
```
->n{s='AA-AA000-';eval's.succ!;'*n;s[2]+=s.slice!5,4;s}
```
[Try it online!](https://tio.run/##KypNqvyfpmD7X9cur7rYVt3RUdfR0cDAQFfdOrUsMUe9WK@4NDlZ0VpdK8@6ONooVtu2ONpUxyQWyDHQsYyt/V@gAGQoGOooWFpaAmmgVh0FM3NTMM/M3AzIj9XLTSyorqmoUUiLrgDqAAA)
This initializes a counter to `AA-AA000-`, increments it `n` times (by multiplying a string of the code that does so by n and `eval`ing), and then moves the last 4 characters after the 3nd.
[Answer]
## Haskell, ~~85~~ ~~81~~ ~~79~~ 77 bytes
```
([h++'-':n++'-':t|h<-q"AZ",t<-q"AZ",n<-q"099"]!!)
q g=mapM(\_->[g!!0..g!!1])g
```
[Try it online!](https://tio.run/##y0gszk7NyfmfZhvzXyM6Q1tbXVfdKg9CldRk2OgWKjlGKemUwBh5IIaBpaVSrKKiJlehQrptbmKBr0ZMvK5ddLqiooGeHpA0jNVM/5@bmJmnYKuQks@loKBQUJSZV6KgopCmYIDKNTM3tbS0RBczMzAw@P8vOS0nMb34v25yQQEA "Haskell – Try It Online")
[Answer]
# [PHP](https://php.net/), ~~96~~ ~~84~~ 79 bytes
-5 byte thanks to [Ismael Miguel](https://codegolf.stackexchange.com/users/14732/ismael-miguel)'s great comments.
```
for($s=AAAA;$x++^$argn/1e3;)$s++;printf('%.2s-%03u-'.$s[2].$s[3],$s,$argn%1e3);
```
[Try it online!](https://tio.run/##HY/dasMwDIXv/RSiODQl/82aErIxdtHdDkLvtq5kidIYMttYDu3TL3MihDj64BwhPej5@VUPmrEkgfMgCFwT2hBIyBZhVJZA9XBvjBTyRtDIDqSyokWnDYI2QlrsVm4HBIM0jRZaNY0d/GCrfhFoVPeYoTHKXA1qZayL8k/XU11/1Ltq7pXxOb28uar4Iwi@eWNuMskwr3acgqBaj/T@1ov3FHlpPkXbmNPn/rLM/BJyCleL5ywuD9tBweZLbio2SfeMzx@OpixjZVmyLE1TVhwPiy6OxbI9HYpyBX9KW6EkzdH7Pw "PHP – Try It Online")
I take advantage of the fact that you can increment letters in PHP! So `AAAA++` would become `AAAB` and `AAAZ++` would become `AABA`. I calculate how many times the letters have to be incremented by getting integer part of `input/1000`. Then increment the four characters length that many times and its first two and last two characters will automatically become the left and right side of the plate.
For example for input of `675999` number of letter increments is `(int)(675999 / 1000) = 675`, so `AAAA` will become `AAZZ`.
Finally, the middle number is calculated by `input%1000` and everything is printed in the specified format with help of [printf](https://www.php.net/manual/en/function.printf.php). `%.2s` prints first two characters of the string, `%03u` pads the number in the left with 3 zeros.
[Answer]
# C, 88 86 bytes
```
#define d(b)a/b/1000%26+65
f(a){printf("%c%c-%03d-%c%c",d(17576),d(676),a%1000,d(26),d(1));}
```
Pretty simple, it uses division and modulus to extract the fields, adds 'A' for the letters to map them to ASCII characters, and printf formatting for the numbers.
[Try it online!](https://tio.run/##dY7NCgIhEIDP7VOIITiUrG6piK/SxdU1PCQR3ZZ9dtMo6JBzmZ@Pb2Y8u3pfyj4sMeUFBTqDG@dRcM7JpA5KDpE6WO@PlJ@RYuKJZ4SfAmsVPgYqtNQKaqFacqSZtZveMwFgt1JVdHMpU0DrsIsUfYKDRd/Fl4zB/kLRh8aYLmznO1Bp2Tfr9x3zLJX5b27lBQ "C (gcc) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~25~~ ~~22~~ 20 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
Au2ããs₄‰`UèX₄+¦'-.øý
```
-2 bytes (and increased the performance by not generating the entire list) thanks to *@Grimy*.
0-based indexing.
[Try it online](https://tio.run/##yy9OTMpM/f/fsdTo8OLDi4sfNbU8atiQEHp4RQSQqX1ombqu3uEdh/f@/29uYmFsYGIKAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9W6WKvpPCobZKCkv1/x1Kjw4sPLy5@1NTyqGFDQujhFRFApvahZeq6eod3HN77X@d/tIGOoY6lpaWOoYEBkGlkbGKqYwgGOmbmpiAJM3MzkJS5iYWxAVDSxNTMEiwRCwA).
**Explanation:**
```
Au            # Push the lowercase alphabet, and uppercase it
  2ã          # Create all possible pairs by taking the cartesian product with itself:
              #  ["AA","AB","AC",...,"ZY","ZZ"]
    ã         # Get the cartesian product of this list with itself:
              #  [["AA","AA"],["AA","AB"],...,["ZZ","ZZ"]]
s             # Swap to push the (implicit) input
 ₄‰           # Take the divmod-1000 of it
              #  i.e. 7483045 becomes [7483,45]
    `         # Push these values separated to the stack
     U        # Pop and store the remainder part in variable `X`
      è       # Index the integer part into the list of letter-pairs we created earlier
              #  i.e. 7483 will result in ["AL","BV"]
X             # Push the remainder part from variable `X` again
 ₄+           # Add 1000 to it
   ¦          # And remove the leading 1 (so now the number is padded with leading 0s)
              #  i.e. 45 becomes 1045 and then "045"
    '-.ø     '# Surround this with "-" (i.e. "045" becomes "-045-")
        ý     # Join the two pairs of letters by this
              #  i.e. ["AL","BV"] and "-045-" becomes "AL-045-BV"
              # (after which the top of the stack is output implicitly as result)
```
The last part (`s₄‰`UèX₄+¦'-.øý`) could be `I₄÷èI₄+3.£.ý'-ý` for an equal-bytes alternative:  
[Try it online](https://tio.run/##yy9OTMpM/f/fsdTo8OLDiz0fNbUc3n54BYjWNtY7tFjv8F513cN7//83N7EwNjAxBQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKS/X/HUqPDiw8vrnzU1HJ4@@EVIFrbWO/QYr3De9V1D@/9r/M/2kDHUMfS0lLH0MAAyDQyNjHVMQQDHTNzU5CEmbkZSMrcxMLYAChpYmpmCZaIBQA).
```
I₄÷           # Push the input, integer-divided by 1000
   è          # Use it to index into the letter-pairs we created earlier
              #  i.e. 7483045 becomes 7483 and then ["AL","BV"]
I₄+           # Push the input again, and add 1000
   3.£        # Only leave the last three digits
              #  i.e. 7483045 becomes 7484045 and then "045"
      .ý      # Intersperse the pair with this
              #  i.e. ["AL","BV"] and "045" becomes ["AL","045","BV"]
        '-ý  '# And join this list by "-"
              #  i.e. ["AL","045","BV"] becomes "AL-045-BV"
              # (after which the top of the stack is output implicitly as result)
```
[Answer]
# [J](http://jsoftware.com/), ~~56~~ ~~49~~ 46 bytes
```
226950 A.'--',7$_3|.4,@u:65 48+/(4 3#26 10)#:]
```
[Try it online!](https://tio.run/##VY6xCsIwFEX3fsXFCrHYxLRNUhMQTAUn6eAYEAexiIuTm/8eo0RihjfcczmXd/czRiZsDAhqcJhwlGF3POx92yotOSwjlJK6n5@7FxP19mmUhFgvVwuBrmwVGl6V5uSrorhebg9MUL3UWsdIrKWcc2otATWh5f@8SbxJPNiJf6bypeFnhJRLzsUqvhDLIf9A9SqZzuWmkEp/ZYwDg38D "J – Try It Online")
*-3 bytes thanks to FrownyFrog*
The whole thing is nothing but 7 nested trains -- if that ain't fun, what is?
```
  ┌─ 226950                                            
  ├─ A.                                                
  │        ┌─ '--'                                     
──┤        ├─ ,                                        
  │        │      ┌─ 7                                 
  └────────┤      ├─ $                                 
           │      │   ┌─ _3                            
           └──────┤   ├─ |.                            
                  │   │    ┌─ 4                        
                  └───┤    │     ┌─ ,                  
                      │    ├─ @ ─┴─ u:                 
                      └────┤                           
                           │     ┌─ 65 48              
                           │     ├─ / ───── +          
                           └─────┤                     
                                 │       ┌─ '4 3#26 10'
                                 └───────┼─ #:         
                                         └─ ]         
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 82 bytes
```
n=>'32-654-10'.replace(/\d/g,x=>Buffer([x&4?n/10**(x-4)%10+48:n/1e3/26**x%26+65]))
```
[Try it online!](https://tio.run/##dc9BDoIwEAXQvadgg7TF0hbaKiZg4BioCwIt0RAgoIbbIwuiqDiryeTl/8w1faRd1l6aG67qXA06GKogtDwXS8Exo5bTqqZMMwXIKSfFpg/C@K61asGxX/NDRRhFCPSYQ5NRm@/240V5xJUI9aYrbSnOEA5ZXXV1qZyyLoAGxjQUQoMQI4owpRRH0WqZsRlj/5jv@y827n8YG4s@S@NfJrfiOy1Jlph8p8XLL3Ah/VlakkxpwxM "JavaScript (Node.js) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 51 bytes
```
->n{[*?A*4..?Z*4][n/1e3][/../]+"-%03d-"%(n%1e3)+$'}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6vOlrL3lHLRE/PPkrLJDY6T98w1Tg2Wl9PTz9WW0lX1cA4RVdJVSNPFSisqa2iXvu/QCHaQEfBUEfB0tISSBsYAHlm5qZgnpm5GZhvYmpmCRaK1ctNLKiuqahRSIuuiK39DwA "Ruby – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 101 bytes
```
b=0:3;a=scan()%/%c(10^b,1e3*26^b)%%rep(c(10,26),e=4);intToUtf8(c(a[8:7],-20,a[3:1]-17,-20,a[6:5])+65)
```
[Try it online!](https://tio.run/##LcjdCoMgFADgpxE860T@5DEN32JdhYGGQTdtVO/vNtjl95215iC8HlO41nRwYB1buRRLRln0Q9GSgbGzvPlvURFgCT2M@3E/X9O9Dd9P8@BtxFYJTLP2MrbS/kXeRGjIQCVrnHP1Aw "R – Try It Online")
Just does the needed arithmetic computations. I saved 5 bytes by including in the vector `a` a useless value at `a[4]`, allowing me to reuse the helper vector `b`.
Consider for example the second character (the `B` in `AB-012-CD`). That character changes every \$26\times26\times1000=676\,000\$ plates, so the value of that character for input `n` is the `n %/% 676000 %% 26`th letter of the alphabet, where `%/%` is integer division and `%%` is modulus in R. The other characters are computed similarly.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~26~~ 22 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ØAṗ2,`ØDṗ3¤ṭŒp⁸ị2œ?j”-
```
A monadic Link accepting an integer (1-indexed) which yields a list of characters... Crazy-slow since it builds all the plates first!
**[Try it online!](https://tio.run/##ATUAyv9qZWxsef//w5hB4bmXMixgw5hE4bmXM8Kk4bmtxZJw4oG44buLMsWTP2rigJ0t////MTAwMA "Jelly – Try It Online")** (wont complete)  
Or try [a reduced alphabet version](https://tio.run/##y0rNyan8//9RwxxHJ@dHDXMf7pxupJNweIYLkGF8aMnDnWuPTip41Ljj4e5uo6OT7bOASnT///9vaWBgCAA "Jelly – Try It Online") (only "ABC" for the letters).
---
For code which completes in a timely manner here's a 32 byte full-program (0-indexed) which creates the single plate instead using modular arithmetic and numeric base decompression:
```
dȷ+“©L§“£ż’µḢṃØAṙ1¤ḊŒHW€jDḊ€$j”-
```
**[Try this one!](https://tio.run/##y0rNyan8/z/lxHbtRw1zDq30ObQcRC8@uudRw8xDWx/uWPRwZ/PhGY4Pd840PLTk4Y6uo5M8wh81rclyAbKBtErWo4a5uv///zczNzMwMAAA "Jelly – Try It Online")** 
[Answer]
# APL+WIN, 61 bytes
Prompts for integer:
```
m←⎕av[4↑66+n←((4⍴26),1E3)⊤⎕]⋄(2↑m),'-',(¯3↑'00',⍕4↓n),'-',2↓m
```
[Try it online! Courtesy of Dyalog Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcjzra0/7nAplAocSyaJNHbRPNzLTzgAIaGiaPercYmWnqGLoaaz7qWgJUEfuou0XDCKgmV1NHXVddR@PQemMgT93AQF3nUe9UoO7JeRAZoKLJuf@Bpv9P4zLgSuMyBGJLS0sQy8AAJGBmbgrhm5mbQURMTM0swYIA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 33 bytes
```
Ｎθ¹✂Ｉ⁺θφ±³≔⪪⍘⁺Ｘ²⁶¦⁵÷θφα²η¹⊟ηＭ⁹←⊟η
```
[Try it online!](https://tio.run/##bY3NCsIwEITvPkWOG6gHU7T@nPy5FLQE@gSxbttATNpmWx8/RoRelGFgYPebqVo1VE6ZEHLbjVSMzzsO0PPDQg7aEqzmVBpdIZyVJ5Bm9NAnrOY8YQU2ihBSzuPr0XvdWCg7owlOymNJEW6@hHSv2C02CVtHLrd00ZN@4NykokV0@2ddug7az8LNTQi7hO2vWNPPOQSRpduoTITlZN4 "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｎθ
```
Input the number.
```
¹
```
Print a `-`.
```
✂Ｉ⁺θφ±³
```
Add 1000 to the number, then cast the result to string, and print the last three digits.
```
≔⪪⍘⁺Ｘ²⁶¦⁵÷θφα²η
```
Divide the number by 1000, then add 26⁵, so the conversion to custom base using the uppercase alphabet results in a string of length 6, which is then split into pairs of letters.
```
¹
```
Print a `-`.
```
⊟η
```
Print the last pair of letters.
```
Ｍ⁹←
```
Move to the beginning of the number plate.
```
⊟η
```
Print the rest of the desired letters.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 42 bytes
```
{S/(..)(\d+)/-$1-$0/}o{('AAAA000'..*)[$_]}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/OlhfQ09PUyMmRVtTX1fFUFfFQL82v1pD3REIDAwM1PX0tDSjVeJja/9bcxUnViqkaajEayqk5RcpGOgoGOooWFpaAmmgSh0FM3NTMM/M3AzIV1DWUTAxNbMEC/4HAA "Perl 6 – Try It Online")
Port of Grimy's Perl 5 solution. Slow for large input values.
[Answer]
# Excel, ~~183~~ ~~167~~ ~~155~~ 147 bytes
-16 bytes thanks to @Neil. (6 by using `E3`)
-12 bytes thanks to @Keeta. (`TRUNC` instead of `QUOTIENT`)
-8 bytes thanks to @Jonathan Larouche (`INT` instead of `TRUNC`)
```
=CHAR(65+INT(A1/17576E3))&CHAR(65+MOD(INT(A1/676E3),26))&"-"&TEXT(MOD(A1,1E3),"000")&"-"&CHAR(65+MOD(INT(A1/26E3),26))&CHAR(65+MOD(INT(A1/1E3),26))
```
Concatenates 5 parts:
```
CHAR(65+INT(A1/17576E3))
CHAR(65+MOD(INT(A1/676E3),26))
TEXT(MOD(A1,1E3),"000")
CHAR(65+MOD(INT(A1/26E3),26))
CHAR(65+MOD(INT(A1/1E3),26))
```
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 107 bytes
```
import StdEnv
A=['A'..'Z']
N=['0'..'9']
$n=[[a,b,'-',x,y,z,'-',c,d]\\a<-A,b<-A,c<-A,d<-A,x<-N,y<-N,z<-N]!!n
```
[Try it online!](https://tio.run/##Hc2xCoMwFIXh3aeIIGS5kS5tCegQaIdCcXFrdLgmtghJLNUW9eGbJl0@zj8dZXp03o76bXpicXB@sM/xNZN61mf3SUQpqaB5Tm@0TaoQuxg8ROZKKRE6oIzCAits/6VAt02DBRPQRVRER5aCVbBGtkCbps7XM4arkmTkcNxzzv1X3Q0@Js8uV39aHdpBTT8 "Clean – Try It Online")
Defines `$ :: Int -> [Char]` giving the n-th zero-indexed licence plate.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 21 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Obscenely slow! Seriously, don't even try to run it!
Tip of the hat to [Kevin](https://codegolf.stackexchange.com/a/193459/58974) for making me realise where I was going wrong when fighting to get this working last night.
```
;gBï ï ïq#d0o ùT3 û-5
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=O2dC7yDvIO9xNfIg%2bVQzIPstNQ&input=OA) - limits the number range to `000-005`.
```
;gBï ï ïq#d0o ùT3 û-5     :Implicit input of integer
 g                        :Index into
; B                       :  Uppercase alphabet
   ï                      :  Cartesian product with itself
     ï                    :  Cartesian product of the result with itself
       ï                  :  Cartesian product of that with
         #d0              :    1000
            o             :    Range [0,1000)
              ùT3         :    Left pad each with 0 to length 3
                  û-5     :    Centre pad each with "-" to length 5
        q                 :  Join the first element (the 2 pairs of letters) with the second (the padded digit string) 
```
[Answer]
# [Forth (gforth)](http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/), 94 bytes
```
: x /mod 65 + emit ; : f dup 1000 / 17576 x 676 x ." -"swap 0 <# # # # #> type ." -"26 x 1 x ;
```
[Try it online!](https://tio.run/##LU1LDsIgFNxzigkuDS0YgVBM72JsURdNCWLU0@OjNC/zfjOZCWvKD3EPdZQy4It@WScYjSPm5ZnhMSBgekcoKSV6KKutIZ3Zesch@OtzjZC4HLDXiPyLcyNPVaYInuzj5uTQpUpCjODkfkvwTCIyRXDO1a2GRWasbjeltc9ZG7c/yx8 "Forth (gforth) – Try It Online")
0-indexed. Input is taken from top of stack
### Code explanation
```
\ extract out some common logic
: x             \ start a new word definition
  /mod          \ divide first argument by second and get both quotient and remainder
  65 +          \ add 65 (ascii A) to quotient
  emit          \ output
;               \ end word definition
: f             \ start a new word definition
  dup 100 /     \ duplicate input and divide by 1000
  17576 x       \ divide by 26^3 and output ascii char
  676 x         \ divide by 26^2 and output ascii char
  ." -"         \ output "-"
  swap 0        \ grab original number and convert to double-cell number
  <# # # # #>   \ convert last 3 chars of number to a string
  type ." -"    \ output string followed by "-"
  26 x          \ divide result of last mod by 26 and output ascii char
  1 x           \ output ascii char for remaining amount
;               \ end word definition
  
```
[Answer]
# [q](https://code.kx.com/v2/ref), 78 bytes
```
{sv["-","0"^-4$($:[x mod 1000]),"-"]2 2#(|).Q.A mod[x div 1000*26 xexp(!)4]26}
```
---
```
                                                    x div 1000*26 xexp(!)4     / input (floor) divided by 1000*26 ^ 0 1 2 3
                                                mod[                      ]26  / mod 26
                                           .Q.a                                / alphabet uppercase, indexed into by preceeding lines, for x=1000, we'd get "BAAA"
                                    2 2#(|)                                    / reverse and cut into 2x2 matrix ("AA";"AB")
               ($:[x mod 1000]),"-"                                            / string cast x mod 1000 and append "-"
            -4$                                                                / left pad to length 4, "  0-"
    "-","0"^                                                                   / fill nulls (" ") with "0" and prepend "-"
 sv[              x                ]y                                          / join elems of y by x
```
[Answer]
# T-SQL, 135 bytes
```
select concat(CHAR(65+(@i/17576000)),CHAR(65+(@i/676000)%26),'-',right(1e3+@i%1000,3),'-',CHAR(65+(@i/26000)%26),CHAR(65+(@i/1000)%26))
```
[Answer]
# [Julia 1.0](http://julialang.org/), 86 bytes
```
i->(join('A'.+digits(i÷1000,base=26,pad=4))string(i%1000,pad=3)*'-')[[4;3;8;5:8;2;1]]
```
[Try it online!](https://tio.run/##yyrNyUw0rPifZvs/U9dOIys/M09D3VFdTzslMz2zpFgj8/B2QwMDA52kxOJUWyMznYLEFFsTTc3ikqLMvHSNTFWwJEjQWFNLXVddMzraxNrY2sLa1MrC2sjaMDb2v0NxRn65QpqGgSYXjGmIYFpaWiKJAw1D8MzMTeNRpM3MzeJRVJiYmsVbQlX9BwA "Julia 1.0 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 88 bytes
```
lambda n:g(n/676000)+'-%03d-'%(n%1000)+g(n/1000)
g=lambda n:chr(65+n/26%26)+chr(65+n%26)
```
[Try it online!](https://tio.run/##PY3NDoIwEITvPMVempawhIJ2SUnqi6gHlPCT4EIaLj59hRqdy843m91Z39u4cBV6dwtz@3p0LXAzKC6oJq11mslc6FOXS6FYlDE5ttElg/ufPEevyGRcVCQqSrMfHxD6xQPDxHDVCCWCtXaf@wsEqk2kbx3C2ZCN0b1JYNfqJ96AUbqLxF5xGj4 "Python 2 – Try It Online")
[Answer]
# [Red](http://www.red-lang.org), ~~130~~ 127 bytes
```
func[n][g: func[a b c][t: copy""loop a[insert t b +(n % c)n: n / c]t]a: g 3 #"0"10
s: g 4 #"A"26 rejoin[s/1 s/2"-"a"-"s/3 s/4]]
```
[Try it online!](https://tio.run/##VYrLCsIwFAX3/YpDRKqIJK1tSrPzF9yGLGr6oCJJSeLCr69R0eriwsw947p2PnUtpEp6Mfc3o6VRchB4YYMztJJBQNvpTsjV2gmNHI3vXECI625jsIbeGgEDGuOgGoEBB6wIIxlL/NOKaEeSc7juYkcjPc3gaU72pInn6SFaodQ8udEE9GDJh7Iv1XW9fFPGloZXZfq78or/7UXJ0/rdzA8 "Red – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 89 bytes
```
lambda n:h(n//676)+f"-{n%1000:03}-"+h(n)
h=lambda x:'%c%c'%(x//26000%26+65,x//1000%26+65)
```
[Try it online!](https://tio.run/##PY5BCoMwEEX3nmIIBBOMJGqNJGBP0o21BAU7iriwiGdPBymdzefNPPizfLZhxiqG9hGn7v18dYB@EKi1bazMAssP5IUxxpvqzFlGJ5kM7U/dfcp73qdc7FqXljRe2szWirD4k4xhXgFhRBBGQaHAOUdJggLb1BdR3cW32rprJX0CNMs64iYCO9C7E/I7HIFeOJmMXw "Python 3 – Try It Online")
*-1 byte thanks to mypetlion*
[Answer]
# [MATLAB](https://github.com/ETHproductions/japt), 113 bytes
```
c=@(x,p)char(mod(idivide(x,1000*26^p),26)+65);
s=@(n)[c(n,3),c(n,2),num2str(mod(n,1000),'-%03d-'),c(n,1),c(n,0)]
```
---
Explanations:
The first line define a function which will produce a char (from `A` to `Z`), function of 2 inputs. The index number `x` to convert into a plate number, and an integer `p` which will be used as an exponent for 26 (i.e. `26^p`). This second input allow to adjust the calculations for the first alphanumeric plate digit (`p=3`) down to the last one (`p=0`).
For example, for the second digit, cycled every 1000\*26\*26 iterations, the operation: `mod(idivide(x,1000*26^2),26)` return an index between 0 and 25, which is then converted to an ASCII `char` by adding 65 (because the index are `0` based)
The second line simply concatenate characters together. Each alphanumeric character is calculated with the use of the function `c(x,p)`, the numeric character are simply calculated with a `modulo` operation and converted to string.
Each component of the string composing the plate number is as follow:
```
digit #     |    how often is it cycled             |  code
----------------------------------------------------------------
digit 1     | cycle every 1000*26*26*26=1000*26^3   | c(n,3) 
digit 2     | cycle every 1000*26*26   =1000*26^2   | c(n,2) 
digit 3,4,5 | cycle every iteration                 | num2str(mod(n,1000),'-%03d-')
digit 6     | cycle every 1000*26      =1000*26^1   | c(n,1) 
digit 7     | cycle every 1000         =1000*26^0   | c(n,0) 
```
---
Since I can't let you try MATLAB online (*edit:* actually you can [try it online](http://ideone.com/R31AkI) ), I'll let MATLAB users the possibility to verify the test cases:
```
% chose some test cases
n = uint32([0;1;999;1000;675999;676000;456975999]) ;
% work out their plate numbers
plates = s(n) ;
% display results
fprintf('\n%10s | Plate # \n','Index')
for k=1:numel(n)
    fprintf('%10d : %s\n',n(k),plates(k,:))
end
```
outputs:
```
     Index | Plate # 
         0 : AA-000-AA
         1 : AA-001-AA
       999 : AA-999-AA
      1000 : AA-000-AB
    675999 : AA-999-ZZ
    676000 : AB-000-AA
 456975999 : ZZ-999-ZZ
```
---
**Variant:**
Note that the option to let `sprintf` or `fprintf` take care of the number to character conversion is possible. It allow to simplify the function `c`, but overall result in a few more bytes in this implementation (119 bytes):
```
c=@(x,p)mod(idivide(x,1000*26^p),26)+65 ;
s=@(n)sprintf('%c%c-%03d-%c%c\n',[c(n,3),c(n,2),mod(n,1000),c(n,1),c(n,0)]')
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~136~~ ~~106~~ 105 bytes
```
#define P(i)s[i]=65+x%26;x/=26;
z;s[]=L"  -%03d-  ";f(x){z=x%1000;x/=1e3;P(9)P(8)P(1)P(0)wprintf(s,z);}
```
[Try it online!](https://tio.run/##TY3RCoIwFIav8ykOhrBR0pY5G2Nv0IX35kWoi120IqOG4rOvCSU78B/Ox3fgb9Jr0zi3bjulTQcl0rivdC1ZvrHJngm7k35Hg@irWp5igDQhWZsCnE0sFLJ4HKRNKCFkfqVdJkrEcYmOPtSH4M/jqc1LoX47YDE5f8Ptog1633WLYYxWCsFvCBYh0hA55wHOhQuyIg8tK9hiDznjfzu5Lw "C (gcc) – Try It Online")
-7 bytes from [celingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)'s [solution](https://tio.run/##bY7NCoJAFEbX@RQXQ5ipkcbMseEy7@BeWvhbs8jCsRiMnt0yIgL9VofDWXyFfyyKYViWVa2bChKSMc1yalJ9UNnaejnajcrR6bE4ZS2Y9KBcAN/jYekDuFgTSx@9sl7AOR/boAoxISJikm0F/dD@R8FIK6NEtLZ4bXXT1cSwnuJzeDOcM92Q@0WXFB7OoibwHad4vXWGuC7Ffx/MeinlnB8PTr2Io9lexGLa7yIhJ/1zeAE), with additional -23 inspired by it
-1 byte from ceilingcat's [solution](https://tio.run/##TY3RCoIwFIav8ykOhrBR0pY5G2Nv0IX35kWoi120IqOG4rOvCSU78B/Ox3fgb9Jr0zi3bjulTQcl0rivdC1ZvrHJngm7k35Hg@irWp5igDQhWZsCnE0sFLJ4HKRNKCFkfqVdJkrEcYmOPtSH4M/jqc1LoX47YDE5f8Ptog1633WLYYxWCsFvCBYh0hA55wHOhQuyIg8tK9hiDznjfzu5Lw) by changing the `char[]` to a `wchar_t[]` implicitly cast to `int[]`
Uses 0-based indexing.
Explanation/Ungolfed:
```
int s[] = L"  -%03d-  "; // Pre-made wide-string with dashes and ending null byte
                         // and wprintf directive for digits
int z;                   // Temporary variable to store the digit part
void f(int x) {
    z = x % 1000;        // The digits represent x % 1000
    x /= 1000;           
    s[9] = 'A' + x % 26; // Place least significant letter
    x /= 26;             // Divide off least significant letter
    s[8] = 'A' + x % 26; // Place second letter
    x /= 26;             // Divide off second letter
    s[1] = 'A' + x % 26; // Place third letter
    x /= 26;             // Divide off third letter
    s[0] = 'A' + x;      // Place fourth letter (Don't need to % 26 because x < 26 now)
    wprintf(s, z); // Print finished string (with x%1000 replacing %03d)
}
```
[Answer]
# [Kotlin](https://kotlinlang.org), 93 bytes
```
{i:Int->val c={v:Int->'A'+i/v/1000%26}
""+c(17576)+c(676)+"-%03d-".format(i%1000)+c(26)+c(1)}
```
[Try it online!](https://tio.run/##lVfbbhs3EH3XV9BCgkjJ6mYnNuzWAeQkLQIkcIEEKOo3apcrEV6RG5IrRTX87e4ZXnbXcYqiQR7E5XA4c@bMHPpWu0qqh9mMfVR14y6Y0m4j1ZqV2rBClLypHHPCOpZzKyzTZgBbrphUTqyFYSvh9kIo9rcwGt8L9vrNaXZ@9iY7Pz@fDsj4nRHcicJ7hG/Lcl0IttZVyfINryqh1uKCDDfO1fZiNqN92p5ax/Nb8R1WMJnmejv7Nlucn7w@OSbz34xQ@YZ9krlQVrA/KtxiB72dKu7UfgfXbgXCZpxZ8a0RyklekbU2hTAZwqsqvafUYVCLXJYyZzV3ThjFdEmWqtmuhLE@zUrQjmUXbHk1mS@OJ@/eh2xTSn71p5FOwGFt9NrwLe5iZaNyJ7UCFtxlHhVOpmu5A4zhiozpxqEcFkYCgRsjbK1VgejItPxJfvHklP2lG5PuI2O70U1VUF0ZcCwqhKMOIUNe@aoybr1hSBqVksrfC2LcYlVzgM8@uuRpJTwFVvDkNFsLJQzdTyfKpqrY8elL/F/M5/OX/idZX74lXrDzs1OG76zW1kpyEEqTES7cspIHdll2oCQqlL3B5QhSMdvUtTYuUOrrJuVL9bIH68QWjEKRyYsvpPWUWi4nuG@yXFKoWICUtBilSoqdrnY@H8ZKaawb/9I/dtU/dsNGyDFCw60LpwIPmA7fjVxvHvu46l990/fh7/svJ1f9@G@eOvm3QCpRRhdXfQhubv5HHN5HANwPhxb6PuFeWNClEN8J@W4seNNrz@H21CMa/5TDXY/5Q8uikNQpoKlU6JMtp5Xf@hS7b8N3noUrwcAPYYjO3gBd4GnTwPcKI43NJyvsFb53F@E32fnYKZ4fqRyHxmgruIpt15GJPHfp0Nk5GLzIAntts/VjBL1AnnA7MO3NUIoJ33zPcT@TQgyJ2xiRcUpOaAxm1HjGn@fK7uEL/Sl2whzIvG0SjC57FDx0V41S2umOcSh0@jdnk7ddXo/3Fu3e4oc9UCjuhX7q7VHb931epb3TIAm9czc33d5pls5d9WLpSQntdeT1aX74XqOYJCxpou4lCo0xv8Vwt1QVjMFcWD/dWqlhqBpEzU7Ze5FX3NA8ZI1SqEQRAN2uCkiAZvsweRTBSfNIKvCjvS3oYAET1Fk6uo7vtCxCCwvXQDa2/DZypxO@vNKW@ADz3DXgNl3IwWAMrekA3lPUI1@zC/SeG7NLdjcYEFYkb62C/MDZqEnJrjR66797R1P2u3B@aUU4DlGLlq1RT6Q33CBARIokkx0vipiq1yVek4ay5ZR9oT60IKVKpqsDtc/qwGpogm8wnFgc@3cCvSMwGKKlLqO3qgrSiqHh0okSqpgM0Ua@2Qu5kwASvoltU79NuLUhj3a8akRCbpC4@WL54pXPcub3Z3T6OfQp@f/Mb0mrrSNVyRgEdNUNSOb2OhlGnDMaEnmAfisLktY4vaId8RG9StwpuN2Q0FF@yXFbJ0kjDv6T45DScPiqy2hx9ubsdNz7cErLNrXh5Pn8pJgMp2FMBuo8pwR7Rt3h40euFmN2PxqHl1OPWoW0yO/gw3/aPZ6p0WREwynC7WlKEzq0EfzkWmFYpRYikgX@BLufvdXAJ5EeFLHZAv1WGjQjiqYmJ6RQTFb7MsPk/CQw7@FOXiCeyVvazS/vdmHlKTDbpdLfDwjkFtwA6hMsI455gA1w3T/4u973APKJZW2ubZOEqHxWofgJVeko9hpUc5UaDZ/5@X7Jnt3VHs3x/XA8uKez8YAvz2cOOrXjLn/ysE5VCtXZwnrEzdrijWoMP/z6xTP7bVekr@aAgvIidRuUKQi6F/Epe8dJq3iEHy9xUYfJAQFCLujcUlZITOlW@ektF8zR4mRB6MTHG2I1/inPrkkT99KKLAIURl5ExSGsO09bql5EhuL8JJUYjY@Opk6jnOAs2ciSecjYEcCZT6dQDYgGlGIcme82Ru/ZR0Cz5tXSrBuizoeUzGjQSd7wipNUYgAdDcPpPsPHEbVr1UFBJd/Cgv6uoNEV80DSwbaT/YtOZ7NOOmP@rSQGkrRKR2jc47xDi4yEMdpc4IGAdOj5PY4gtSRqo0chqaTx7zebkiGiBKgQbiWtuy5H8wzvFlL0zE/TrEXj1GOYkTjTd9bBmnB9jA0FSgnjWeJ/EPse/gE "Kotlin – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 161 bytes
```
i,t,u,v,a,c,f=int(input()),1000,676,26,ord('A'),chr,lambda x:c(a+x//v)+c(a+x%v)
m,n=i%t,i//t
e,o=n%u,n//u
print('-'.join([f(o),(3-len(str(m)))*'0'+str(m),f(e)]))
```
[Try it online!](https://tio.run/##JcxLDoIwFEbhOatwQnqv/NgqAsGEgeswDpBHqIGW1EJw9Rh1dr7Jmd6@tybZNg2PGQsq1OhKbTxpM82emHFUSiHLM5wyWNeQuApG3TsM1fhoqt16qamKVikXjn4VLhyMMKUOPbSUPmhhSxPOMFLOweS@dxGLw9NqQ7eOLIOSeGgNvbyjkZn3QonoD3TU8p15285pVuRpUagP "Python 3 – Try It Online")
]