New Order #2: Turn My WayIncrementing Gray CodesGive me the Gray Code list of bit width nNew Order #1: How does this feel?Give me the Gray Code list of bit width nPrint the intersection of sequencesHarmonious “Convergence”Sylvester's sequenceIncrementing Gray CodesThe dragon Curve sequenceAlternating bit smearingJumping NumbersMake me a metasequenceNew Order #1: How does this feel?

Strange behavior in TikZ draw command

"Marked down as someone wanting to sell shares." What does that mean?

How are passwords stolen from companies if they only store hashes?

Extract substring according to regexp with sed or grep

Taking the numerator and the denominator

A seasonal riddle

How do you say "Trust your struggle." in French?

Boss fired me and is begging for me to come back - how much of a raise is reasonable?

How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?

New Order #2: Turn My Way

When is the exact date for EOL of Ubuntu 14.04 LTS?

Is there any common country to visit for persons holding UK and Schengen visas?

If the Dominion rule using their Jem'Hadar troops, why is their life expectancy so low?

Is there a distance limit for minecart tracks?

What's the meaning of "what it means for something to be something"?

How do you justify more code being written by following clean code practices?

What is the period/term used describe Giuseppe Arcimboldo's style of painting?

Writing in a Christian voice

python displays `n` instead of breaking a line

Why didn’t Eve recognize the little cockroach as a living organism?

How to robustly store bits of text for later use

Hashing password to increase entropy

"Oh no!" in Latin

How would a solely written language work mechanically



New Order #2: Turn My Way


Incrementing Gray CodesGive me the Gray Code list of bit width nNew Order #1: How does this feel?Give me the Gray Code list of bit width nPrint the intersection of sequencesHarmonious “Convergence”Sylvester's sequenceIncrementing Gray CodesThe dragon Curve sequenceAlternating bit smearingJumping NumbersMake me a metasequenceNew Order #1: How does this feel?













8












$begingroup$


Introduction (may be ignored)



Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the second challenge in this series. The first challenge can be found here.



In this challenge, we use Gray codes to rearrage the natural numbers. A Gray code, or "reflected binary code" is a binary encoding in such a way that two successive values differ in only one bit. A practical application of this encoding is to use it in rotary encoders, hence my reference to "Turn My Way".



Rotary encoder for angle-measuring devices marked in 3-bit binary.



Note that this encoding leaves some degree of freedom. For example, following binary 1100, there are four possible following codes: 1101, 1110, 1000 and 0100. This is why I will define $a(n)$ as the smallest, not previously used value that differs only one character in binary encoding. This sequence corresponds with A163252.



Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A163252.



Task



Given an integer input $n$, output $a(n)$ in integer format (not in binary format).



$a(n)$ is defined as the least positive integer not occurring earlier in the sequence such that $a(n-1)$ and $a(n)$ differ in only one bit when written in binary.



Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 3$, etc. Please mention this in your answer if you choose to use this.



Test cases



Input | Output
--------------
1 | 1
5 | 4
20 | 18
50 | 48
123 | 121
1234 | 1333
3000 | 3030
9999 | 9997


Rules



  • Input and output are integers (your program should at least support input and output in the range of 1 up to 32767)

  • Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour. In A163252, $a(0)$ is defined as 0. For this challenge, we will ignore this.

  • Default I/O rules apply.


  • Default loopholes are forbidden.

  • This is code-golf, so the shortest answers in bytes wins

Final note



See the following related (but not equal) PP&CG questions:



  • Finding the next Gray code (input and output in binary)

  • Generate the all Gray codes of length n









share|improve this question









