Do I have a twin with permutated remainders?Tips for golfing in 05AB1ESplit a word into parts with equal scoresChinese Remainder TheoremMaximise the squared differenceIs it a Mersenne Prime?Your Base to 1-2-3-Tribonacci to Binary back to Your BaseIs this number a factorial?Write numbers as a difference of Nth powersConjugate permutationsAm I a Pillai prime?Passwords Strong Against Bishops

cryptic clue: mammal sounds like relative consumer (8)

My colleague's body is amazing

How old can references or sources in a thesis be?

"which" command doesn't work / path of Safari?

What are these boxed doors outside store fronts in New York?

How is it possible for user's password to be changed after storage was encrypted? (on OS X, Android)

What does "enim et" mean?

How do I create uniquely male characters?

Chess with symmetric move-square

Are white and non-white police officers equally likely to kill black suspects?

If Manufacturer spice model and Datasheet give different values which should I use?

Is it legal to have the "// (c) 2019 John Smith" header in all files when there are hundreds of contributors?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

Showing the closure of a compact subset need not be compact

Is it possible to do 50 km distance without any previous training?

Example of a relative pronoun

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Why don't electron-positron collisions release infinite energy?

Could a US political party gain complete control over the government by removing checks & balances?

How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?

How do you conduct xenoanthropology after first contact?

Does the radius of the Spirit Guardians spell depend on the size of the caster?

Is it possible to make sharp wind that can cut stuff from afar?

Why is an old chain unsafe?



Do I have a twin with permutated remainders?


Tips for golfing in 05AB1ESplit a word into parts with equal scoresChinese Remainder TheoremMaximise the squared differenceIs it a Mersenne Prime?Your Base to 1-2-3-Tribonacci to Binary back to Your BaseIs this number a factorial?Write numbers as a difference of Nth powersConjugate permutationsAm I a Pillai prime?Passwords Strong Against Bishops













17












$begingroup$


We define $R_n$ as the list of remainders of the Euclidean division of $n$ by $2$, $3$, $5$ and $7$.



Given an integer $nge0$, you have to figure out if there exists an integer $0<k<210$ such that $R_n+k$ is a permutation of $R_n$.



Examples



The criterion is met for $n=8$, because:



  • we have $R_8=(0,2,3,1)$

  • for $k=44$, we have $R_n+k=R_52=(0,1,2,3)$, which is a permutation of $R_8$

The criterion is not met for $n=48$, because:



  • we have $R_48=(0,0,3,6)$

  • the smallest integer $k>0$ such that $R_n+k$ is a permutation of $R_48$ is $k=210$ (leading to $R_258=(0,0,3,6)$ as well)

Rules



  • You may either output a truthy value if $k$ exists and a falsy value otherwise, or two distinct and consistent values of your choice.

  • This is code-golf.

Hint




Do you really need to compute $k$? Well, maybe. Or maybe not.




Test cases



Some values of $n$ for which $k$ exists:



3, 4, 5, 8, 30, 100, 200, 2019


Some values of $n$ for which $k$ does not exist:



0, 1, 2, 13, 19, 48, 210, 1999









share|improve this question









