[Question]
  [
You have locked your bike with a combination lock of 3 digits. Now you want to go for a ride and need to unlock it with the help of following program.
## Input
### 1st parameter
The digit combination of your lock in *locked* state. It must be different from the 2nd parameter (=the combination of *unlocked* state). (Or else your bike could be stolen!)
Range 000..999. Leading zeros must not be omitted.
### 2nd parameter
The digit combination of your lock in *unlocked* state. This value is your goal.
Range 000..999. Leading zeros must not be omitted.
## Output
A list of each state of the combination lock after each "rotation" including the initial state (which is always the 1st parameter) and the last step (which is always the 2nd paramater).
## Algorithm
You start "rotating" the first digit one by one until you reach the correct digit in *unlocked* state. But, because you are in knowledge of the whole unlock-code, **you rotate the digit in the direction in which you need the smallest amount of rotations to reach the digit in *unlocked* state**. In case of a tie you can choose whatever direction you prefer.
When you have reached the correct first digit, you start the same procedure with the 2nd and then with the 3rd.
The order of digits is to understand as a circle:
`... 9 0 1 2 3 4 5 6 7 8 9 0 1 2 ...`
This means, that the smallest amount of rotations from 1 to 9 is not 
`1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9` = 8
but 
`1 -> 0 -> 9` = 2.
## Notes
* You can rely on [Default I/O rules](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods)
* You can change the order of the parameters.
## Examples
### Example 1, correct
```
Input: 999 001
Output:
999
099
009
000
001
```
### Example 2, correct
```
Input: 000 292
Output:
000
100
200
290
291
292
```
### Example 3, wrong output
```
Input: 999 121
Wrong output:
999
899 // Wrong because wrong rotation direction.
799
699
...
Correct output:
999
099
199
109
119
129
120
121
```
### Example 4, wrong input
```
Input: 1 212 // Wrong because no leading zeros.
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") the shortest answer wins.
  
[Answer]
# [Python 2](https://docs.python.org/2/), ~~113~~ ~~107~~ ~~105~~ ~~99~~ 95 bytes
```
a,b=input()
i=0
print a
for x in a:
 while x-b[i]:a[i]=x=(x+(x-b[i])%10/5*2-1)%10;print a
 i+=1
```
[Try it online!](https://tio.run/##NY3NCoMwEITv@xSLUPBnpUnEQy15EvEQbYoLJRGxNH36NCplYdhvBmaW7zZ7p@LkH1ZnWRYNjZrd8t7yAlgLWFZ2Gxp4@hUDskPTAX5mflkM9djz0JkkOug8VPnpFBcprm2parl/938DcqVlPAjSEoANdsJ9GEtsYn@jdAP1ggTJARJLahMrakgdfOaSVMp/ "Python 2 – Try It Online")
Takes input as lists of integers
---
Saved:
* -6 bytes, thanks to Joel
* -4 bytes, thanks to Jitse
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 15 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
_æ%5ḣT$ṂṠ⁸_%⁵ðƬ
```
A dyadic Link accepting the start-code on the left and the target-code on the right as lists of integers (in \$[0,9]\$, lengths equal but otherwise arbitrary) which yields a list of lists of the codes from start-code to target-code.
**[Try it online!](https://tio.run/##ATUAyv9qZWxsef//X8OmJTXhuKNUJOG5guG5oOKBuF8l4oG1w7DGrP///1s5LDEsMV3/WzIsMywyXQ "Jelly – Try It Online")**
### How?
```
_æ%5ḣT$ṂṠ⁸_%⁵ðƬ - Link: list of integers, s; list of integers, t
              Ƭ - collect up values until a fixed point is reached applying:
             ð  -   the dyadic chain:  (i.e. f(x, t) where x starts off as s)
_               -     subtract (t from x) (vectorises) - i.e. [ta-xa, tb-xb, tc-xc]
   5            -     literal five
 æ%             -     symmetric modulo (vectorises) - i.e. [[-4..5][ta-xa], [-4..5][tb-xb], [-4..5][tc-xc]]
      $         -     last two links as a monad:
     T          -       truthy indices  - e.g. [0,-4,1]->[2,3]
    ḣ           -       head to index (vectorises)       [[0,-4],[0,-4,1]]
       Ṃ        -     minimum                            [0,-4]
        Ṡ       -     sign (vectorises)                  [0,-1]
         ⁸      -     chain's left argument (x)
          _     -     subtract (vectorises) - i.e. move the single spindle one in the chosen direction
            ⁵   -     literal ten
           %    -     modulo (since 9+1=10 not 0)
```
[Answer]
# JavaScript (ES6), ~~73 72~~ 70 bytes
*Saved 2 bytes thanks to @tsh*
Takes input as 2 arrays of digits in curried syntax `(a)(b)`. Returns a string.
```
a=>g=b=>b.some(x=>d=x-(a[++i]%=10),i=-1)?a+`
`+g(b,a[i]+=d/5<5/d||9):b
```
[Try it online!](https://tio.run/##fYzLDoIwEEX3fgUbQycdHsWwwDj4IbUJLQVSg9SIMSz49yqJOxNzlvfcc9UvPbcPd38mk7dd6CloqgcyVJt09reOLVRbWhKmJedO7UnkgI4SAWfNm13DB2ZQS6c42aw8lZld1wqOJrR@mv3YpaMfWM9khR8UMJljjkJBxKP4MsWw@/HENjNZ4AGLf963J7DYDhDe "JavaScript (Node.js) – Try It Online")
### Commented
```
a =>                  // a[] = initial combination
g = b =>              // b[] = target combination
  b.some(x =>         // for each digit x in b[]:
    d =               //   compute the difference d:
      x -             //     between x
      (a[++i] %= 10), //     and the corresponding digit in a[]
                      //     we apply a mod 10, because it may have exceed 9
                      //     during the previous iteration
    i = -1            //   start with i = -1
  ) ?                 // end of some(); if it's truthy:
    a + `\n` +        //   append a[] followed by a line feed
    g(                //   followed by the result of a recursive call:
      b,              //     pass b[] unchanged
      a[i] +=         //     add either 1 or 9 to a[i]:
        d / 5 < 5 / d //       add 1 if d / 5 < 5 / d
        || 9          //       otherwise, add 9
    )                 //   end of recursive call
  :                   // else:
    b                 //   stop recursion and return b[]
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 25 bytes
```
_æ%5+⁹⁹rḊ€%⁵J;Ɱ"$ẎṄḢ}⁺¦¥ƒ
```
[Try it online!](https://tio.run/##AU4Asf9qZWxsef//X8OmJTUr4oG54oG5cuG4iuKCrCXigbVKO@KxriIk4bqO4bmE4biifeKBusKmwqXGkv///1s3LCAyLCAxXf9bMywgNCwgOV0 "Jelly – Try It Online")
Full program.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~101~~ 97 bytes
```
a,c=input()
print a
for i in 0,1,2:
 while a[i]!=c[i]:a[i]=(a[i]+(a[i]-c[i])%10/5*2-1)%10;print a
```
[Try it online!](https://tio.run/##VY9Bi8IwEIXPzq8YEWmrI9tEerDSo169eAs5dGPEoLQlRNRfXyetLiyBx2Tel5eZ7hUubSN7055slSRJX5OpXNPdQ5pB510TsIZz69GhazAnQbIEfFzczWKtnJ5WhrWMZZVGXQ66it1sLvKfYiFXIlbbT1rPvwDAGHH0d1vCJPgX68Q@rcE4CdcDDdwytgu4O@x33rc@Ur/e1leA2TlVggpaa1Ib4qMzmI2vorXhUYUmVJLWJHXWfyBSOfEaGgai4PsIwJ/PKw7@/3D4Jn75Nw "Python 2 – Try It Online")
3 bytes thx to [Joel](https://codegolf.stackexchange.com/users/88506/joel).
Takes input as lists of ints.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 30 bytes
```
_ż+¥⁵AÞḢṠxAƊ×€ʋ"JṬ€$$Ẏ;@W}+\%⁵
```
[Try it online!](https://tio.run/##y0rNyan8/z/@6B7tQ0sfNW51PDzv4Y5FD3cuqHA81nV4@qOmNae6lbwe7lwDZKmoPNzVZ@0QXqsdowpU@v//f0MdIx3j/yY6pjqWAA "Jelly – Try It Online")
A dyadic link taking as its left argument the unlock code and its right the current locked state, both as lists of integers.
This feels far too long!
[Answer]
# [PHP](https://php.net/), 114 bytes
```
for([,$a,$b]=$argv;$i<3;($x=$a[$i]-$b[$i])?(print$a._).$a[$i]=($y=$a[$i]+(5/$x>$x/5?-1:1))<0?9:$y%10:++$i);echo$b;
```
[Try it online!](https://tio.run/##LYpbCsIwFEQ3M0JC@rpKP/Jos5BSJBG1@bEhSElXHyv6M4fDmbjEYmw89rEmNlVwFfw8wKXnphHMRTPkQyeEuYb/glsWU3i94Zorb35pYNj/L8H6FnlEbntbkyLOTWelwn6iTgmBwPX9tqzwupQipSx0pg8 "PHP – Try It Online")
My solution probably sucks, but that is the best I can think of for now!
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 48 bytes
```
θ≔ＥθＩιθＦ³«≔⁻﹪⁺⁻Ｉ§ηι§θι⁵χ⁵ζＦ↔ζ«§≔θι﹪⁺§θι÷ζ↔ζχ⸿⪫θω
```
[Try it online!](https://tio.run/##VY9BC4IwFMfP@imGpzdYkEUH6SR1MRD8AF2WWg3Glm5aGH72NafCOjx4/733fj9WPmlbSsqNKVomNDT4GKZKsYeAnL6gIehElQaGMUHT7C5bBHuMvmGwrjHRKchl1XEJBZ969@LuUp2Jqv7AkyCHWHOz5IOteLs0g@UHTpDelOSdrmHATrW4/GuCfOUfl6BM6DPrWWUB1unBZt3kCeb/Rtc28uJFMjFB3m5nDEdjkiRB8S42m57/AA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
θ
```
Print the initial position.
```
≔ＥθＩιθ
```
Change the initial position string into an array of numeric digits for calculation purposes.
```
Ｆ³«
```
Loop over each digit in turn.
```
≔⁻﹪⁺⁻Ｉ§ηι§θι⁵χ⁵ζ
```
Calculate the number of rotations needed to unlock that digit. This is a number from `-5` to `4` where `-5` means 5 downward rotations and `4` means 4 upward rotations.
```
Ｆ↔ζ«
```
Loop over each rotation.
```
§≔θι﹪⁺§θι÷ζ↔ζχ
```
Update the digit according to the sign of the rotation.
```
⸿⪫θω
```
Output the digits as a string on a new line.
[Answer]
# T-SQL 2008, 170 bytes
I added some linebreaks to make it readable
```
DECLARE @1 char(3)='123',@2 char(3)='956'
DECLARE @r int,@s int,@ int=0
g:SET @+=1
h:SELECT @r=substring(@1,@,1)+9,@s=@r-substring(@2+'1',@,1)
IF @s=9GOTO g
PRINT @1
SET @1=stuff(@1,@,1,(@r+@s/5%2*2)%10)
IF @<4GOTO h
```
**[Try it online](https://data.stackexchange.com/stackoverflow/query/1097687/unlock-your-lock)**
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 101 bytes
```
a=>b=>{for(int i=0;i<3;i++)for(;a[i]!=b[i];a[i]+=(a[i]-b[i]+10)%10<5?9:1,a[i]%=10)Print(a);Print(a);}
```
[Try it online!](https://tio.run/##RYyxCoMwEIZ3n6IdhISckCgd2ngpXTp16NZBHDQo3BJBLR3EZ0@TVloO7u777ufslNmJ/PXpbElurmq42JkG9wVjevQNmhbN0g8jC3JHKDWVhSYheHS6qajeYxv6ZxXI4siiEEryVMnycD6eFESdYlD3MTxiDde/ZfU6SXrmuldVL0cItfKNJEhQK9fJY6S5u5HrWIB/VsXrRjkUkIesfwM "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [J](http://jsoftware.com/), 36 bytes
```
10|[+/\@,#:@4 2 1#~[:>&|/`]}10|-,:-~
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/DQ1qorX1Yxx0lK0cTBSMFAyV66Kt7NRq9BNia4FyujpWunX/Nbm4UpMz8hUswTANqN1AwRAipK4OkzIEQqCckYKxghG6HESbIcj8/wA "J – Try It Online")
Will add explanation tomorrow.
[Answer]
# MATLAB, ~~100~~ 89 bytes
A different approach (using implicit expansion to create a subtraction matrix) reduces 11 bytes:
```
function f(a,b);c = mod(a-b+5,10)-5;a,mod(a-cumsum(repelem(eye(3).*sign(c),abs(c),1)),10)
```
[Original 100 byte solution]
```
function f(a,b);c=mod(a-b+5,10)-5;a,for n=1:3;for r=1:abs(c(n));a(n)=mod(a(n)-sign(c(n)),10),end;end
```
Both called by passing the inputs as 3-element arrays, e.g. `f([9 1 1], [2 3 2])`
[Answer]
# [Java (JDK)](http://jdk.java.net/), 139 bytes
```
a->b->{for(int i;;a[i]+=(a[i]-b[i]+10)%10<5?9:1,a[i]%=10){System.out.println(""+a[i=0]+a[1]+a[2]);for(;i<3&&a[i]==b[i];i++);if(i>2)break;}}
```
[Try it online!](https://tio.run/##fVBNi4MwFLz3VzwKLbrGYCxlaVPdw8Le9tSjeIhWS6xfmFgokt/uJir7xbIk5jnzJpNJCnZnbnG5jbxqm05CoTHuJS9x3tep5E2Nn@gqLZkQ8M54DcMKoO2TkqcgJJO63Bt@gUr3rLPseH2NYmDdVdiTFOBt8TnxWkYxem1q0VdZN8MwhByCkblh4oZD3nSWpoFTyiIeO4FlipuYf@LZG@Kd9i@HI0GG3gSaGs4PIbMKN73ErT5clrW1Xju6H3ixLsQsfmxTY035abfdmr1BYDwpdxyb8tzioW8nXcZuVKmRTqmndGaAzIQUECy3ARj0OKBpgkIaeMhMAkrDb5qZ9maNP23wf2t@@BBkZP/77BE8I9h9adQcV18PrCXzlPg457Y/Y@eYtW35sAwdebGNWZpmrZwx0S@06P540KWnVuZT4wc "Java (JDK) – Try It Online")
Same algorithm as everyone, rolled differently because Java's `System.out.println` is pretty expensive!
[Answer]
# [C (clang)](http://clang.llvm.org/), 125 bytes
```
t,*d;f(*a,*b){for(t=d=a;t?printf("%d%d%d\n",*a,a[1],a[2]):d++,t=*d-b[d-a],d-a<3;*d=(*d+=!~*d*10)%10)t?*d+=(t+10)/5&1?1:-1:0;}
```
[Try it online!](https://tio.run/##HY3hCoIwFIX/@xQmGNuctBVJuIYPYvsxuxlCrZAFitirr7vu4R7O/bhwruX1Yd09BM8ZqJ4wy1lHl/41Eq9BW@Wb9zg435Msh6iLyzg@2VYatL2hNRQF95pB2bVQWsPRzgfFQBMGhd58GTApaI7rm0iILzDvjlvZyLqUtVBrwIb0aQdHaLokSbym1uhF8IqfVvUHcwQVggpBTyY@U5WkOOPNf0aXCpWs4Qc "C (clang) – Try It Online")
[Answer]
# [Kotlin](https://kotlinlang.org), 162 bytes
```
{s:Array<Int>,e:Array<Int>->var i=0
o@while(i<3){println(""+s[0]+s[1]+s[2])
while(s[i]==e[i]){if(i>1)break@o
i++}
s[i]=(s[i]+if((e[i]-s[i]+10)%10>5)9 else 1)%10}}
```
[Try it online!](https://tio.run/##pVhtbxs3Ev7uXzEWeogEy2utHCeWERtJ0wYwkNaHNofgEPgDpaWkPa@WKsmN7Lr@7blnhuRqZbsFridY613yITmvz8zqxviqrL8dHdFlvW78GdXGL8t6QXNjyS81FXqumsqT187TTDnt9gDmyY2hsvZ6oa0jt9azcl7qgjalX2Kh1ZpxRbkovaOp9hutaxqNRqTq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