$endgroup$
















    8












    $begingroup$


    Introduction (may be ignored)



    Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the second challenge in this series. The first challenge can be found here.



    In this challenge, we use Gray codes to rearrage the natural numbers. A Gray code, or "reflected binary code" is a binary encoding in such a way that two successive values differ in only one bit. A practical application of this encoding is to use it in rotary encoders, hence my reference to "Turn My Way".



    Rotary encoder for angle-measuring devices marked in 3-bit binary.



    Note that this encoding leaves some degree of freedom. For example, following binary 1100, there are four possible following codes: 1101, 1110, 1000 and 0100. This is why I will define $a(n)$ as the smallest, not previously used value that differs only one character in binary encoding. This sequence corresponds with A163252.



    Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A163252.



    Task



    Given an integer input $n$, output $a(n)$ in integer format (not in binary format).



    $a(n)$ is defined as the least positive integer not occurring earlier in the sequence such that $a(n-1)$ and $a(n)$ differ in only one bit when written in binary.



    Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 3$, etc. Please mention this in your answer if you choose to use this.



    Test cases



    Input | Output
    --------------
    1 | 1
    5 | 4
    20 | 18
    50 | 48
    123 | 121
    1234 | 1333
    3000 | 3030
    9999 | 9997


    Rules



    • Input and output are integers (your program should at least support input and output in the range of 1 up to 32767)

    • Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour. In A163252, $a(0)$ is defined as 0. For this challenge, we will ignore this.

    • Default I/O rules apply.


    • Default loopholes are forbidden.

    • This is code-golf, so the shortest answers in bytes wins

    Final note



    See the following related (but not equal) PP&CG questions:



    • Finding the next Gray code (input and output in binary)

    • Generate the all Gray codes of length n









    share|improve this question









    $endgroup$














      8












      8








      8





      $begingroup$


      Introduction (may be ignored)



      Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the second challenge in this series. The first challenge can be found here.



      In this challenge, we use Gray codes to rearrage the natural numbers. A Gray code, or "reflected binary code" is a binary encoding in such a way that two successive values differ in only one bit. A practical application of this encoding is to use it in rotary encoders, hence my reference to "Turn My Way".



      Rotary encoder for angle-measuring devices marked in 3-bit binary.



      Note that this encoding leaves some degree of freedom. For example, following binary 1100, there are four possible following codes: 1101, 1110, 1000 and 0100. This is why I will define $a(n)$ as the smallest, not previously used value that differs only one character in binary encoding. This sequence corresponds with A163252.



      Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A163252.



      Task



      Given an integer input $n$, output $a(n)$ in integer format (not in binary format).



      $a(n)$ is defined as the least positive integer not occurring earlier in the sequence such that $a(n-1)$ and $a(n)$ differ in only one bit when written in binary.



      Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 3$, etc. Please mention this in your answer if you choose to use this.



      Test cases



      Input | Output
      --------------
      1 | 1
      5 | 4
      20 | 18
      50 | 48
      123 | 121
      1234 | 1333
      3000 | 3030
      9999 | 9997


      Rules



      • Input and output are integers (your program should at least support input and output in the range of 1 up to 32767)

      • Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour. In A163252, $a(0)$ is defined as 0. For this challenge, we will ignore this.

      • Default I/O rules apply.


      • Default loopholes are forbidden.

      • This is code-golf, so the shortest answers in bytes wins

      Final note



      See the following related (but not equal) PP&CG questions:



      • Finding the next Gray code (input and output in binary)

      • Generate the all Gray codes of length n









      share|improve this question









      $endgroup$




      Introduction (may be ignored)



      Putting all positive numbers in its regular order (1, 2, 3, ...) is a bit boring, isn't it? So here is a series of challenges around permutations (reshuffelings) of all positive numbers. This is the second challenge in this series. The first challenge can be found here.



      In this challenge, we use Gray codes to rearrage the natural numbers. A Gray code, or "reflected binary code" is a binary encoding in such a way that two successive values differ in only one bit. A practical application of this encoding is to use it in rotary encoders, hence my reference to "Turn My Way".



      Rotary encoder for angle-measuring devices marked in 3-bit binary.



      Note that this encoding leaves some degree of freedom. For example, following binary 1100, there are four possible following codes: 1101, 1110, 1000 and 0100. This is why I will define $a(n)$ as the smallest, not previously used value that differs only one character in binary encoding. This sequence corresponds with A163252.



      Since this is a "pure sequence" challenge, the task is to output $a(n)$ for a given $n$ as input, where $a(n)$ is A163252.



      Task



      Given an integer input $n$, output $a(n)$ in integer format (not in binary format).



      $a(n)$ is defined as the least positive integer not occurring earlier in the sequence such that $a(n-1)$ and $a(n)$ differ in only one bit when written in binary.



      Note: 1-based indexing is assumed here; you may use 0-based indexing, so $a(0) = 1; a(1) = 3$, etc. Please mention this in your answer if you choose to use this.



      Test cases



      Input | Output
      --------------
      1 | 1
      5 | 4
      20 | 18
      50 | 48
      123 | 121
      1234 | 1333
      3000 | 3030
      9999 | 9997


      Rules



      • Input and output are integers (your program should at least support input and output in the range of 1 up to 32767)

      • Invalid input (0, floats, strings, negative values, etc.) may lead to unpredicted output, errors or (un)defined behaviour. In A163252, $a(0)$ is defined as 0. For this challenge, we will ignore this.

      • Default I/O rules apply.


      • Default loopholes are forbidden.

      • This is code-golf, so the shortest answers in bytes wins

      Final note



      See the following related (but not equal) PP&CG questions:



      • Finding the next Gray code (input and output in binary)

      • Generate the all Gray codes of length n






      code-golf sequence






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 5 hours ago









      agtoeveragtoever

      1,113419




      1,113419




















          5 Answers
          5






          active

          oldest

          votes


















          2












          $begingroup$


          Jelly, 26 22 bytes



          ṀBL‘Ḷ2*^0ị$ḟ⁸Ṃ
          0;Ç$⁸¡Ṫ


          Try it online!



          A full program that takes n as the single argument. Works for all test cases. Also note that, although not required, it handles n=0.



          Explanation



          Helper link: find next term



          Ṁ | maximum of list so far
          B | convert to binary
          L | number of binary digits
          ‘ | increase by one
          Ḷ | lowered range (0..above number)
          2* | 2 to the power of each of the above
          ^ | exclusive or with...
          0ị$ | ... the last term in the list so far
          ḟ⁸ | filter out anything used already
          Ṃ | find the minimum


          Main link



          0 | start with zero
          ;Ç$ | append the result of the above link
          ⁸¡ | and repeat n times
          Ṫ | take the last term





          share|improve this answer











          $endgroup$




















            2












            $begingroup$

            JavaScript (ES6), 65 bytes



            1-indexed.





            n=>for(o=p=[k=1];o[k]


            Try it online!



            Commented



            n => // n = index of requested term
            for( // for loop:
            o = // o = storage object for the terms of the sequence
            p = // p = last term found in the sequence
            [k = 1]; // k = current term
            o[k] // end





            share|improve this answer











            $endgroup$












            • $begingroup$
              On TIO, I get a stack overflow for n > ~1024. Any suggestions on how tot deal with that in Abu other environment? Rule: "your program should at least support input and output in theorie range of 1 up tot 32767"
              $endgroup$
              – agtoever
              58 mins ago






            • 1




              $begingroup$
              @agtoever I've updated it to a non-recursive version.
              $endgroup$
              – Arnauld
              27 mins ago


















            1












            $begingroup$


            Wolfram Language (Mathematica), 74 bytes



            Last@Nest[#~Join~Min[BitXor[Last@#,2^Range[0,20]]~Complement~#]&,0,#]&


            Try it online!






            share|improve this answer









            $endgroup$




















              0












              $begingroup$


              Python 3.8 (pre-release), 85 bytes



              1-based indexing, really inefficient





              a=lambda n,x=0:((w:=x^(n and a(n-1)))&w-1or x in[a(i)for i in range(n)])and-~a(n,x+1)


              Try it online!






              share|improve this answer









              $endgroup$












              • $begingroup$
                Maximum input 32767 isn't supported (the default recursion depth isn't system-dependent).
                $endgroup$
                – Erik the Outgolfer
                6 mins ago


















              0












              $begingroup$


              05AB1E, 15 bytes



              Pretty inefficient, so it might take a while for larger inputs.



              Code:



              0λ∞λKD₁^bíϬ]¹è


              Try it online!






              share|improve this answer









              $endgroup$












                Your Answer





                StackExchange.ifUsing("editor", function ()
                return StackExchange.using("mathjaxEditing", function ()
                StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
                StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                );
                );
                , "mathjax-editing");

                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
                );



                );













                draft saved

                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181825%2fnew-order-2-turn-my-way%23new-answer', 'question_page');

                );

                Post as a guest















                Required, but never shown

























                5 Answers
                5






                active

                oldest

                votes








                5 Answers
                5






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                2












                $begingroup$


                Jelly, 26 22 bytes



                ṀBL‘Ḷ2*^0ị$ḟ⁸Ṃ
                0;Ç$⁸¡Ṫ


                Try it online!



                A full program that takes n as the single argument. Works for all test cases. Also note that, although not required, it handles n=0.



                Explanation



                Helper link: find next term



                Ṁ | maximum of list so far
                B | convert to binary
                L | number of binary digits
                ‘ | increase by one
                Ḷ | lowered range (0..above number)
                2* | 2 to the power of each of the above
                ^ | exclusive or with...
                0ị$ | ... the last term in the list so far
                ḟ⁸ | filter out anything used already
                Ṃ | find the minimum


                Main link



                0 | start with zero
                ;Ç$ | append the result of the above link
                ⁸¡ | and repeat n times
                Ṫ | take the last term





                share|improve this answer











                $endgroup$

















                  2












                  $begingroup$


                  Jelly, 26 22 bytes



                  ṀBL‘Ḷ2*^0ị$ḟ⁸Ṃ
                  0;Ç$⁸¡Ṫ


                  Try it online!



                  A full program that takes n as the single argument. Works for all test cases. Also note that, although not required, it handles n=0.



                  Explanation



                  Helper link: find next term



                  Ṁ | maximum of list so far
                  B | convert to binary
                  L | number of binary digits
                  ‘ | increase by one
                  Ḷ | lowered range (0..above number)
                  2* | 2 to the power of each of the above
                  ^ | exclusive or with...
                  0ị$ | ... the last term in the list so far
                  ḟ⁸ | filter out anything used already
                  Ṃ | find the minimum


                  Main link



                  0 | start with zero
                  ;Ç$ | append the result of the above link
                  ⁸¡ | and repeat n times
                  Ṫ | take the last term





                  share|improve this answer











                  $endgroup$















                    2












                    2








                    2





                    $begingroup$


                    Jelly, 26 22 bytes



                    ṀBL‘Ḷ2*^0ị$ḟ⁸Ṃ
                    0;Ç$⁸¡Ṫ


                    Try it online!



                    A full program that takes n as the single argument. Works for all test cases. Also note that, although not required, it handles n=0.



                    Explanation



                    Helper link: find next term



                    Ṁ | maximum of list so far
                    B | convert to binary
                    L | number of binary digits
                    ‘ | increase by one
                    Ḷ | lowered range (0..above number)
                    2* | 2 to the power of each of the above
                    ^ | exclusive or with...
                    0ị$ | ... the last term in the list so far
                    ḟ⁸ | filter out anything used already
                    Ṃ | find the minimum


                    Main link



                    0 | start with zero
                    ;Ç$ | append the result of the above link
                    ⁸¡ | and repeat n times
                    Ṫ | take the last term





                    share|improve this answer











                    $endgroup$




                    Jelly, 26 22 bytes



                    ṀBL‘Ḷ2*^0ị$ḟ⁸Ṃ
                    0;Ç$⁸¡Ṫ


                    Try it online!



                    A full program that takes n as the single argument. Works for all test cases. Also note that, although not required, it handles n=0.



                    Explanation



                    Helper link: find next term



                    Ṁ | maximum of list so far
                    B | convert to binary
                    L | number of binary digits
                    ‘ | increase by one
                    Ḷ | lowered range (0..above number)
                    2* | 2 to the power of each of the above
                    ^ | exclusive or with...
                    0ị$ | ... the last term in the list so far
                    ḟ⁸ | filter out anything used already
                    Ṃ | find the minimum


                    Main link



                    0 | start with zero
                    ;Ç$ | append the result of the above link
                    ⁸¡ | and repeat n times
                    Ṫ | take the last term






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 8 mins ago

























                    answered 1 hour ago









                    Nick KennedyNick Kennedy

                    79137




                    79137





















                        2












                        $begingroup$

                        JavaScript (ES6), 65 bytes



                        1-indexed.





                        n=>for(o=p=[k=1];o[k]


                        Try it online!



                        Commented



                        n => // n = index of requested term
                        for( // for loop:
                        o = // o = storage object for the terms of the sequence
                        p = // p = last term found in the sequence
                        [k = 1]; // k = current term
                        o[k] // end





                        share|improve this answer











                        $endgroup$












                        • $begingroup$
                          On TIO, I get a stack overflow for n > ~1024. Any suggestions on how tot deal with that in Abu other environment? Rule: "your program should at least support input and output in theorie range of 1 up tot 32767"
                          $endgroup$
                          – agtoever
                          58 mins ago






                        • 1




                          $begingroup$
                          @agtoever I've updated it to a non-recursive version.
                          $endgroup$
                          – Arnauld
                          27 mins ago















                        2












                        $begingroup$

                        JavaScript (ES6), 65 bytes



                        1-indexed.





                        n=>for(o=p=[k=1];o[k]


                        Try it online!



                        Commented



                        n => // n = index of requested term
                        for( // for loop:
                        o = // o = storage object for the terms of the sequence
                        p = // p = last term found in the sequence
                        [k = 1]; // k = current term
                        o[k] // end





                        share|improve this answer











                        $endgroup$












                        • $begingroup$
                          On TIO, I get a stack overflow for n > ~1024. Any suggestions on how tot deal with that in Abu other environment? Rule: "your program should at least support input and output in theorie range of 1 up tot 32767"
                          $endgroup$
                          – agtoever
                          58 mins ago






                        • 1




                          $begingroup$
                          @agtoever I've updated it to a non-recursive version.
                          $endgroup$
                          – Arnauld
                          27 mins ago













                        2












                        2








                        2





                        $begingroup$

                        JavaScript (ES6), 65 bytes



                        1-indexed.





                        n=>for(o=p=[k=1];o[k]


                        Try it online!



                        Commented



                        n => // n = index of requested term
                        for( // for loop:
                        o = // o = storage object for the terms of the sequence
                        p = // p = last term found in the sequence
                        [k = 1]; // k = current term
                        o[k] // end





                        share|improve this answer











                        $endgroup$



                        JavaScript (ES6), 65 bytes



                        1-indexed.





                        n=>for(o=p=[k=1];o[k]


                        Try it online!



                        Commented



                        n => // n = index of requested term
                        for( // for loop:
                        o = // o = storage object for the terms of the sequence
                        p = // p = last term found in the sequence
                        [k = 1]; // k = current term
                        o[k] // end






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited 7 mins ago

























                        answered 4 hours ago









                        ArnauldArnauld

                        79.2k796329




                        79.2k796329











                        • $begingroup$
                          On TIO, I get a stack overflow for n > ~1024. Any suggestions on how tot deal with that in Abu other environment? Rule: "your program should at least support input and output in theorie range of 1 up tot 32767"
                          $endgroup$
                          – agtoever
                          58 mins ago






                        • 1




                          $begingroup$
                          @agtoever I've updated it to a non-recursive version.
                          $endgroup$
                          – Arnauld
                          27 mins ago
















                        • $begingroup$
                          On TIO, I get a stack overflow for n > ~1024. Any suggestions on how tot deal with that in Abu other environment? Rule: "your program should at least support input and output in theorie range of 1 up tot 32767"
                          $endgroup$
                          – agtoever
                          58 mins ago






                        • 1




                          $begingroup$
                          @agtoever I've updated it to a non-recursive version.
                          $endgroup$
                          – Arnauld
                          27 mins ago















                        $begingroup$
                        On TIO, I get a stack overflow for n > ~1024. Any suggestions on how tot deal with that in Abu other environment? Rule: "your program should at least support input and output in theorie range of 1 up tot 32767"
                        $endgroup$
                        – agtoever
                        58 mins ago




                        $begingroup$
                        On TIO, I get a stack overflow for n > ~1024. Any suggestions on how tot deal with that in Abu other environment? Rule: "your program should at least support input and output in theorie range of 1 up tot 32767"
                        $endgroup$
                        – agtoever
                        58 mins ago




                        1




                        1




                        $begingroup$
                        @agtoever I've updated it to a non-recursive version.
                        $endgroup$
                        – Arnauld
                        27 mins ago




                        $begingroup$
                        @agtoever I've updated it to a non-recursive version.
                        $endgroup$
                        – Arnauld
                        27 mins ago











                        1












                        $begingroup$


                        Wolfram Language (Mathematica), 74 bytes



                        Last@Nest[#~Join~Min[BitXor[Last@#,2^Range[0,20]]~Complement~#]&,0,#]&


                        Try it online!






                        share|improve this answer









                        $endgroup$

















                          1












                          $begingroup$


                          Wolfram Language (Mathematica), 74 bytes



                          Last@Nest[#~Join~Min[BitXor[Last@#,2^Range[0,20]]~Complement~#]&,0,#]&


                          Try it online!






                          share|improve this answer









                          $endgroup$















                            1












                            1








                            1





                            $begingroup$


                            Wolfram Language (Mathematica), 74 bytes



                            Last@Nest[#~Join~Min[BitXor[Last@#,2^Range[0,20]]~Complement~#]&,0,#]&


                            Try it online!






                            share|improve this answer









                            $endgroup$




                            Wolfram Language (Mathematica), 74 bytes



                            Last@Nest[#~Join~Min[BitXor[Last@#,2^Range[0,20]]~Complement~#]&,0,#]&


                            Try it online!







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 30 mins ago









                            J42161217J42161217

                            13.3k21251




                            13.3k21251





















                                0












                                $begingroup$


                                Python 3.8 (pre-release), 85 bytes



                                1-based indexing, really inefficient





                                a=lambda n,x=0:((w:=x^(n and a(n-1)))&w-1or x in[a(i)for i in range(n)])and-~a(n,x+1)


                                Try it online!






                                share|improve this answer









                                $endgroup$












                                • $begingroup$
                                  Maximum input 32767 isn't supported (the default recursion depth isn't system-dependent).
                                  $endgroup$
                                  – Erik the Outgolfer
                                  6 mins ago















                                0












                                $begingroup$


                                Python 3.8 (pre-release), 85 bytes



                                1-based indexing, really inefficient





                                a=lambda n,x=0:((w:=x^(n and a(n-1)))&w-1or x in[a(i)for i in range(n)])and-~a(n,x+1)


                                Try it online!






                                share|improve this answer









                                $endgroup$












                                • $begingroup$
                                  Maximum input 32767 isn't supported (the default recursion depth isn't system-dependent).
                                  $endgroup$
                                  – Erik the Outgolfer
                                  6 mins ago













                                0












                                0








                                0





                                $begingroup$


                                Python 3.8 (pre-release), 85 bytes



                                1-based indexing, really inefficient





                                a=lambda n,x=0:((w:=x^(n and a(n-1)))&w-1or x in[a(i)for i in range(n)])and-~a(n,x+1)


                                Try it online!






                                share|improve this answer









                                $endgroup$




                                Python 3.8 (pre-release), 85 bytes



                                1-based indexing, really inefficient





                                a=lambda n,x=0:((w:=x^(n and a(n-1)))&w-1or x in[a(i)for i in range(n)])and-~a(n,x+1)


                                Try it online!







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered 1 hour ago









                                ovsovs

                                19.3k21160




                                19.3k21160











                                • $begingroup$
                                  Maximum input 32767 isn't supported (the default recursion depth isn't system-dependent).
                                  $endgroup$
                                  – Erik the Outgolfer
                                  6 mins ago
















                                • $begingroup$
                                  Maximum input 32767 isn't supported (the default recursion depth isn't system-dependent).
                                  $endgroup$
                                  – Erik the Outgolfer
                                  6 mins ago















                                $begingroup$
                                Maximum input 32767 isn't supported (the default recursion depth isn't system-dependent).
                                $endgroup$
                                – Erik the Outgolfer
                                6 mins ago




                                $begingroup$
                                Maximum input 32767 isn't supported (the default recursion depth isn't system-dependent).
                                $endgroup$
                                – Erik the Outgolfer
                                6 mins ago











                                0












                                $begingroup$


                                05AB1E, 15 bytes



                                Pretty inefficient, so it might take a while for larger inputs.



                                Code:



                                0λ∞λKD₁^bíϬ]¹è


                                Try it online!






                                share|improve this answer









                                $endgroup$

















                                  0












                                  $begingroup$


                                  05AB1E, 15 bytes



                                  Pretty inefficient, so it might take a while for larger inputs.



                                  Code:



                                  0λ∞λKD₁^bíϬ]¹è


                                  Try it online!






                                  share|improve this answer









                                  $endgroup$















                                    0












                                    0








                                    0





                                    $begingroup$


                                    05AB1E, 15 bytes



                                    Pretty inefficient, so it might take a while for larger inputs.



                                    Code:



                                    0λ∞λKD₁^bíϬ]¹è


                                    Try it online!






                                    share|improve this answer









                                    $endgroup$




                                    05AB1E, 15 bytes



                                    Pretty inefficient, so it might take a while for larger inputs.



                                    Code:



                                    0λ∞λKD₁^bíϬ]¹è


                                    Try it online!







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered 1 hour ago









                                    AdnanAdnan

                                    35.7k562225




                                    35.7k562225



























                                        draft saved

                                        draft discarded
















































                                        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%2f181825%2fnew-order-2-turn-my-way%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

                                        Благоевград Съдържание География | История | Население | Политика | Икономика и инфрастуктура | Здравеопазване | Образование и наука | Култура и забавления | Забележителности | Личности | Литература | Външни препратки | Бележки | Навигация42°01′18.99″ с. ш. 23°05′51″ и. д. / 42.021944° с. ш. 23.0975° и. д.*БлагоевградразширитередактиранеОфициален уебсайт на община БлагоевградНовинарски портал на Благоевград – blagoevgrad.euСайтове за БлагоевградНационален статистически институтdariknews.bgГригоровичъ, Викторъ. „Очеркъ путешествія по Европейской Турціи“. Москва, 1877.Стрезов, Георги. Два санджака от Източна Македония. Периодично списание на Българското книжовно дружество в Средец, кн. XXXVII и XXXVIII, 1891, стр. 18 – 19.Македония. Етнография и статистикаГаджанов, Димитър Г. Мюсюлманското население в Новоосвободените земи, в: Научна експедиция в Македония и Поморавието 1916, Военноиздателски комплекс „Св. Георги Победоносец“, Университетско издателство „Св. Климент Охридски“, София, 1993, стр. 244.паметник на незнайния четник&cd=18&hl=en&ct=clnk&client=firefox-a „История на днешен Благоевград“, взето от www.museumblg.com на 16 март 2010 г.„Справка за населението на град Благоевград, община Благоевград, област Благоевград, НСИ“„The population of all towns and villages in Blagoevgrad Province with 50 inhabitants or more according to census results and latest official estimates“„Ethnic composition, all places: 2011 census“История на Неврокопска епархия.Национален статистически институтМюсюлманско изповедание. Главно мюфтийствоНационален публичен регистър на храмовете в БългарияМюсюлманско изповедание. Главно мюфтийствоwww.dnes.bg Джамията в Благоевград не била паленаwww.sesc-bg.orgСписък на побратимени градовеТехническо побратимяванеГУМ грейва в цветовете на нощен Лас Вегас под името „Largo“, „МОЛ Благоевград“..., в. „Струма“grabo.bgwww.cinemaxbg.comррр4238731-067cad53a-0546-417b-a3d3-51e49b1d2232147736077147736077

                                        What is the best defense strategy for Survival in Grand Theft Auto Online?What is JP used for in Grand Theft Auto Online?How do I setup a Crew HQ in Grand Theft Auto Online?How does stealth work in Grand Theft Auto Online?Is it possible to own more than 10 cars in Grand Theft Auto online?Where to find truck/trailers in Grand Theft Auto OnlineWhat are some of the best missions to do on Grand Theft Auto 5 onlineFastest Car in Grand Theft Auto V PCHow to setup a Crew vs Crew online session in Grand Theft Auto Online?Grand theft auto 5 crossplayingRestart Grand Theft Auto V Online?

                                        How does Billy Russo acquire his 'Jigsaw' mask? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why does Bane wear the mask?Why does Kylo Ren wear a mask?Why did Captain America remove his mask while fighting Batroc the Leaper?How did the OA acquire her wisdom?Is Billy Breckenridge gay?How does Adrian Toomes hide his earnings from the IRS?What is the state of affairs on Nootka Sound by the end of season 1?How did Tia Dalma acquire Captain Barbossa's body?How is one “Deemed Worthy”, to acquire the Greatsword “Dawn”?How did Karen acquire the handgun?