Unlock your LockCombination bike lockGolf String's format() inverseCrack the code to the combination lockFinding the DeadlockIT'S CAPS LOCK DAYCombination lock counterCombination bike lockZipper multiplicationRoom Number LocatorThe weight of a Zero

Handling Disruptive Student on the Autism Spectrum

Duplicate instruments in unison in an orchestra

What is Spectral Subtraction for noise reduction?

Was the Boeing 2707 design flawed?

Can Orcus use Multiattack with any melee weapon?

When, exactly, does the Rogue Scout get to use their Skirmisher ability?

Is the negative potential of 書く used in this sentence and what is its meaning?

What stops you from using fixed income in developing countries?

What to look for in a spotting scope?

Changing JPEG to RAW to use on Lightroom?

Why is proof-of-work required in Bitcoin?

Breaker Mapping Questions

If the Shillelagh cantrip is applied to a club with non-standard damage dice, what is the resulting damage dice?

Why is "-ber" the suffix of the last four months of the year?

To what extent are we obligated to continue to procreate beyond having two kids?

Cooking Scrambled Eggs

LINQ for generating all possible permutations

How does the OS tell whether an "Address is already in use"?

How much does Commander Data weigh?

Is it legal for source code containing undefined behavior to crash the compiler?

"There were either twelve sexes or none."

How were medieval castles built in swamps or marshes without draining them?

How many lines of code does the original TeX contain?

Can you board the plane when your passport is valid less than 3 months?



Unlock your Lock


Combination bike lockGolf String's format() inverseCrack the code to the combination lockFinding the DeadlockIT'S CAPS LOCK DAYCombination lock counterCombination bike lockZipper multiplicationRoom Number LocatorThe weight of a Zero






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








12












$begingroup$


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

  • 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: 911 232

Output:
911
011
111
211
221
231
232


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 the shortest answer wins.










share|improve this question









New contributor



user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$













  • $begingroup$
    May I change the order of two parameters?
    $endgroup$
    – tsh
    8 hours ago










  • $begingroup$
    May we update the digits in any order as long as it's optimal?
    $endgroup$
    – Arnauld
    7 hours ago










  • $begingroup$
    @Arnauld No because I unlock my lock one by one :)
    $endgroup$
    – user2190035
    7 hours ago







  • 2




    $begingroup$
    Related
    $endgroup$
    – Luis Mendo
    4 hours ago






  • 2




    $begingroup$
    I'm not sure it's a good idea to put the (essentially useless) picture of a 4-digit lock from the other challenge on this 3-digit challenge. ¯_(ツ)_/¯
    $endgroup$
    – Arnauld
    1 hour ago


















12












$begingroup$


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

  • 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: 911 232

Output:
911
011
111
211
221
231
232


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 the shortest answer wins.










share|improve this question









New contributor



user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$













  • $begingroup$
    May I change the order of two parameters?
    $endgroup$
    – tsh
    8 hours ago










  • $begingroup$
    May we update the digits in any order as long as it's optimal?
    $endgroup$
    – Arnauld
    7 hours ago










  • $begingroup$
    @Arnauld No because I unlock my lock one by one :)
    $endgroup$
    – user2190035
    7 hours ago







  • 2




    $begingroup$
    Related
    $endgroup$
    – Luis Mendo
    4 hours ago






  • 2




    $begingroup$
    I'm not sure it's a good idea to put the (essentially useless) picture of a 4-digit lock from the other challenge on this 3-digit challenge. ¯_(ツ)_/¯
    $endgroup$
    – Arnauld
    1 hour ago














12












12








12


1



$begingroup$


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

  • 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: 911 232

Output:
911
011
111
211
221
231
232


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 the shortest answer wins.










share|improve this question









New contributor



user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$




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

  • 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: 911 232

Output:
911
011
111
211
221
231
232


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 the shortest answer wins.







code-golf path-finding






share|improve this question









New contributor



user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 24 mins ago







user2190035













New contributor



user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 8 hours ago









user2190035user2190035

1614 bronze badges




1614 bronze badges




New contributor



user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