$endgroup$
















    17












    $begingroup$


    We define $R_n$ as the list of remainders of the Euclidean division of $n$ by $2$, $3$, $5$ and $7$.



    Given an integer $nge0$, you have to figure out if there exists an integer $0<k<210$ such that $R_n+k$ is a permutation of $R_n$.



    Examples



    The criterion is met for $n=8$, because:



    • we have $R_8=(0,2,3,1)$

    • for $k=44$, we have $R_n+k=R_52=(0,1,2,3)$, which is a permutation of $R_8$

    The criterion is not met for $n=48$, because:



    • we have $R_48=(0,0,3,6)$

    • the smallest integer $k>0$ such that $R_n+k$ is a permutation of $R_48$ is $k=210$ (leading to $R_258=(0,0,3,6)$ as well)

    Rules



    • You may either output a truthy value if $k$ exists and a falsy value otherwise, or two distinct and consistent values of your choice.

    • This is code-golf.

    Hint




    Do you really need to compute $k$? Well, maybe. Or maybe not.




    Test cases



    Some values of $n$ for which $k$ exists:



    3, 4, 5, 8, 30, 100, 200, 2019


    Some values of $n$ for which $k$ does not exist:



    0, 1, 2, 13, 19, 48, 210, 1999









    share|improve this question









    $endgroup$














      17












      17








      17





      $begingroup$


      We define $R_n$ as the list of remainders of the Euclidean division of $n$ by $2$, $3$, $5$ and $7$.



      Given an integer $nge0$, you have to figure out if there exists an integer $0<k<210$ such that $R_n+k$ is a permutation of $R_n$.



      Examples



      The criterion is met for $n=8$, because:



      • we have $R_8=(0,2,3,1)$

      • for $k=44$, we have $R_n+k=R_52=(0,1,2,3)$, which is a permutation of $R_8$

      The criterion is not met for $n=48$, because:



      • we have $R_48=(0,0,3,6)$

      • the smallest integer $k>0$ such that $R_n+k$ is a permutation of $R_48$ is $k=210$ (leading to $R_258=(0,0,3,6)$ as well)

      Rules



      • You may either output a truthy value if $k$ exists and a falsy value otherwise, or two distinct and consistent values of your choice.

      • This is code-golf.

      Hint




      Do you really need to compute $k$? Well, maybe. Or maybe not.




      Test cases



      Some values of $n$ for which $k$ exists:



      3, 4, 5, 8, 30, 100, 200, 2019


      Some values of $n$ for which $k$ does not exist:



      0, 1, 2, 13, 19, 48, 210, 1999









      share|improve this question









      $endgroup$




      We define $R_n$ as the list of remainders of the Euclidean division of $n$ by $2$, $3$, $5$ and $7$.



      Given an integer $nge0$, you have to figure out if there exists an integer $0<k<210$ such that $R_n+k$ is a permutation of $R_n$.



      Examples



      The criterion is met for $n=8$, because:



      • we have $R_8=(0,2,3,1)$

      • for $k=44$, we have $R_n+k=R_52=(0,1,2,3)$, which is a permutation of $R_8$

      The criterion is not met for $n=48$, because:



      • we have $R_48=(0,0,3,6)$

      • the smallest integer $k>0$ such that $R_n+k$ is a permutation of $R_48$ is $k=210$ (leading to $R_258=(0,0,3,6)$ as well)

      Rules



      • You may either output a truthy value if $k$ exists and a falsy value otherwise, or two distinct and consistent values of your choice.

      • This is code-golf.

      Hint




      Do you really need to compute $k$? Well, maybe. Or maybe not.




      Test cases



      Some values of $n$ for which $k$ exists:



      3, 4, 5, 8, 30, 100, 200, 2019


      Some values of $n$ for which $k$ does not exist:



      0, 1, 2, 13, 19, 48, 210, 1999






      code-golf decision-problem number-theory






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 4 at 15:36









      ArnauldArnauld

      80.6k797333




      80.6k797333




















          16 Answers
          16






          active

          oldest

          votes


















          20












          $begingroup$


          R, 63 59 bytes





          s=scan()%%c(2,3,5,7);i=which(s<c(0,2,3,5));any(s[i]-s[i-1])


          Try it online!



          -4 bytes thanks to Giuseppe



          (The explanation contains a spoiler as to how to solve the problem without computing $k$.)



          Explanation:
          Let $s$ be the list of remainders. Note the constraint that s[1]<2, s[2]<3, s[3]<5 and s[4]<7. By the Chinese Remainder Theorem, there exists a $k$ iff there is a permutation of $s$, distinct from $s$, which verifies the constraint. In practice, this will be verified if one of the following conditions is verified:



          • s[2]<2 and s[2]!=s[1]

          • s[3]<3 and s[3]!=s[2]

          • s[4]<5 and s[4]!=s[3]

          The code can probably be golfed further.






          share|improve this answer










          New contributor




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






          $endgroup$












          • $begingroup$
            Could you explain why the permutation is necessarily distinct from $s$?
            $endgroup$
            – dfeuer
            2 days ago







          • 1




            $begingroup$
            @dfeuer It is a consequence of the Chinese Remainder Theorem; I added a link. If two integers have the same remainders modulo 2, 3, 5 and 7 (without a permutation), then the two integers are equal modulo 2*3*5*7=210.
            $endgroup$
            – Robin Ryder
            2 days ago


















          8












          $begingroup$


          Haskell, 69 bytes



          Based on the Chinese remainder theorem





          m=[2,3,5,7]
          f x|s<-mod x<$>m=or[m!!a>b|a<-[0..2],b<-drop a s,s!!a/=b]


          Try it online!






          share|improve this answer









          $endgroup$








          • 4




            $begingroup$
            Actually, my working title for this challenge was "Do I have a Chinese twin?" :)
            $endgroup$
            – Arnauld
            2 days ago


















          5












          $begingroup$


          Perl 6, 64 61 59 43 bytes





          map($!=(*X%2,3,5,7).Bag,^209+$_+1)∋.&$!


          Try it online!



          -16 thanks to @Jo King






          share|improve this answer











          $endgroup$




















            4












            $begingroup$


            Python 2, 41 bytes





            lambda n:n%5!=n%7<5or n%3!=n%5<3or-~n%6/4


            Try it online!



            Uses the same characterization as Robin Ryder. The check n%2!=n%3<2 is shortened to -~n%6/4. Writing out the three conditions turned out shorter than writing a general one:



            46 bytes





            lambda n:any(n%p!=n%(p+1|1)<p for p in[2,3,5])


            Try it online!






            share|improve this answer











            $endgroup$




















              4












              $begingroup$


              Haskell, 47 bytes





              g.mod
              g r|let p?q=r p/=r q&&r q<p=2?3||3?5||5?7


              Try it online!






              share|improve this answer











              $endgroup$












              • $begingroup$
                Can you explain?
                $endgroup$
                – dfeuer
                2 days ago






              • 1




                $begingroup$
                @dfeuer It's using Robin Ryder's method.
                $endgroup$
                – Ørjan Johansen
                2 days ago


















              4












              $begingroup$


              C# (Visual C# Interactive Compiler), 125 42 38 36 bytes





              n=>n%7<5&5<n%35|n%5<3&3<n%15|-~n%6>3


              Direct port of @xnor's answer, which is based off of @RobinRyder's solution.



              Saved 4 bytes thanks to @Ørjan Johansen!



              Saved 2 more thanks to @Arnauld!



              Try it online!






              share|improve this answer











              $endgroup$








              • 1




                $begingroup$
                I found a variation that only ties for xnor's languages but helps for this: 38 bytes
                $endgroup$
                – Ørjan Johansen
                Apr 5 at 6:04






              • 1




                $begingroup$
                Isn't -~n%6/4>0 just -~n%6>3?
                $endgroup$
                – Arnauld
                yesterday










              • $begingroup$
                BTW, this is a JavaScript polyglot.
                $endgroup$
                – Arnauld
                22 hours ago


















              3












              $begingroup$


              Wolfram Language (Mathematica), 67 bytes



              !FreeQ[Sort/@Table[R[#+k],k,209],Sort@R@#]&
              R@n_:=n~Mod~2,3,5,7


              Try it online!






              share|improve this answer











              $endgroup$




















                2












                $begingroup$


                Ruby, 54 bytes





                ->n[2,3,5,7].each_cons(2).any?n%l!=n%h&&n%h<l


                Try it online!



                Uses Robin Ryder's clever solution.






                share|improve this answer









                $endgroup$




















                  2












                  $begingroup$


                  Java (JDK), 38 bytes





                  n->n%7<5&5<n%35|n%5<3&3<n%15|-~n%6/4>0


                  Try it online!



                  Credits



                  • Port of xnor's solution, improved by Ørjan Johansen.





                  share|improve this answer









                  $endgroup$




















                    1












                    $begingroup$


                    R, 72 bytes





                    n=scan();b=c(2,3,5,7);for(i in n+1:209)F=F|all(sort(n%%b)==sort(i%%b));F


                    Try it online!






                    share|improve this answer









                    $endgroup$




















                      1












                      $begingroup$


                      Jelly, 15 bytes



                      8ÆR©PḶ+%Ṣ¥€®ċḢ$


                      Try it online!



                      I’m sure there’s a golfier answer. I’ve interpreted a truthy value as being anything that isn’t zero, so here it’s the number of possible values of k. If it needs to be two distinct values that costs me a further byte.






                      share|improve this answer









                      $endgroup$








                      • 1




                        $begingroup$
                        All good regarding truthy vs falsey. Using the meta agreed definition of truthy and falsey (effectively "what does the language's if-else construct do if there is one) zero is falsey and non-zeros are truthy (? is the if-else construct in Jelly; for some languages it's a harder question).
                        $endgroup$
                        – Jonathan Allan
                        Apr 4 at 18:08










                      • $begingroup$
                        Oh, and you could get distinct values for no cost with Ḣe$ if you wanted :)
                        $endgroup$
                        – Jonathan Allan
                        Apr 4 at 18:11










                      • $begingroup$
                        @JonathanAllan yes of course, thanks. :)
                        $endgroup$
                        – Nick Kennedy
                        Apr 4 at 18:12



















                      1












                      $begingroup$


                      PHP, 81 78 72 bytes





                      while($y<3)if($argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u)die(T);


                      A riff on @Robin Ryder's answer. Input is via STDIN, output is 'T' if truthy, and empty '' if falsy.



                      $ echo 3|php -nF euc.php
                      T
                      $ echo 5|php -nF euc.php
                      T
                      $ echo 2019|php -nF euc.php
                      T
                      $ echo 0|php -nF euc.php

                      $ echo 2|php -nF euc.php

                      $ echo 1999|php -nF euc.php


                      Try it online!



                      Or 73 bytes with 1 or 0 response



                      while($y<3)$r|=$argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u;echo$r;



                      $ echo 2019|php -nF euc.php
                      1
                      $ echo 1999|php -nF euc.php
                      0


                      Try it online (all test cases)!



                      Original answer, 133 127 bytes



                      function($n)while(++$k<210)if(($r=function($n)foreach([2,3,5,7]as$d)$o[]=$n%$d;sort($o);return$o;)($n+$k)==$r($n))return 1;


                      Try it online!






                      share|improve this answer











                      $endgroup$




















                        1












                        $begingroup$


                        Python 3, 69 bytes





                        lambda x:int('4LR2991ODO5GS2974QWH22YTLL3E3I6TDADQG87I0',36)&1<<x%210


                        Try it online!



                        Hardcoded






                        share|improve this answer









                        $endgroup$




















                          1












                          $begingroup$


                          05AB1E, 16 bytes



                          Ƶ.L+ε‚ε4Åp%Ë}à


                          Try it online or verify all test cases.



                          Explanation:





                          Ƶ.L # Create a list in the range [1,209] (which is k)
                          + # Add the (implicit) input to each (which is n+k)
                          ε # Map each value to:
                          ‚ # Pair it with the (implicit) input
                          ε # Map both to:
                          4Åp # Get the first 4 primes: [2,3,5,7]
                          % # Modulo the current number by each of these four (now we have R_n and R_n+k)
                          # Sort the list
                          Ë # After the inner map: check if both sorted lists are equal
                          }à # After the outer map: check if any are truthy by taking the maximum
                          # (which is output implicitly as result)


                          See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ. is 209.






                          share|improve this answer









                          $endgroup$




















                            1












                            $begingroup$


                            J, 40 bytes



                            1 e.(>:+i.@209)-:&(/:~)&(2 3 5 7&|"1 0)]


                            Try it online!



                            Brute force...






                            share|improve this answer









                            $endgroup$




















                              1












                              $begingroup$


                              Wolfram Language (Mathematica), 56 bytes



                              Or@@(Min[s-#]>0&/@Rest@Permutations@Mod[#,s=2,3,5,7])&


                              Try it online!



                              Finds all non-identity permutations of the remainders of the input modulo 2, 3, 5, 7, and checks if any of them are below 2,3,5,7 in each coordinate. Note that Or@@ is False.






                              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%2f182669%2fdo-i-have-a-twin-with-permutated-remainders%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown

























                                16 Answers
                                16






                                active

                                oldest

                                votes








                                16 Answers
                                16






                                active

                                oldest

                                votes









                                active

                                oldest

                                votes






                                active

                                oldest

                                votes









                                20












                                $begingroup$


                                R, 63 59 bytes





                                s=scan()%%c(2,3,5,7);i=which(s<c(0,2,3,5));any(s[i]-s[i-1])


                                Try it online!



                                -4 bytes thanks to Giuseppe



                                (The explanation contains a spoiler as to how to solve the problem without computing $k$.)



                                Explanation:
                                Let $s$ be the list of remainders. Note the constraint that s[1]<2, s[2]<3, s[3]<5 and s[4]<7. By the Chinese Remainder Theorem, there exists a $k$ iff there is a permutation of $s$, distinct from $s$, which verifies the constraint. In practice, this will be verified if one of the following conditions is verified:



                                • s[2]<2 and s[2]!=s[1]

                                • s[3]<3 and s[3]!=s[2]

                                • s[4]<5 and s[4]!=s[3]

                                The code can probably be golfed further.






                                share|improve this answer










                                New contributor




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






                                $endgroup$












                                • $begingroup$
                                  Could you explain why the permutation is necessarily distinct from $s$?
                                  $endgroup$
                                  – dfeuer
                                  2 days ago







                                • 1




                                  $begingroup$
                                  @dfeuer It is a consequence of the Chinese Remainder Theorem; I added a link. If two integers have the same remainders modulo 2, 3, 5 and 7 (without a permutation), then the two integers are equal modulo 2*3*5*7=210.
                                  $endgroup$
                                  – Robin Ryder
                                  2 days ago















                                20












                                $begingroup$


                                R, 63 59 bytes





                                s=scan()%%c(2,3,5,7);i=which(s<c(0,2,3,5));any(s[i]-s[i-1])


                                Try it online!



                                -4 bytes thanks to Giuseppe



                                (The explanation contains a spoiler as to how to solve the problem without computing $k$.)



                                Explanation:
                                Let $s$ be the list of remainders. Note the constraint that s[1]<2, s[2]<3, s[3]<5 and s[4]<7. By the Chinese Remainder Theorem, there exists a $k$ iff there is a permutation of $s$, distinct from $s$, which verifies the constraint. In practice, this will be verified if one of the following conditions is verified:



                                • s[2]<2 and s[2]!=s[1]

                                • s[3]<3 and s[3]!=s[2]

                                • s[4]<5 and s[4]!=s[3]

                                The code can probably be golfed further.






                                share|improve this answer










                                New contributor




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






                                $endgroup$












                                • $begingroup$
                                  Could you explain why the permutation is necessarily distinct from $s$?
                                  $endgroup$
                                  – dfeuer
                                  2 days ago







                                • 1




                                  $begingroup$
                                  @dfeuer It is a consequence of the Chinese Remainder Theorem; I added a link. If two integers have the same remainders modulo 2, 3, 5 and 7 (without a permutation), then the two integers are equal modulo 2*3*5*7=210.
                                  $endgroup$
                                  – Robin Ryder
                                  2 days ago













                                20












                                20








                                20





                                $begingroup$


                                R, 63 59 bytes





                                s=scan()%%c(2,3,5,7);i=which(s<c(0,2,3,5));any(s[i]-s[i-1])


                                Try it online!



                                -4 bytes thanks to Giuseppe



                                (The explanation contains a spoiler as to how to solve the problem without computing $k$.)



                                Explanation:
                                Let $s$ be the list of remainders. Note the constraint that s[1]<2, s[2]<3, s[3]<5 and s[4]<7. By the Chinese Remainder Theorem, there exists a $k$ iff there is a permutation of $s$, distinct from $s$, which verifies the constraint. In practice, this will be verified if one of the following conditions is verified:



                                • s[2]<2 and s[2]!=s[1]

                                • s[3]<3 and s[3]!=s[2]

                                • s[4]<5 and s[4]!=s[3]

                                The code can probably be golfed further.






                                share|improve this answer










                                New contributor




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






                                $endgroup$




                                R, 63 59 bytes





                                s=scan()%%c(2,3,5,7);i=which(s<c(0,2,3,5));any(s[i]-s[i-1])


                                Try it online!



                                -4 bytes thanks to Giuseppe



                                (The explanation contains a spoiler as to how to solve the problem without computing $k$.)



                                Explanation:
                                Let $s$ be the list of remainders. Note the constraint that s[1]<2, s[2]<3, s[3]<5 and s[4]<7. By the Chinese Remainder Theorem, there exists a $k$ iff there is a permutation of $s$, distinct from $s$, which verifies the constraint. In practice, this will be verified if one of the following conditions is verified:



                                • s[2]<2 and s[2]!=s[1]

                                • s[3]<3 and s[3]!=s[2]

                                • s[4]<5 and s[4]!=s[3]

                                The code can probably be golfed further.







                                share|improve this answer










                                New contributor




                                Robin Ryder 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 answer



                                share|improve this answer








                                edited yesterday





















                                New contributor




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









                                answered Apr 4 at 17:00









                                Robin RyderRobin Ryder

                                5417




                                5417




                                New contributor




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





                                New contributor





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






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











                                • $begingroup$
                                  Could you explain why the permutation is necessarily distinct from $s$?
                                  $endgroup$
                                  – dfeuer
                                  2 days ago







                                • 1




                                  $begingroup$
                                  @dfeuer It is a consequence of the Chinese Remainder Theorem; I added a link. If two integers have the same remainders modulo 2, 3, 5 and 7 (without a permutation), then the two integers are equal modulo 2*3*5*7=210.
                                  $endgroup$
                                  – Robin Ryder
                                  2 days ago
















                                • $begingroup$
                                  Could you explain why the permutation is necessarily distinct from $s$?
                                  $endgroup$
                                  – dfeuer
                                  2 days ago







                                • 1




                                  $begingroup$
                                  @dfeuer It is a consequence of the Chinese Remainder Theorem; I added a link. If two integers have the same remainders modulo 2, 3, 5 and 7 (without a permutation), then the two integers are equal modulo 2*3*5*7=210.
                                  $endgroup$
                                  – Robin Ryder
                                  2 days ago















                                $begingroup$
                                Could you explain why the permutation is necessarily distinct from $s$?
                                $endgroup$
                                – dfeuer
                                2 days ago





                                $begingroup$
                                Could you explain why the permutation is necessarily distinct from $s$?
                                $endgroup$
                                – dfeuer
                                2 days ago





                                1




                                1




                                $begingroup$
                                @dfeuer It is a consequence of the Chinese Remainder Theorem; I added a link. If two integers have the same remainders modulo 2, 3, 5 and 7 (without a permutation), then the two integers are equal modulo 2*3*5*7=210.
                                $endgroup$
                                – Robin Ryder
                                2 days ago




                                $begingroup$
                                @dfeuer It is a consequence of the Chinese Remainder Theorem; I added a link. If two integers have the same remainders modulo 2, 3, 5 and 7 (without a permutation), then the two integers are equal modulo 2*3*5*7=210.
                                $endgroup$
                                – Robin Ryder
                                2 days ago











                                8












                                $begingroup$


                                Haskell, 69 bytes



                                Based on the Chinese remainder theorem





                                m=[2,3,5,7]
                                f x|s<-mod x<$>m=or[m!!a>b|a<-[0..2],b<-drop a s,s!!a/=b]


                                Try it online!






                                share|improve this answer









                                $endgroup$








                                • 4




                                  $begingroup$
                                  Actually, my working title for this challenge was "Do I have a Chinese twin?" :)
                                  $endgroup$
                                  – Arnauld
                                  2 days ago















                                8












                                $begingroup$


                                Haskell, 69 bytes



                                Based on the Chinese remainder theorem





                                m=[2,3,5,7]
                                f x|s<-mod x<$>m=or[m!!a>b|a<-[0..2],b<-drop a s,s!!a/=b]


                                Try it online!






                                share|improve this answer









                                $endgroup$








                                • 4




                                  $begingroup$
                                  Actually, my working title for this challenge was "Do I have a Chinese twin?" :)
                                  $endgroup$
                                  – Arnauld
                                  2 days ago













                                8












                                8








                                8





                                $begingroup$


                                Haskell, 69 bytes



                                Based on the Chinese remainder theorem





                                m=[2,3,5,7]
                                f x|s<-mod x<$>m=or[m!!a>b|a<-[0..2],b<-drop a s,s!!a/=b]


                                Try it online!






                                share|improve this answer









                                $endgroup$




                                Haskell, 69 bytes



                                Based on the Chinese remainder theorem





                                m=[2,3,5,7]
                                f x|s<-mod x<$>m=or[m!!a>b|a<-[0..2],b<-drop a s,s!!a/=b]


                                Try it online!







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Apr 4 at 16:45









                                H.PWizH.PWiz

                                10.3k21351




                                10.3k21351







                                • 4




                                  $begingroup$
                                  Actually, my working title for this challenge was "Do I have a Chinese twin?" :)
                                  $endgroup$
                                  – Arnauld
                                  2 days ago












                                • 4




                                  $begingroup$
                                  Actually, my working title for this challenge was "Do I have a Chinese twin?" :)
                                  $endgroup$
                                  – Arnauld
                                  2 days ago







                                4




                                4




                                $begingroup$
                                Actually, my working title for this challenge was "Do I have a Chinese twin?" :)
                                $endgroup$
                                – Arnauld
                                2 days ago




                                $begingroup$
                                Actually, my working title for this challenge was "Do I have a Chinese twin?" :)
                                $endgroup$
                                – Arnauld
                                2 days ago











                                5












                                $begingroup$


                                Perl 6, 64 61 59 43 bytes





                                map($!=(*X%2,3,5,7).Bag,^209+$_+1)∋.&$!


                                Try it online!



                                -16 thanks to @Jo King






                                share|improve this answer











                                $endgroup$

















                                  5












                                  $begingroup$


                                  Perl 6, 64 61 59 43 bytes





                                  map($!=(*X%2,3,5,7).Bag,^209+$_+1)∋.&$!


                                  Try it online!



                                  -16 thanks to @Jo King






                                  share|improve this answer











                                  $endgroup$















                                    5












                                    5








                                    5





                                    $begingroup$


                                    Perl 6, 64 61 59 43 bytes





                                    map($!=(*X%2,3,5,7).Bag,^209+$_+1)∋.&$!


                                    Try it online!



                                    -16 thanks to @Jo King






                                    share|improve this answer











                                    $endgroup$




                                    Perl 6, 64 61 59 43 bytes





                                    map($!=(*X%2,3,5,7).Bag,^209+$_+1)∋.&$!


                                    Try it online!



                                    -16 thanks to @Jo King







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 2 days ago

























                                    answered Apr 4 at 16:20









                                    VenVen

                                    2,55511223




                                    2,55511223





















                                        4












                                        $begingroup$


                                        Python 2, 41 bytes





                                        lambda n:n%5!=n%7<5or n%3!=n%5<3or-~n%6/4


                                        Try it online!



                                        Uses the same characterization as Robin Ryder. The check n%2!=n%3<2 is shortened to -~n%6/4. Writing out the three conditions turned out shorter than writing a general one:



                                        46 bytes





                                        lambda n:any(n%p!=n%(p+1|1)<p for p in[2,3,5])


                                        Try it online!






                                        share|improve this answer











                                        $endgroup$

















                                          4












                                          $begingroup$


                                          Python 2, 41 bytes





                                          lambda n:n%5!=n%7<5or n%3!=n%5<3or-~n%6/4


                                          Try it online!



                                          Uses the same characterization as Robin Ryder. The check n%2!=n%3<2 is shortened to -~n%6/4. Writing out the three conditions turned out shorter than writing a general one:



                                          46 bytes





                                          lambda n:any(n%p!=n%(p+1|1)<p for p in[2,3,5])


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$















                                            4












                                            4








                                            4





                                            $begingroup$


                                            Python 2, 41 bytes





                                            lambda n:n%5!=n%7<5or n%3!=n%5<3or-~n%6/4


                                            Try it online!



                                            Uses the same characterization as Robin Ryder. The check n%2!=n%3<2 is shortened to -~n%6/4. Writing out the three conditions turned out shorter than writing a general one:



                                            46 bytes





                                            lambda n:any(n%p!=n%(p+1|1)<p for p in[2,3,5])


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$




                                            Python 2, 41 bytes





                                            lambda n:n%5!=n%7<5or n%3!=n%5<3or-~n%6/4


                                            Try it online!



                                            Uses the same characterization as Robin Ryder. The check n%2!=n%3<2 is shortened to -~n%6/4. Writing out the three conditions turned out shorter than writing a general one:



                                            46 bytes





                                            lambda n:any(n%p!=n%(p+1|1)<p for p in[2,3,5])


                                            Try it online!







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Apr 5 at 4:16

























                                            answered Apr 5 at 0:34









                                            xnorxnor

                                            93.4k18190448




                                            93.4k18190448





















                                                4












                                                $begingroup$


                                                Haskell, 47 bytes





                                                g.mod
                                                g r|let p?q=r p/=r q&&r q<p=2?3||3?5||5?7


                                                Try it online!






                                                share|improve this answer











                                                $endgroup$












                                                • $begingroup$
                                                  Can you explain?
                                                  $endgroup$
                                                  – dfeuer
                                                  2 days ago






                                                • 1




                                                  $begingroup$
                                                  @dfeuer It's using Robin Ryder's method.
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  2 days ago















                                                4












                                                $begingroup$


                                                Haskell, 47 bytes





                                                g.mod
                                                g r|let p?q=r p/=r q&&r q<p=2?3||3?5||5?7


                                                Try it online!






                                                share|improve this answer











                                                $endgroup$












                                                • $begingroup$
                                                  Can you explain?
                                                  $endgroup$
                                                  – dfeuer
                                                  2 days ago






                                                • 1




                                                  $begingroup$
                                                  @dfeuer It's using Robin Ryder's method.
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  2 days ago













                                                4












                                                4








                                                4





                                                $begingroup$


                                                Haskell, 47 bytes





                                                g.mod
                                                g r|let p?q=r p/=r q&&r q<p=2?3||3?5||5?7


                                                Try it online!






                                                share|improve this answer











                                                $endgroup$




                                                Haskell, 47 bytes





                                                g.mod
                                                g r|let p?q=r p/=r q&&r q<p=2?3||3?5||5?7


                                                Try it online!







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited Apr 5 at 5:27

























                                                answered Apr 5 at 5:19









                                                xnorxnor

                                                93.4k18190448




                                                93.4k18190448











                                                • $begingroup$
                                                  Can you explain?
                                                  $endgroup$
                                                  – dfeuer
                                                  2 days ago






                                                • 1




                                                  $begingroup$
                                                  @dfeuer It's using Robin Ryder's method.
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  2 days ago
















                                                • $begingroup$
                                                  Can you explain?
                                                  $endgroup$
                                                  – dfeuer
                                                  2 days ago






                                                • 1




                                                  $begingroup$
                                                  @dfeuer It's using Robin Ryder's method.
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  2 days ago















                                                $begingroup$
                                                Can you explain?
                                                $endgroup$
                                                – dfeuer
                                                2 days ago




                                                $begingroup$
                                                Can you explain?
                                                $endgroup$
                                                – dfeuer
                                                2 days ago




                                                1




                                                1




                                                $begingroup$
                                                @dfeuer It's using Robin Ryder's method.
                                                $endgroup$
                                                – Ørjan Johansen
                                                2 days ago




                                                $begingroup$
                                                @dfeuer It's using Robin Ryder's method.
                                                $endgroup$
                                                – Ørjan Johansen
                                                2 days ago











                                                4












                                                $begingroup$


                                                C# (Visual C# Interactive Compiler), 125 42 38 36 bytes





                                                n=>n%7<5&5<n%35|n%5<3&3<n%15|-~n%6>3


                                                Direct port of @xnor's answer, which is based off of @RobinRyder's solution.



                                                Saved 4 bytes thanks to @Ørjan Johansen!



                                                Saved 2 more thanks to @Arnauld!



                                                Try it online!






                                                share|improve this answer











                                                $endgroup$








                                                • 1




                                                  $begingroup$
                                                  I found a variation that only ties for xnor's languages but helps for this: 38 bytes
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  Apr 5 at 6:04






                                                • 1




                                                  $begingroup$
                                                  Isn't -~n%6/4>0 just -~n%6>3?
                                                  $endgroup$
                                                  – Arnauld
                                                  yesterday










                                                • $begingroup$
                                                  BTW, this is a JavaScript polyglot.
                                                  $endgroup$
                                                  – Arnauld
                                                  22 hours ago















                                                4












                                                $begingroup$


                                                C# (Visual C# Interactive Compiler), 125 42 38 36 bytes





                                                n=>n%7<5&5<n%35|n%5<3&3<n%15|-~n%6>3


                                                Direct port of @xnor's answer, which is based off of @RobinRyder's solution.



                                                Saved 4 bytes thanks to @Ørjan Johansen!



                                                Saved 2 more thanks to @Arnauld!



                                                Try it online!






                                                share|improve this answer











                                                $endgroup$








                                                • 1




                                                  $begingroup$
                                                  I found a variation that only ties for xnor's languages but helps for this: 38 bytes
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  Apr 5 at 6:04






                                                • 1




                                                  $begingroup$
                                                  Isn't -~n%6/4>0 just -~n%6>3?
                                                  $endgroup$
                                                  – Arnauld
                                                  yesterday










                                                • $begingroup$
                                                  BTW, this is a JavaScript polyglot.
                                                  $endgroup$
                                                  – Arnauld
                                                  22 hours ago













                                                4












                                                4








                                                4





                                                $begingroup$


                                                C# (Visual C# Interactive Compiler), 125 42 38 36 bytes





                                                n=>n%7<5&5<n%35|n%5<3&3<n%15|-~n%6>3


                                                Direct port of @xnor's answer, which is based off of @RobinRyder's solution.



                                                Saved 4 bytes thanks to @Ørjan Johansen!



                                                Saved 2 more thanks to @Arnauld!



                                                Try it online!






                                                share|improve this answer











                                                $endgroup$




                                                C# (Visual C# Interactive Compiler), 125 42 38 36 bytes





                                                n=>n%7<5&5<n%35|n%5<3&3<n%15|-~n%6>3


                                                Direct port of @xnor's answer, which is based off of @RobinRyder's solution.



                                                Saved 4 bytes thanks to @Ørjan Johansen!



                                                Saved 2 more thanks to @Arnauld!



                                                Try it online!







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited yesterday

























                                                answered Apr 4 at 16:33









                                                Embodiment of IgnoranceEmbodiment of Ignorance

                                                2,838127




                                                2,838127







                                                • 1




                                                  $begingroup$
                                                  I found a variation that only ties for xnor's languages but helps for this: 38 bytes
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  Apr 5 at 6:04






                                                • 1




                                                  $begingroup$
                                                  Isn't -~n%6/4>0 just -~n%6>3?
                                                  $endgroup$
                                                  – Arnauld
                                                  yesterday










                                                • $begingroup$
                                                  BTW, this is a JavaScript polyglot.
                                                  $endgroup$
                                                  – Arnauld
                                                  22 hours ago












                                                • 1




                                                  $begingroup$
                                                  I found a variation that only ties for xnor's languages but helps for this: 38 bytes
                                                  $endgroup$
                                                  – Ørjan Johansen
                                                  Apr 5 at 6:04






                                                • 1




                                                  $begingroup$
                                                  Isn't -~n%6/4>0 just -~n%6>3?
                                                  $endgroup$
                                                  – Arnauld
                                                  yesterday










                                                • $begingroup$
                                                  BTW, this is a JavaScript polyglot.
                                                  $endgroup$
                                                  – Arnauld
                                                  22 hours ago







                                                1




                                                1




                                                $begingroup$
                                                I found a variation that only ties for xnor's languages but helps for this: 38 bytes
                                                $endgroup$
                                                – Ørjan Johansen
                                                Apr 5 at 6:04




                                                $begingroup$
                                                I found a variation that only ties for xnor's languages but helps for this: 38 bytes
                                                $endgroup$
                                                – Ørjan Johansen
                                                Apr 5 at 6:04




                                                1




                                                1




                                                $begingroup$
                                                Isn't -~n%6/4>0 just -~n%6>3?
                                                $endgroup$
                                                – Arnauld
                                                yesterday




                                                $begingroup$
                                                Isn't -~n%6/4>0 just -~n%6>3?
                                                $endgroup$
                                                – Arnauld
                                                yesterday












                                                $begingroup$
                                                BTW, this is a JavaScript polyglot.
                                                $endgroup$
                                                – Arnauld
                                                22 hours ago




                                                $begingroup$
                                                BTW, this is a JavaScript polyglot.
                                                $endgroup$
                                                – Arnauld
                                                22 hours ago











                                                3












                                                $begingroup$


                                                Wolfram Language (Mathematica), 67 bytes



                                                !FreeQ[Sort/@Table[R[#+k],k,209],Sort@R@#]&
                                                R@n_:=n~Mod~2,3,5,7


                                                Try it online!






                                                share|improve this answer











                                                $endgroup$

















                                                  3












                                                  $begingroup$


                                                  Wolfram Language (Mathematica), 67 bytes



                                                  !FreeQ[Sort/@Table[R[#+k],k,209],Sort@R@#]&
                                                  R@n_:=n~Mod~2,3,5,7


                                                  Try it online!






                                                  share|improve this answer











                                                  $endgroup$















                                                    3












                                                    3








                                                    3





                                                    $begingroup$


                                                    Wolfram Language (Mathematica), 67 bytes



                                                    !FreeQ[Sort/@Table[R[#+k],k,209],Sort@R@#]&
                                                    R@n_:=n~Mod~2,3,5,7


                                                    Try it online!






                                                    share|improve this answer











                                                    $endgroup$




                                                    Wolfram Language (Mathematica), 67 bytes



                                                    !FreeQ[Sort/@Table[R[#+k],k,209],Sort@R@#]&
                                                    R@n_:=n~Mod~2,3,5,7


                                                    Try it online!







                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited Apr 4 at 16:00

























                                                    answered Apr 4 at 15:53









                                                    J42161217J42161217

                                                    13.8k21253




                                                    13.8k21253





















                                                        2












                                                        $begingroup$


                                                        Ruby, 54 bytes





                                                        ->n[2,3,5,7].each_cons(2).any?n%l!=n%h&&n%h<l


                                                        Try it online!



                                                        Uses Robin Ryder's clever solution.






                                                        share|improve this answer









                                                        $endgroup$

















                                                          2












                                                          $begingroup$


                                                          Ruby, 54 bytes





                                                          ->n[2,3,5,7].each_cons(2).any?n%l!=n%h&&n%h<l


                                                          Try it online!



                                                          Uses Robin Ryder's clever solution.






                                                          share|improve this answer









                                                          $endgroup$















                                                            2












                                                            2








                                                            2





                                                            $begingroup$


                                                            Ruby, 54 bytes





                                                            ->n[2,3,5,7].each_cons(2).any?n%l!=n%h&&n%h<l


                                                            Try it online!



                                                            Uses Robin Ryder's clever solution.






                                                            share|improve this answer









                                                            $endgroup$




                                                            Ruby, 54 bytes





                                                            ->n[2,3,5,7].each_cons(2).any?n%l!=n%h&&n%h<l


                                                            Try it online!



                                                            Uses Robin Ryder's clever solution.







                                                            share|improve this answer












                                                            share|improve this answer



                                                            share|improve this answer










                                                            answered Apr 4 at 18:59









                                                            histocrathistocrat

                                                            19.2k43173




                                                            19.2k43173





















                                                                2












                                                                $begingroup$


                                                                Java (JDK), 38 bytes





                                                                n->n%7<5&5<n%35|n%5<3&3<n%15|-~n%6/4>0


                                                                Try it online!



                                                                Credits



                                                                • Port of xnor's solution, improved by Ørjan Johansen.





                                                                share|improve this answer









                                                                $endgroup$

















                                                                  2












                                                                  $begingroup$


                                                                  Java (JDK), 38 bytes





                                                                  n->n%7<5&5<n%35|n%5<3&3<n%15|-~n%6/4>0


                                                                  Try it online!



                                                                  Credits



                                                                  • Port of xnor's solution, improved by Ørjan Johansen.





                                                                  share|improve this answer









                                                                  $endgroup$















                                                                    2












                                                                    2








                                                                    2





                                                                    $begingroup$


                                                                    Java (JDK), 38 bytes





                                                                    n->n%7<5&5<n%35|n%5<3&3<n%15|-~n%6/4>0


                                                                    Try it online!



                                                                    Credits



                                                                    • Port of xnor's solution, improved by Ørjan Johansen.





                                                                    share|improve this answer









                                                                    $endgroup$




                                                                    Java (JDK), 38 bytes





                                                                    n->n%7<5&5<n%35|n%5<3&3<n%15|-~n%6/4>0


                                                                    Try it online!



                                                                    Credits



                                                                    • Port of xnor's solution, improved by Ørjan Johansen.






                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered 2 days ago









                                                                    Olivier GrégoireOlivier Grégoire

                                                                    9,39511944




                                                                    9,39511944





















                                                                        1












                                                                        $begingroup$


                                                                        R, 72 bytes





                                                                        n=scan();b=c(2,3,5,7);for(i in n+1:209)F=F|all(sort(n%%b)==sort(i%%b));F


                                                                        Try it online!






                                                                        share|improve this answer









                                                                        $endgroup$

















                                                                          1












                                                                          $begingroup$


                                                                          R, 72 bytes





                                                                          n=scan();b=c(2,3,5,7);for(i in n+1:209)F=F|all(sort(n%%b)==sort(i%%b));F


                                                                          Try it online!






                                                                          share|improve this answer









                                                                          $endgroup$















                                                                            1












                                                                            1








                                                                            1





                                                                            $begingroup$


                                                                            R, 72 bytes





                                                                            n=scan();b=c(2,3,5,7);for(i in n+1:209)F=F|all(sort(n%%b)==sort(i%%b));F


                                                                            Try it online!






                                                                            share|improve this answer









                                                                            $endgroup$




                                                                            R, 72 bytes





                                                                            n=scan();b=c(2,3,5,7);for(i in n+1:209)F=F|all(sort(n%%b)==sort(i%%b));F


                                                                            Try it online!







                                                                            share|improve this answer












                                                                            share|improve this answer



                                                                            share|improve this answer










                                                                            answered Apr 4 at 16:42









                                                                            Aaron HaymanAaron Hayman

                                                                            3516




                                                                            3516





















                                                                                1












                                                                                $begingroup$


                                                                                Jelly, 15 bytes



                                                                                8ÆR©PḶ+%Ṣ¥€®ċḢ$


                                                                                Try it online!



                                                                                I’m sure there’s a golfier answer. I’ve interpreted a truthy value as being anything that isn’t zero, so here it’s the number of possible values of k. If it needs to be two distinct values that costs me a further byte.






                                                                                share|improve this answer









                                                                                $endgroup$








                                                                                • 1




                                                                                  $begingroup$
                                                                                  All good regarding truthy vs falsey. Using the meta agreed definition of truthy and falsey (effectively "what does the language's if-else construct do if there is one) zero is falsey and non-zeros are truthy (? is the if-else construct in Jelly; for some languages it's a harder question).
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:08










                                                                                • $begingroup$
                                                                                  Oh, and you could get distinct values for no cost with Ḣe$ if you wanted :)
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:11










                                                                                • $begingroup$
                                                                                  @JonathanAllan yes of course, thanks. :)
                                                                                  $endgroup$
                                                                                  – Nick Kennedy
                                                                                  Apr 4 at 18:12
















                                                                                1












                                                                                $begingroup$


                                                                                Jelly, 15 bytes



                                                                                8ÆR©PḶ+%Ṣ¥€®ċḢ$


                                                                                Try it online!



                                                                                I’m sure there’s a golfier answer. I’ve interpreted a truthy value as being anything that isn’t zero, so here it’s the number of possible values of k. If it needs to be two distinct values that costs me a further byte.






                                                                                share|improve this answer









                                                                                $endgroup$








                                                                                • 1




                                                                                  $begingroup$
                                                                                  All good regarding truthy vs falsey. Using the meta agreed definition of truthy and falsey (effectively "what does the language's if-else construct do if there is one) zero is falsey and non-zeros are truthy (? is the if-else construct in Jelly; for some languages it's a harder question).
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:08










                                                                                • $begingroup$
                                                                                  Oh, and you could get distinct values for no cost with Ḣe$ if you wanted :)
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:11










                                                                                • $begingroup$
                                                                                  @JonathanAllan yes of course, thanks. :)
                                                                                  $endgroup$
                                                                                  – Nick Kennedy
                                                                                  Apr 4 at 18:12














                                                                                1












                                                                                1








                                                                                1





                                                                                $begingroup$


                                                                                Jelly, 15 bytes



                                                                                8ÆR©PḶ+%Ṣ¥€®ċḢ$


                                                                                Try it online!



                                                                                I’m sure there’s a golfier answer. I’ve interpreted a truthy value as being anything that isn’t zero, so here it’s the number of possible values of k. If it needs to be two distinct values that costs me a further byte.






                                                                                share|improve this answer









                                                                                $endgroup$




                                                                                Jelly, 15 bytes



                                                                                8ÆR©PḶ+%Ṣ¥€®ċḢ$


                                                                                Try it online!



                                                                                I’m sure there’s a golfier answer. I’ve interpreted a truthy value as being anything that isn’t zero, so here it’s the number of possible values of k. If it needs to be two distinct values that costs me a further byte.







                                                                                share|improve this answer












                                                                                share|improve this answer



                                                                                share|improve this answer










                                                                                answered Apr 4 at 17:59









                                                                                Nick KennedyNick Kennedy

                                                                                1,34649




                                                                                1,34649







                                                                                • 1




                                                                                  $begingroup$
                                                                                  All good regarding truthy vs falsey. Using the meta agreed definition of truthy and falsey (effectively "what does the language's if-else construct do if there is one) zero is falsey and non-zeros are truthy (? is the if-else construct in Jelly; for some languages it's a harder question).
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:08










                                                                                • $begingroup$
                                                                                  Oh, and you could get distinct values for no cost with Ḣe$ if you wanted :)
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:11










                                                                                • $begingroup$
                                                                                  @JonathanAllan yes of course, thanks. :)
                                                                                  $endgroup$
                                                                                  – Nick Kennedy
                                                                                  Apr 4 at 18:12













                                                                                • 1




                                                                                  $begingroup$
                                                                                  All good regarding truthy vs falsey. Using the meta agreed definition of truthy and falsey (effectively "what does the language's if-else construct do if there is one) zero is falsey and non-zeros are truthy (? is the if-else construct in Jelly; for some languages it's a harder question).
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:08










                                                                                • $begingroup$
                                                                                  Oh, and you could get distinct values for no cost with Ḣe$ if you wanted :)
                                                                                  $endgroup$
                                                                                  – Jonathan Allan
                                                                                  Apr 4 at 18:11










                                                                                • $begingroup$
                                                                                  @JonathanAllan yes of course, thanks. :)
                                                                                  $endgroup$
                                                                                  – Nick Kennedy
                                                                                  Apr 4 at 18:12








                                                                                1




                                                                                1




                                                                                $begingroup$
                                                                                All good regarding truthy vs falsey. Using the meta agreed definition of truthy and falsey (effectively "what does the language's if-else construct do if there is one) zero is falsey and non-zeros are truthy (? is the if-else construct in Jelly; for some languages it's a harder question).
                                                                                $endgroup$
                                                                                – Jonathan Allan
                                                                                Apr 4 at 18:08




                                                                                $begingroup$
                                                                                All good regarding truthy vs falsey. Using the meta agreed definition of truthy and falsey (effectively "what does the language's if-else construct do if there is one) zero is falsey and non-zeros are truthy (? is the if-else construct in Jelly; for some languages it's a harder question).
                                                                                $endgroup$
                                                                                – Jonathan Allan
                                                                                Apr 4 at 18:08












                                                                                $begingroup$
                                                                                Oh, and you could get distinct values for no cost with Ḣe$ if you wanted :)
                                                                                $endgroup$
                                                                                – Jonathan Allan
                                                                                Apr 4 at 18:11




                                                                                $begingroup$
                                                                                Oh, and you could get distinct values for no cost with Ḣe$ if you wanted :)
                                                                                $endgroup$
                                                                                – Jonathan Allan
                                                                                Apr 4 at 18:11












                                                                                $begingroup$
                                                                                @JonathanAllan yes of course, thanks. :)
                                                                                $endgroup$
                                                                                – Nick Kennedy
                                                                                Apr 4 at 18:12





                                                                                $begingroup$
                                                                                @JonathanAllan yes of course, thanks. :)
                                                                                $endgroup$
                                                                                – Nick Kennedy
                                                                                Apr 4 at 18:12












                                                                                1












                                                                                $begingroup$


                                                                                PHP, 81 78 72 bytes





                                                                                while($y<3)if($argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u)die(T);


                                                                                A riff on @Robin Ryder's answer. Input is via STDIN, output is 'T' if truthy, and empty '' if falsy.



                                                                                $ echo 3|php -nF euc.php
                                                                                T
                                                                                $ echo 5|php -nF euc.php
                                                                                T
                                                                                $ echo 2019|php -nF euc.php
                                                                                T
                                                                                $ echo 0|php -nF euc.php

                                                                                $ echo 2|php -nF euc.php

                                                                                $ echo 1999|php -nF euc.php


                                                                                Try it online!



                                                                                Or 73 bytes with 1 or 0 response



                                                                                while($y<3)$r|=$argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u;echo$r;



                                                                                $ echo 2019|php -nF euc.php
                                                                                1
                                                                                $ echo 1999|php -nF euc.php
                                                                                0


                                                                                Try it online (all test cases)!



                                                                                Original answer, 133 127 bytes



                                                                                function($n)while(++$k<210)if(($r=function($n)foreach([2,3,5,7]as$d)$o[]=$n%$d;sort($o);return$o;)($n+$k)==$r($n))return 1;


                                                                                Try it online!






                                                                                share|improve this answer











                                                                                $endgroup$

















                                                                                  1












                                                                                  $begingroup$


                                                                                  PHP, 81 78 72 bytes





                                                                                  while($y<3)if($argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u)die(T);


                                                                                  A riff on @Robin Ryder's answer. Input is via STDIN, output is 'T' if truthy, and empty '' if falsy.



                                                                                  $ echo 3|php -nF euc.php
                                                                                  T
                                                                                  $ echo 5|php -nF euc.php
                                                                                  T
                                                                                  $ echo 2019|php -nF euc.php
                                                                                  T
                                                                                  $ echo 0|php -nF euc.php

                                                                                  $ echo 2|php -nF euc.php

                                                                                  $ echo 1999|php -nF euc.php


                                                                                  Try it online!



                                                                                  Or 73 bytes with 1 or 0 response



                                                                                  while($y<3)$r|=$argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u;echo$r;



                                                                                  $ echo 2019|php -nF euc.php
                                                                                  1
                                                                                  $ echo 1999|php -nF euc.php
                                                                                  0


                                                                                  Try it online (all test cases)!



                                                                                  Original answer, 133 127 bytes



                                                                                  function($n)while(++$k<210)if(($r=function($n)foreach([2,3,5,7]as$d)$o[]=$n%$d;sort($o);return$o;)($n+$k)==$r($n))return 1;


                                                                                  Try it online!






                                                                                  share|improve this answer











                                                                                  $endgroup$















                                                                                    1












                                                                                    1








                                                                                    1





                                                                                    $begingroup$


                                                                                    PHP, 81 78 72 bytes





                                                                                    while($y<3)if($argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u)die(T);


                                                                                    A riff on @Robin Ryder's answer. Input is via STDIN, output is 'T' if truthy, and empty '' if falsy.



                                                                                    $ echo 3|php -nF euc.php
                                                                                    T
                                                                                    $ echo 5|php -nF euc.php
                                                                                    T
                                                                                    $ echo 2019|php -nF euc.php
                                                                                    T
                                                                                    $ echo 0|php -nF euc.php

                                                                                    $ echo 2|php -nF euc.php

                                                                                    $ echo 1999|php -nF euc.php


                                                                                    Try it online!



                                                                                    Or 73 bytes with 1 or 0 response



                                                                                    while($y<3)$r|=$argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u;echo$r;



                                                                                    $ echo 2019|php -nF euc.php
                                                                                    1
                                                                                    $ echo 1999|php -nF euc.php
                                                                                    0


                                                                                    Try it online (all test cases)!



                                                                                    Original answer, 133 127 bytes



                                                                                    function($n)while(++$k<210)if(($r=function($n)foreach([2,3,5,7]as$d)$o[]=$n%$d;sort($o);return$o;)($n+$k)==$r($n))return 1;


                                                                                    Try it online!






                                                                                    share|improve this answer











                                                                                    $endgroup$




                                                                                    PHP, 81 78 72 bytes





                                                                                    while($y<3)if($argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u)die(T);


                                                                                    A riff on @Robin Ryder's answer. Input is via STDIN, output is 'T' if truthy, and empty '' if falsy.



                                                                                    $ echo 3|php -nF euc.php
                                                                                    T
                                                                                    $ echo 5|php -nF euc.php
                                                                                    T
                                                                                    $ echo 2019|php -nF euc.php
                                                                                    T
                                                                                    $ echo 0|php -nF euc.php

                                                                                    $ echo 2|php -nF euc.php

                                                                                    $ echo 1999|php -nF euc.php


                                                                                    Try it online!



                                                                                    Or 73 bytes with 1 or 0 response



                                                                                    while($y<3)$r|=$argn%($u='235'[$y])!=($b=$argn%'357'[$y++])&$b<$u;echo$r;



                                                                                    $ echo 2019|php -nF euc.php
                                                                                    1
                                                                                    $ echo 1999|php -nF euc.php
                                                                                    0


                                                                                    Try it online (all test cases)!



                                                                                    Original answer, 133 127 bytes



                                                                                    function($n)while(++$k<210)if(($r=function($n)foreach([2,3,5,7]as$d)$o[]=$n%$d;sort($o);return$o;)($n+$k)==$r($n))return 1;


                                                                                    Try it online!







                                                                                    share|improve this answer














                                                                                    share|improve this answer



                                                                                    share|improve this answer








                                                                                    edited Apr 4 at 19:16

























                                                                                    answered Apr 4 at 16:01









                                                                                    gwaughgwaugh

                                                                                    2,0281517




                                                                                    2,0281517





















                                                                                        1












                                                                                        $begingroup$


                                                                                        Python 3, 69 bytes





                                                                                        lambda x:int('4LR2991ODO5GS2974QWH22YTLL3E3I6TDADQG87I0',36)&1<<x%210


                                                                                        Try it online!



                                                                                        Hardcoded






                                                                                        share|improve this answer









                                                                                        $endgroup$

















                                                                                          1












                                                                                          $begingroup$


                                                                                          Python 3, 69 bytes





                                                                                          lambda x:int('4LR2991ODO5GS2974QWH22YTLL3E3I6TDADQG87I0',36)&1<<x%210


                                                                                          Try it online!



                                                                                          Hardcoded






                                                                                          share|improve this answer









                                                                                          $endgroup$















                                                                                            1












                                                                                            1








                                                                                            1





                                                                                            $begingroup$


                                                                                            Python 3, 69 bytes





                                                                                            lambda x:int('4LR2991ODO5GS2974QWH22YTLL3E3I6TDADQG87I0',36)&1<<x%210


                                                                                            Try it online!



                                                                                            Hardcoded






                                                                                            share|improve this answer









                                                                                            $endgroup$




                                                                                            Python 3, 69 bytes





                                                                                            lambda x:int('4LR2991ODO5GS2974QWH22YTLL3E3I6TDADQG87I0',36)&1<<x%210


                                                                                            Try it online!



                                                                                            Hardcoded







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered Apr 4 at 22:17









                                                                                            attinatattinat

                                                                                            4797




                                                                                            4797





















                                                                                                1












                                                                                                $begingroup$


                                                                                                05AB1E, 16 bytes



                                                                                                Ƶ.L+ε‚ε4Åp%Ë}à


                                                                                                Try it online or verify all test cases.



                                                                                                Explanation:





                                                                                                Ƶ.L # Create a list in the range [1,209] (which is k)
                                                                                                + # Add the (implicit) input to each (which is n+k)
                                                                                                ε # Map each value to:
                                                                                                ‚ # Pair it with the (implicit) input
                                                                                                ε # Map both to:
                                                                                                4Åp # Get the first 4 primes: [2,3,5,7]
                                                                                                % # Modulo the current number by each of these four (now we have R_n and R_n+k)
                                                                                                # Sort the list
                                                                                                Ë # After the inner map: check if both sorted lists are equal
                                                                                                }à # After the outer map: check if any are truthy by taking the maximum
                                                                                                # (which is output implicitly as result)


                                                                                                See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ. is 209.






                                                                                                share|improve this answer









                                                                                                $endgroup$

















                                                                                                  1












                                                                                                  $begingroup$


                                                                                                  05AB1E, 16 bytes



                                                                                                  Ƶ.L+ε‚ε4Åp%Ë}à


                                                                                                  Try it online or verify all test cases.



                                                                                                  Explanation:





                                                                                                  Ƶ.L # Create a list in the range [1,209] (which is k)
                                                                                                  + # Add the (implicit) input to each (which is n+k)
                                                                                                  ε # Map each value to:
                                                                                                  ‚ # Pair it with the (implicit) input
                                                                                                  ε # Map both to:
                                                                                                  4Åp # Get the first 4 primes: [2,3,5,7]
                                                                                                  % # Modulo the current number by each of these four (now we have R_n and R_n+k)
                                                                                                  # Sort the list
                                                                                                  Ë # After the inner map: check if both sorted lists are equal
                                                                                                  }à # After the outer map: check if any are truthy by taking the maximum
                                                                                                  # (which is output implicitly as result)


                                                                                                  See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ. is 209.






                                                                                                  share|improve this answer









                                                                                                  $endgroup$















                                                                                                    1












                                                                                                    1








                                                                                                    1





                                                                                                    $begingroup$


                                                                                                    05AB1E, 16 bytes



                                                                                                    Ƶ.L+ε‚ε4Åp%Ë}à


                                                                                                    Try it online or verify all test cases.



                                                                                                    Explanation:





                                                                                                    Ƶ.L # Create a list in the range [1,209] (which is k)
                                                                                                    + # Add the (implicit) input to each (which is n+k)
                                                                                                    ε # Map each value to:
                                                                                                    ‚ # Pair it with the (implicit) input
                                                                                                    ε # Map both to:
                                                                                                    4Åp # Get the first 4 primes: [2,3,5,7]
                                                                                                    % # Modulo the current number by each of these four (now we have R_n and R_n+k)
                                                                                                    # Sort the list
                                                                                                    Ë # After the inner map: check if both sorted lists are equal
                                                                                                    }à # After the outer map: check if any are truthy by taking the maximum
                                                                                                    # (which is output implicitly as result)


                                                                                                    See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ. is 209.






                                                                                                    share|improve this answer









                                                                                                    $endgroup$




                                                                                                    05AB1E, 16 bytes



                                                                                                    Ƶ.L+ε‚ε4Åp%Ë}à


                                                                                                    Try it online or verify all test cases.



                                                                                                    Explanation:





                                                                                                    Ƶ.L # Create a list in the range [1,209] (which is k)
                                                                                                    + # Add the (implicit) input to each (which is n+k)
                                                                                                    ε # Map each value to:
                                                                                                    ‚ # Pair it with the (implicit) input
                                                                                                    ε # Map both to:
                                                                                                    4Åp # Get the first 4 primes: [2,3,5,7]
                                                                                                    % # Modulo the current number by each of these four (now we have R_n and R_n+k)
                                                                                                    # Sort the list
                                                                                                    Ë # After the inner map: check if both sorted lists are equal
                                                                                                    }à # After the outer map: check if any are truthy by taking the maximum
                                                                                                    # (which is output implicitly as result)


                                                                                                    See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ƶ. is 209.







                                                                                                    share|improve this answer












                                                                                                    share|improve this answer



                                                                                                    share|improve this answer










                                                                                                    answered 2 days ago









                                                                                                    Kevin CruijssenKevin Cruijssen

                                                                                                    42.3k570217




                                                                                                    42.3k570217





















                                                                                                        1












                                                                                                        $begingroup$


                                                                                                        J, 40 bytes



                                                                                                        1 e.(>:+i.@209)-:&(/:~)&(2 3 5 7&|"1 0)]


                                                                                                        Try it online!



                                                                                                        Brute force...






                                                                                                        share|improve this answer









                                                                                                        $endgroup$

















                                                                                                          1












                                                                                                          $begingroup$


                                                                                                          J, 40 bytes



                                                                                                          1 e.(>:+i.@209)-:&(/:~)&(2 3 5 7&|"1 0)]


                                                                                                          Try it online!



                                                                                                          Brute force...






                                                                                                          share|improve this answer









                                                                                                          $endgroup$















                                                                                                            1












                                                                                                            1








                                                                                                            1





                                                                                                            $begingroup$


                                                                                                            J, 40 bytes



                                                                                                            1 e.(>:+i.@209)-:&(/:~)&(2 3 5 7&|"1 0)]


                                                                                                            Try it online!



                                                                                                            Brute force...






                                                                                                            share|improve this answer









                                                                                                            $endgroup$




                                                                                                            J, 40 bytes



                                                                                                            1 e.(>:+i.@209)-:&(/:~)&(2 3 5 7&|"1 0)]


                                                                                                            Try it online!



                                                                                                            Brute force...







                                                                                                            share|improve this answer












                                                                                                            share|improve this answer



                                                                                                            share|improve this answer










                                                                                                            answered 2 days ago









                                                                                                            Galen IvanovGalen Ivanov

                                                                                                            7,38211034




                                                                                                            7,38211034





















                                                                                                                1












                                                                                                                $begingroup$


                                                                                                                Wolfram Language (Mathematica), 56 bytes



                                                                                                                Or@@(Min[s-#]>0&/@Rest@Permutations@Mod[#,s=2,3,5,7])&


                                                                                                                Try it online!



                                                                                                                Finds all non-identity permutations of the remainders of the input modulo 2, 3, 5, 7, and checks if any of them are below 2,3,5,7 in each coordinate. Note that Or@@ is False.






                                                                                                                share|improve this answer









                                                                                                                $endgroup$

















                                                                                                                  1












                                                                                                                  $begingroup$


                                                                                                                  Wolfram Language (Mathematica), 56 bytes



                                                                                                                  Or@@(Min[s-#]>0&/@Rest@Permutations@Mod[#,s=2,3,5,7])&


                                                                                                                  Try it online!



                                                                                                                  Finds all non-identity permutations of the remainders of the input modulo 2, 3, 5, 7, and checks if any of them are below 2,3,5,7 in each coordinate. Note that Or@@ is False.






                                                                                                                  share|improve this answer









                                                                                                                  $endgroup$















                                                                                                                    1












                                                                                                                    1








                                                                                                                    1





                                                                                                                    $begingroup$


                                                                                                                    Wolfram Language (Mathematica), 56 bytes



                                                                                                                    Or@@(Min[s-#]>0&/@Rest@Permutations@Mod[#,s=2,3,5,7])&


                                                                                                                    Try it online!



                                                                                                                    Finds all non-identity permutations of the remainders of the input modulo 2, 3, 5, 7, and checks if any of them are below 2,3,5,7 in each coordinate. Note that Or@@ is False.






                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$




                                                                                                                    Wolfram Language (Mathematica), 56 bytes



                                                                                                                    Or@@(Min[s-#]>0&/@Rest@Permutations@Mod[#,s=2,3,5,7])&


                                                                                                                    Try it online!



                                                                                                                    Finds all non-identity permutations of the remainders of the input modulo 2, 3, 5, 7, and checks if any of them are below 2,3,5,7 in each coordinate. Note that Or@@ is False.







                                                                                                                    share|improve this answer












                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer










                                                                                                                    answered 2 days ago









                                                                                                                    Misha LavrovMisha Lavrov

                                                                                                                    4,261424




                                                                                                                    4,261424



























                                                                                                                        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%2f182669%2fdo-i-have-a-twin-with-permutated-remainders%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

                                                                                                                        Sum ergo cogito? 1 nng

                                                                                                                        三茅街道4182Guuntc Dn precexpngmageondP