user2190035 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • $begingroup$
    May I change the order of two parameters?
    $endgroup$
    – tsh
    8 hours ago










  • $begingroup$
    May we update the digits in any order as long as it's optimal?
    $endgroup$
    – Arnauld
    7 hours ago










  • $begingroup$
    @Arnauld No because I unlock my lock one by one :)
    $endgroup$
    – user2190035
    7 hours ago







  • 2




    $begingroup$
    Related
    $endgroup$
    – Luis Mendo
    4 hours ago






  • 2




    $begingroup$
    I'm not sure it's a good idea to put the (essentially useless) picture of a 4-digit lock from the other challenge on this 3-digit challenge. ¯_(ツ)_/¯
    $endgroup$
    – Arnauld
    1 hour ago

















  • $begingroup$
    May I change the order of two parameters?
    $endgroup$
    – tsh
    8 hours ago










  • $begingroup$
    May we update the digits in any order as long as it's optimal?
    $endgroup$
    – Arnauld
    7 hours ago










  • $begingroup$
    @Arnauld No because I unlock my lock one by one :)
    $endgroup$
    – user2190035
    7 hours ago







  • 2




    $begingroup$
    Related
    $endgroup$
    – Luis Mendo
    4 hours ago






  • 2




    $begingroup$
    I'm not sure it's a good idea to put the (essentially useless) picture of a 4-digit lock from the other challenge on this 3-digit challenge. ¯_(ツ)_/¯
    $endgroup$
    – Arnauld
    1 hour ago
















$begingroup$
May I change the order of two parameters?
$endgroup$
– tsh
8 hours ago




$begingroup$
May I change the order of two parameters?
$endgroup$
– tsh
8 hours ago












$begingroup$
May we update the digits in any order as long as it's optimal?
$endgroup$
– Arnauld
7 hours ago




$begingroup$
May we update the digits in any order as long as it's optimal?
$endgroup$
– Arnauld
7 hours ago












$begingroup$
@Arnauld No because I unlock my lock one by one :)
$endgroup$
– user2190035
7 hours ago





$begingroup$
@Arnauld No because I unlock my lock one by one :)
$endgroup$
– user2190035
7 hours ago





2




2




$begingroup$
Related
$endgroup$
– Luis Mendo
4 hours ago




$begingroup$
Related
$endgroup$
– Luis Mendo
4 hours ago




2




2




$begingroup$
I'm not sure it's a good idea to put the (essentially useless) picture of a 4-digit lock from the other challenge on this 3-digit challenge. ¯_(ツ)_/¯
$endgroup$
– Arnauld
1 hour ago





$begingroup$
I'm not sure it's a good idea to put the (essentially useless) picture of a 4-digit lock from the other challenge on this 3-digit challenge. ¯_(ツ)_/¯
$endgroup$
– Arnauld
1 hour ago











7 Answers
7






active

oldest

votes


















2













$begingroup$


Python 2, 113 107 bytes





a,b=input()
print a
for x,y,i in zip(a,b,(0,1,2)):
while x-y:a[i]=x=(x+1-2*((y-x)%10>(x-y)%10))%10;print a


Try it online!



Takes input as lists of integers






share|improve this answer









$endgroup$






















    1













    $begingroup$

    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!



    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[]





    share|improve this answer











    $endgroup$














    • $begingroup$
      d/6&1^d>0||9 -> d/5>5/d?9:1
      $endgroup$
      – tsh
      7 hours ago


















    0













    $begingroup$


    Jelly, 30 bytes



    _ż+¥⁵AÞḢṠxAƊ×€ʋ"JṬ€$$Ẏ;@W}+%⁵


    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!






    share|improve this answer









    $endgroup$






















      0













      $begingroup$


      PHP, 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!



      My solution probably sucks, but that is the best I can think of for now!






      share|improve this answer











      $endgroup$






















        0













        $begingroup$


        Charcoal, 48 bytes



        θ≔EθIιθF³«≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζF↔櫧≔θι﹪⁺§θι÷ζ↔ζχ⸿⪫θω


        Try it online! Link is to verbose version of code. Explanation:



        θ


        Print the initial position.



        ≔EθIιθ


        Change the initial position string into an array of numeric digits for calculation purposes.



        F³«


        Loop over each digit in turn.



        ≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζ


        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.



        F↔ζ«


        Loop over each rotation.



        §≔θι﹪⁺§θι÷ζ↔ζχ


        Update the digit according to the sign of the rotation.



        ⸿⪫θω


        Output the digits as a string on a new line.






        share|improve this answer









        $endgroup$






















          0













          $begingroup$


          Jelly, 25 bytes



          _æ%5+⁹⁹rḊ€%⁵J;Ɱ"$ẎṄḢ}⁺¦¥ƒ


          Try it online!



          Full program.






          share|improve this answer









          $endgroup$






















            0













            $begingroup$

            T-SQL 2012, 229 bytes



            Not 100 % sql, but it is a full program, that works with the link



            DECLARE @1 char(3)=##i##, @2 char(3)=##j##,@ INT=1PRINT @1
            WHILE @<4IF substring(@1,@,1)=substring(@2,@,1)SET @+=1
            ELSE
            BEGIN
            SET @1=stuff(@1,@,1,(9+substring(@1,@,1)+(9+substring(@1,@,1)-substring(@2,@,1))/5%2*2)%10)PRINT @1
            END


            Try it online






            share|improve this answer









            $endgroup$

















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "200"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              user2190035 is a new contributor. Be nice, and check out our Code of Conduct.









              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f190875%2funlock-your-lock%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              7 Answers
              7






              active

              oldest

              votes








              7 Answers
              7






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2













              $begingroup$


              Python 2, 113 107 bytes





              a,b=input()
              print a
              for x,y,i in zip(a,b,(0,1,2)):
              while x-y:a[i]=x=(x+1-2*((y-x)%10>(x-y)%10))%10;print a


              Try it online!



              Takes input as lists of integers






              share|improve this answer









              $endgroup$



















                2













                $begingroup$


                Python 2, 113 107 bytes





                a,b=input()
                print a
                for x,y,i in zip(a,b,(0,1,2)):
                while x-y:a[i]=x=(x+1-2*((y-x)%10>(x-y)%10))%10;print a


                Try it online!



                Takes input as lists of integers






                share|improve this answer









                $endgroup$

















                  2














                  2










                  2







                  $begingroup$


                  Python 2, 113 107 bytes





                  a,b=input()
                  print a
                  for x,y,i in zip(a,b,(0,1,2)):
                  while x-y:a[i]=x=(x+1-2*((y-x)%10>(x-y)%10))%10;print a


                  Try it online!



                  Takes input as lists of integers






                  share|improve this answer









                  $endgroup$




                  Python 2, 113 107 bytes





                  a,b=input()
                  print a
                  for x,y,i in zip(a,b,(0,1,2)):
                  while x-y:a[i]=x=(x+1-2*((y-x)%10>(x-y)%10))%10;print a


                  Try it online!



                  Takes input as lists of integers







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 8 hours ago









                  TFeldTFeld

                  18.4k3 gold badges14 silver badges57 bronze badges




                  18.4k3 gold badges14 silver badges57 bronze badges


























                      1













                      $begingroup$

                      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!



                      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[]





                      share|improve this answer











                      $endgroup$














                      • $begingroup$
                        d/6&1^d>0||9 -> d/5>5/d?9:1
                        $endgroup$
                        – tsh
                        7 hours ago















                      1













                      $begingroup$

                      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!



                      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[]





                      share|improve this answer











                      $endgroup$














                      • $begingroup$
                        d/6&1^d>0||9 -> d/5>5/d?9:1
                        $endgroup$
                        – tsh
                        7 hours ago













                      1














                      1










                      1







                      $begingroup$

                      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!



                      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[]





                      share|improve this answer











                      $endgroup$



                      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!



                      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[]






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 6 hours ago

























                      answered 7 hours ago









                      ArnauldArnauld

                      91.2k7 gold badges106 silver badges372 bronze badges




                      91.2k7 gold badges106 silver badges372 bronze badges














                      • $begingroup$
                        d/6&1^d>0||9 -> d/5>5/d?9:1
                        $endgroup$
                        – tsh
                        7 hours ago
















                      • $begingroup$
                        d/6&1^d>0||9 -> d/5>5/d?9:1
                        $endgroup$
                        – tsh
                        7 hours ago















                      $begingroup$
                      d/6&1^d>0||9 -> d/5>5/d?9:1
                      $endgroup$
                      – tsh
                      7 hours ago




                      $begingroup$
                      d/6&1^d>0||9 -> d/5>5/d?9:1
                      $endgroup$
                      – tsh
                      7 hours ago











                      0













                      $begingroup$


                      Jelly, 30 bytes



                      _ż+¥⁵AÞḢṠxAƊ×€ʋ"JṬ€$$Ẏ;@W}+%⁵


                      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!






                      share|improve this answer









                      $endgroup$



















                        0













                        $begingroup$


                        Jelly, 30 bytes



                        _ż+¥⁵AÞḢṠxAƊ×€ʋ"JṬ€$$Ẏ;@W}+%⁵


                        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!






                        share|improve this answer









                        $endgroup$

















                          0














                          0










                          0







                          $begingroup$


                          Jelly, 30 bytes



                          _ż+¥⁵AÞḢṠxAƊ×€ʋ"JṬ€$$Ẏ;@W}+%⁵


                          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!






                          share|improve this answer









                          $endgroup$




                          Jelly, 30 bytes



                          _ż+¥⁵AÞḢṠxAƊ×€ʋ"JṬ€$$Ẏ;@W}+%⁵


                          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!







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 5 hours ago









                          Nick KennedyNick Kennedy

                          6,1071 gold badge9 silver badges15 bronze badges




                          6,1071 gold badge9 silver badges15 bronze badges
























                              0













                              $begingroup$


                              PHP, 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!



                              My solution probably sucks, but that is the best I can think of for now!






                              share|improve this answer











                              $endgroup$



















                                0













                                $begingroup$


                                PHP, 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!



                                My solution probably sucks, but that is the best I can think of for now!






                                share|improve this answer











                                $endgroup$

















                                  0














                                  0










                                  0







                                  $begingroup$


                                  PHP, 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!



                                  My solution probably sucks, but that is the best I can think of for now!






                                  share|improve this answer











                                  $endgroup$




                                  PHP, 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!



                                  My solution probably sucks, but that is the best I can think of for now!







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited 5 hours ago

























                                  answered 6 hours ago









                                  Night2Night2

                                  2,4013 silver badges15 bronze badges




                                  2,4013 silver badges15 bronze badges
























                                      0













                                      $begingroup$


                                      Charcoal, 48 bytes



                                      θ≔EθIιθF³«≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζF↔櫧≔θι﹪⁺§θι÷ζ↔ζχ⸿⪫θω


                                      Try it online! Link is to verbose version of code. Explanation:



                                      θ


                                      Print the initial position.



                                      ≔EθIιθ


                                      Change the initial position string into an array of numeric digits for calculation purposes.



                                      F³«


                                      Loop over each digit in turn.



                                      ≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζ


                                      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.



                                      F↔ζ«


                                      Loop over each rotation.



                                      §≔θι﹪⁺§θι÷ζ↔ζχ


                                      Update the digit according to the sign of the rotation.



                                      ⸿⪫θω


                                      Output the digits as a string on a new line.






                                      share|improve this answer









                                      $endgroup$



















                                        0













                                        $begingroup$


                                        Charcoal, 48 bytes



                                        θ≔EθIιθF³«≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζF↔櫧≔θι﹪⁺§θι÷ζ↔ζχ⸿⪫θω


                                        Try it online! Link is to verbose version of code. Explanation:



                                        θ


                                        Print the initial position.



                                        ≔EθIιθ


                                        Change the initial position string into an array of numeric digits for calculation purposes.



                                        F³«


                                        Loop over each digit in turn.



                                        ≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζ


                                        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.



                                        F↔ζ«


                                        Loop over each rotation.



                                        §≔θι﹪⁺§θι÷ζ↔ζχ


                                        Update the digit according to the sign of the rotation.



                                        ⸿⪫θω


                                        Output the digits as a string on a new line.






                                        share|improve this answer









                                        $endgroup$

















                                          0














                                          0










                                          0







                                          $begingroup$


                                          Charcoal, 48 bytes



                                          θ≔EθIιθF³«≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζF↔櫧≔θι﹪⁺§θι÷ζ↔ζχ⸿⪫θω


                                          Try it online! Link is to verbose version of code. Explanation:



                                          θ


                                          Print the initial position.



                                          ≔EθIιθ


                                          Change the initial position string into an array of numeric digits for calculation purposes.



                                          F³«


                                          Loop over each digit in turn.



                                          ≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζ


                                          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.



                                          F↔ζ«


                                          Loop over each rotation.



                                          §≔θι﹪⁺§θι÷ζ↔ζχ


                                          Update the digit according to the sign of the rotation.



                                          ⸿⪫θω


                                          Output the digits as a string on a new line.






                                          share|improve this answer









                                          $endgroup$




                                          Charcoal, 48 bytes



                                          θ≔EθIιθF³«≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζF↔櫧≔θι﹪⁺§θι÷ζ↔ζχ⸿⪫θω


                                          Try it online! Link is to verbose version of code. Explanation:



                                          θ


                                          Print the initial position.



                                          ≔EθIιθ


                                          Change the initial position string into an array of numeric digits for calculation purposes.



                                          F³«


                                          Loop over each digit in turn.



                                          ≔⁻﹪⁺⁻I§ηι§θι⁵χ⁵ζ


                                          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.



                                          F↔ζ«


                                          Loop over each rotation.



                                          §≔θι﹪⁺§θι÷ζ↔ζχ


                                          Update the digit according to the sign of the rotation.



                                          ⸿⪫θω


                                          Output the digits as a string on a new line.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered 4 hours ago









                                          NeilNeil

                                          88.1k8 gold badges46 silver badges186 bronze badges




                                          88.1k8 gold badges46 silver badges186 bronze badges
























                                              0













                                              $begingroup$


                                              Jelly, 25 bytes



                                              _æ%5+⁹⁹rḊ€%⁵J;Ɱ"$ẎṄḢ}⁺¦¥ƒ


                                              Try it online!



                                              Full program.






                                              share|improve this answer









                                              $endgroup$



















                                                0













                                                $begingroup$


                                                Jelly, 25 bytes



                                                _æ%5+⁹⁹rḊ€%⁵J;Ɱ"$ẎṄḢ}⁺¦¥ƒ


                                                Try it online!



                                                Full program.






                                                share|improve this answer









                                                $endgroup$

















                                                  0














                                                  0










                                                  0







                                                  $begingroup$


                                                  Jelly, 25 bytes



                                                  _æ%5+⁹⁹rḊ€%⁵J;Ɱ"$ẎṄḢ}⁺¦¥ƒ


                                                  Try it online!



                                                  Full program.






                                                  share|improve this answer









                                                  $endgroup$




                                                  Jelly, 25 bytes



                                                  _æ%5+⁹⁹rḊ€%⁵J;Ɱ"$ẎṄḢ}⁺¦¥ƒ


                                                  Try it online!



                                                  Full program.







                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered 2 hours ago









                                                  Erik the OutgolferErik the Outgolfer

                                                  35.9k4 gold badges30 silver badges113 bronze badges




                                                  35.9k4 gold badges30 silver badges113 bronze badges
























                                                      0













                                                      $begingroup$

                                                      T-SQL 2012, 229 bytes



                                                      Not 100 % sql, but it is a full program, that works with the link



                                                      DECLARE @1 char(3)=##i##, @2 char(3)=##j##,@ INT=1PRINT @1
                                                      WHILE @<4IF substring(@1,@,1)=substring(@2,@,1)SET @+=1
                                                      ELSE
                                                      BEGIN
                                                      SET @1=stuff(@1,@,1,(9+substring(@1,@,1)+(9+substring(@1,@,1)-substring(@2,@,1))/5%2*2)%10)PRINT @1
                                                      END


                                                      Try it online






                                                      share|improve this answer









                                                      $endgroup$



















                                                        0













                                                        $begingroup$

                                                        T-SQL 2012, 229 bytes



                                                        Not 100 % sql, but it is a full program, that works with the link



                                                        DECLARE @1 char(3)=##i##, @2 char(3)=##j##,@ INT=1PRINT @1
                                                        WHILE @<4IF substring(@1,@,1)=substring(@2,@,1)SET @+=1
                                                        ELSE
                                                        BEGIN
                                                        SET @1=stuff(@1,@,1,(9+substring(@1,@,1)+(9+substring(@1,@,1)-substring(@2,@,1))/5%2*2)%10)PRINT @1
                                                        END


                                                        Try it online






                                                        share|improve this answer









                                                        $endgroup$

















                                                          0














                                                          0










                                                          0







                                                          $begingroup$

                                                          T-SQL 2012, 229 bytes



                                                          Not 100 % sql, but it is a full program, that works with the link



                                                          DECLARE @1 char(3)=##i##, @2 char(3)=##j##,@ INT=1PRINT @1
                                                          WHILE @<4IF substring(@1,@,1)=substring(@2,@,1)SET @+=1
                                                          ELSE
                                                          BEGIN
                                                          SET @1=stuff(@1,@,1,(9+substring(@1,@,1)+(9+substring(@1,@,1)-substring(@2,@,1))/5%2*2)%10)PRINT @1
                                                          END


                                                          Try it online






                                                          share|improve this answer









                                                          $endgroup$



                                                          T-SQL 2012, 229 bytes



                                                          Not 100 % sql, but it is a full program, that works with the link



                                                          DECLARE @1 char(3)=##i##, @2 char(3)=##j##,@ INT=1PRINT @1
                                                          WHILE @<4IF substring(@1,@,1)=substring(@2,@,1)SET @+=1
                                                          ELSE
                                                          BEGIN
                                                          SET @1=stuff(@1,@,1,(9+substring(@1,@,1)+(9+substring(@1,@,1)-substring(@2,@,1))/5%2*2)%10)PRINT @1
                                                          END


                                                          Try it online







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered 1 hour ago









                                                          t-clausen.dkt-clausen.dk

                                                          2,5645 silver badges14 bronze badges




                                                          2,5645 silver badges14 bronze badges























                                                              user2190035 is a new contributor. Be nice, and check out our Code of Conduct.









                                                              draft saved

                                                              draft discarded


















                                                              user2190035 is a new contributor. Be nice, and check out our Code of Conduct.












                                                              user2190035 is a new contributor. Be nice, and check out our Code of Conduct.











                                                              user2190035 is a new contributor. Be nice, and check out our Code of Conduct.














                                                              If this is an answer to a challenge…



                                                              • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                              • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                Explanations of your answer make it more interesting to read and are very much encouraged.


                                                              • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                              More generally…



                                                              • …Please make sure to answer the question and provide sufficient detail.


                                                              • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function ()
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f190875%2funlock-your-lock%23new-answer', 'question_page');

                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              Popular posts from this blog

                                                              Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                                                              Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                                                              Tom Holland Mục lục Đầu đời và giáo dục | Sự nghiệp | Cuộc sống cá nhân | Phim tham gia | Giải thưởng và đề cử | Chú thích | Liên kết ngoài | Trình đơn chuyển hướngProfile“Person Details for Thomas Stanley Holland, "England and Wales Birth Registration Index, 1837-2008" — FamilySearch.org”"Meet Tom Holland... the 16-year-old star of The Impossible""Schoolboy actor Tom Holland finds himself in Oscar contention for role in tsunami drama"“Naomi Watts on the Prince William and Harry's reaction to her film about the late Princess Diana”lưu trữ"Holland and Pflueger Are West End's Two New 'Billy Elliots'""I'm so envious of my son, the movie star! British writer Dominic Holland's spent 20 years trying to crack Hollywood - but he's been beaten to it by a very unlikely rival"“Richard and Margaret Povey of Jersey, Channel Islands, UK: Information about Thomas Stanley Holland”"Tom Holland to play Billy Elliot""New Billy Elliot leaving the garage"Billy Elliot the Musical - Tom Holland - Billy"A Tale of four Billys: Tom Holland""The Feel Good Factor""Thames Christian College schoolboys join Myleene Klass for The Feelgood Factor""Government launches £600,000 arts bursaries pilot""BILLY's Chapman, Holland, Gardner & Jackson-Keen Visit Prime Minister""Elton John 'blown away' by Billy Elliot fifth birthday" (video with John's interview and fragments of Holland's performance)"First News interviews Arrietty's Tom Holland"“33rd Critics' Circle Film Awards winners”“National Board of Review Current Awards”Bản gốc"Ron Howard Whaling Tale 'In The Heart Of The Sea' Casts Tom Holland"“'Spider-Man' Finds Tom Holland to Star as New Web-Slinger”lưu trữ“Captain America: Civil War (2016)”“Film Review: ‘Captain America: Civil War’”lưu trữ“‘Captain America: Civil War’ review: Choose your own avenger”lưu trữ“The Lost City of Z reviews”“Sony Pictures and Marvel Studios Find Their 'Spider-Man' Star and Director”“‘Mary Magdalene’, ‘Current War’ & ‘Wind River’ Get 2017 Release Dates From Weinstein”“Lionsgate Unleashing Daisy Ridley & Tom Holland Starrer ‘Chaos Walking’ In Cannes”“PTA's 'Master' Leads Chicago Film Critics Nominations, UPDATED: Houston and Indiana Critics Nominations”“Nominaciones Goya 2013 Telecinco Cinema – ENG”“Jameson Empire Film Awards: Martin Freeman wins best actor for performance in The Hobbit”“34th Annual Young Artist Awards”Bản gốc“Teen Choice Awards 2016—Captain America: Civil War Leads Second Wave of Nominations”“BAFTA Film Award Nominations: ‘La La Land’ Leads Race”“Saturn Awards Nominations 2017: 'Rogue One,' 'Walking Dead' Lead”Tom HollandTom HollandTom HollandTom Hollandmedia.gettyimages.comWorldCat Identities300279794no20130442900000 0004 0355 42791085670554170004732cb16706349t(data)XX5557367