Number in overlapping rangeShortest Port ScannerFinding Not-Quite-Prime NumbersA newly discovered number: bleen!Safety in numbersDo the circles intersect?Date within range?count ones in rangeThe first, the last, and everything betweenIs this Pascal's Matrix?Is it double speak?

How to measure if Scrum Master is making a difference and when to give up

Why do my bicycle brakes get worse and feel more 'squishy" over time?

How do figure out how powerful I am, when my abilities far exceed my knowledge?

Why won't the Republicans use a superdelegate system like the DNC in their nomination process?

The more + the + comparative degree

When was "Fredo" an insult to Italian-Americans?

Output the list of musical notes

Because my friend asked me to

Is this bar slide trick shown on Cheers real or a visual effect?

Why aren't rockets built with truss structures inside their fuel & oxidizer tanks to increase structural strength?

Bringing Power Supplies on Plane?

Word for an event that will likely never happen again

What are the advantages of this gold finger shape?

Why did IBM make the PC BIOS source code public?

What is the most difficult concept to grasp in Calculus 1?

Solving pricing problem heuristically in column generation algorithm for VRP

What should we do with manuals from the 80s?

Is there any official ruling on how characters go from 0th to 1st level in a class?

Number in overlapping range

Graphs for which a calculus student can reasonably compute the arclength

What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?

Are there liquid fueled rocket boosters having coaxial fuel/oxidizer tanks?

How can I shoot a bow using Strength instead of Dexterity?

Do I need to start off my book by describing the character's "normal world"?



Number in overlapping range


Shortest Port ScannerFinding Not-Quite-Prime NumbersA newly discovered number: bleen!Safety in numbersDo the circles intersect?Date within range?count ones in rangeThe first, the last, and everything betweenIs this Pascal's Matrix?Is it double speak?






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








2












$begingroup$


You are given two integers between lets say 1 and 12, one and two

and a integer between lets say 0 and 4 which is called range.
The challange is to decide if one is inside or equal the range from two ± range.

The range is restarting with 1 (one) after 12 (two) and vise versa.



For example, if one = 2, two = 11 and range = 3, the result is true, as one is the the range [8, 9, 10, 11, 12, 1, 2].



The input has to be 3 seperated integers, the order doesn't matter. Input via string with seperators possible. But the Input has to consist of numbers reading as '10' and not 'A' e.g.



Test cases:



one=7 two=6 range=0 result=false
one=5 two=6 range=1 result=true
one=8 two=11 range=3 result=true
one=1 two=11 range=3 result=true
one=2 two=10 range=3 result=false
one=11 two=1 range=2 result=true
one=6 two=1 range=4 result=false
one=12 two=1 range=3 result=true


Shortest valid answer in bytes wins.










share|improve this question









New contributor



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






$endgroup$













  • $begingroup$
    Welcome to the site! While this challenge is understandable, there are still a few issues. For example, why between 1 and 12, and 0 and 4 particularly? Also, please keep in mind that homework questions are not on-topic here, so if this is homework (or similar), I'd recommend loosening the requirements of the challenge (allowing the integers/range to be any number, etc.). Finally, what do you mean by "Restarting with 1 after 12 and vise versa."?
    $endgroup$
    – caird coinheringaahing
    10 hours ago











  • $begingroup$
    @cairdcoinheringaahing Hey thank you, I picked those numbers randomly, but two has to be bigger than one. How big the range is does not really matter. With restarting I mean that your range overlaps over two so if one is 2 and two is 11 and the range is 3, one is still inside the range because it restarts at two with one
    $endgroup$
    – Tom Unger
    10 hours ago










  • $begingroup$
    So if one is 2, two is 11, and range is 3, is the task basically to check if one is in the list [8, 9, 10, 11, 12, 1, 2]? That the range cycles round if it goes out of bounds?
    $endgroup$
    – caird coinheringaahing
    9 hours ago










  • $begingroup$
    Exactly, sorry If my description was irritating
    $endgroup$
    – Tom Unger
    9 hours ago






  • 1




    $begingroup$
    one and two really should be called A and B for the sake of clarity. Also, it's still unclear IMO what is given as input and what is a constant. Are $1$ and $12$ the input values, or are the input values guaranteed to be in $[1..12]$?
    $endgroup$
    – Arnauld
    9 hours ago

















2












$begingroup$


You are given two integers between lets say 1 and 12, one and two

and a integer between lets say 0 and 4 which is called range.
The challange is to decide if one is inside or equal the range from two ± range.

The range is restarting with 1 (one) after 12 (two) and vise versa.



For example, if one = 2, two = 11 and range = 3, the result is true, as one is the the range [8, 9, 10, 11, 12, 1, 2].



The input has to be 3 seperated integers, the order doesn't matter. Input via string with seperators possible. But the Input has to consist of numbers reading as '10' and not 'A' e.g.



Test cases:



one=7 two=6 range=0 result=false
one=5 two=6 range=1 result=true
one=8 two=11 range=3 result=true
one=1 two=11 range=3 result=true
one=2 two=10 range=3 result=false
one=11 two=1 range=2 result=true
one=6 two=1 range=4 result=false
one=12 two=1 range=3 result=true


Shortest valid answer in bytes wins.










share|improve this question









New contributor



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






$endgroup$













  • $begingroup$
    Welcome to the site! While this challenge is understandable, there are still a few issues. For example, why between 1 and 12, and 0 and 4 particularly? Also, please keep in mind that homework questions are not on-topic here, so if this is homework (or similar), I'd recommend loosening the requirements of the challenge (allowing the integers/range to be any number, etc.). Finally, what do you mean by "Restarting with 1 after 12 and vise versa."?
    $endgroup$
    – caird coinheringaahing
    10 hours ago











  • $begingroup$
    @cairdcoinheringaahing Hey thank you, I picked those numbers randomly, but two has to be bigger than one. How big the range is does not really matter. With restarting I mean that your range overlaps over two so if one is 2 and two is 11 and the range is 3, one is still inside the range because it restarts at two with one
    $endgroup$
    – Tom Unger
    10 hours ago










  • $begingroup$
    So if one is 2, two is 11, and range is 3, is the task basically to check if one is in the list [8, 9, 10, 11, 12, 1, 2]? That the range cycles round if it goes out of bounds?
    $endgroup$
    – caird coinheringaahing
    9 hours ago










  • $begingroup$
    Exactly, sorry If my description was irritating
    $endgroup$
    – Tom Unger
    9 hours ago






  • 1




    $begingroup$
    one and two really should be called A and B for the sake of clarity. Also, it's still unclear IMO what is given as input and what is a constant. Are $1$ and $12$ the input values, or are the input values guaranteed to be in $[1..12]$?
    $endgroup$
    – Arnauld
    9 hours ago













2












2








2





$begingroup$


You are given two integers between lets say 1 and 12, one and two

and a integer between lets say 0 and 4 which is called range.
The challange is to decide if one is inside or equal the range from two ± range.

The range is restarting with 1 (one) after 12 (two) and vise versa.



For example, if one = 2, two = 11 and range = 3, the result is true, as one is the the range [8, 9, 10, 11, 12, 1, 2].



The input has to be 3 seperated integers, the order doesn't matter. Input via string with seperators possible. But the Input has to consist of numbers reading as '10' and not 'A' e.g.



Test cases:



one=7 two=6 range=0 result=false
one=5 two=6 range=1 result=true
one=8 two=11 range=3 result=true
one=1 two=11 range=3 result=true
one=2 two=10 range=3 result=false
one=11 two=1 range=2 result=true
one=6 two=1 range=4 result=false
one=12 two=1 range=3 result=true


Shortest valid answer in bytes wins.










share|improve this question









New contributor



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






$endgroup$




You are given two integers between lets say 1 and 12, one and two

and a integer between lets say 0 and 4 which is called range.
The challange is to decide if one is inside or equal the range from two ± range.

The range is restarting with 1 (one) after 12 (two) and vise versa.



For example, if one = 2, two = 11 and range = 3, the result is true, as one is the the range [8, 9, 10, 11, 12, 1, 2].



The input has to be 3 seperated integers, the order doesn't matter. Input via string with seperators possible. But the Input has to consist of numbers reading as '10' and not 'A' e.g.



Test cases:



one=7 two=6 range=0 result=false
one=5 two=6 range=1 result=true
one=8 two=11 range=3 result=true
one=1 two=11 range=3 result=true
one=2 two=10 range=3 result=false
one=11 two=1 range=2 result=true
one=6 two=1 range=4 result=false
one=12 two=1 range=3 result=true


Shortest valid answer in bytes wins.







code-golf decision-problem






share|improve this question









New contributor



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










share|improve this question









New contributor



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








share|improve this question




share|improve this question








edited 8 hours ago









Arnauld

90.1k7 gold badges105 silver badges366 bronze badges




90.1k7 gold badges105 silver badges366 bronze badges






New contributor



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








asked 10 hours ago









Tom UngerTom Unger

142 bronze badges




142 bronze badges




New contributor



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




New contributor




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
















  • $begingroup$
    Welcome to the site! While this challenge is understandable, there are still a few issues. For example, why between 1 and 12, and 0 and 4 particularly? Also, please keep in mind that homework questions are not on-topic here, so if this is homework (or similar), I'd recommend loosening the requirements of the challenge (allowing the integers/range to be any number, etc.). Finally, what do you mean by "Restarting with 1 after 12 and vise versa."?
    $endgroup$
    – caird coinheringaahing
    10 hours ago











  • $begingroup$
    @cairdcoinheringaahing Hey thank you, I picked those numbers randomly, but two has to be bigger than one. How big the range is does not really matter. With restarting I mean that your range overlaps over two so if one is 2 and two is 11 and the range is 3, one is still inside the range because it restarts at two with one
    $endgroup$
    – Tom Unger
    10 hours ago










  • $begingroup$
    So if one is 2, two is 11, and range is 3, is the task basically to check if one is in the list [8, 9, 10, 11, 12, 1, 2]? That the range cycles round if it goes out of bounds?
    $endgroup$
    – caird coinheringaahing
    9 hours ago










  • $begingroup$
    Exactly, sorry If my description was irritating
    $endgroup$
    – Tom Unger
    9 hours ago






  • 1




    $begingroup$
    one and two really should be called A and B for the sake of clarity. Also, it's still unclear IMO what is given as input and what is a constant. Are $1$ and $12$ the input values, or are the input values guaranteed to be in $[1..12]$?
    $endgroup$
    – Arnauld
    9 hours ago
















  • $begingroup$
    Welcome to the site! While this challenge is understandable, there are still a few issues. For example, why between 1 and 12, and 0 and 4 particularly? Also, please keep in mind that homework questions are not on-topic here, so if this is homework (or similar), I'd recommend loosening the requirements of the challenge (allowing the integers/range to be any number, etc.). Finally, what do you mean by "Restarting with 1 after 12 and vise versa."?
    $endgroup$
    – caird coinheringaahing
    10 hours ago











  • $begingroup$
    @cairdcoinheringaahing Hey thank you, I picked those numbers randomly, but two has to be bigger than one. How big the range is does not really matter. With restarting I mean that your range overlaps over two so if one is 2 and two is 11 and the range is 3, one is still inside the range because it restarts at two with one
    $endgroup$
    – Tom Unger
    10 hours ago










  • $begingroup$
    So if one is 2, two is 11, and range is 3, is the task basically to check if one is in the list [8, 9, 10, 11, 12, 1, 2]? That the range cycles round if it goes out of bounds?
    $endgroup$
    – caird coinheringaahing
    9 hours ago










  • $begingroup$
    Exactly, sorry If my description was irritating
    $endgroup$
    – Tom Unger
    9 hours ago






  • 1




    $begingroup$
    one and two really should be called A and B for the sake of clarity. Also, it's still unclear IMO what is given as input and what is a constant. Are $1$ and $12$ the input values, or are the input values guaranteed to be in $[1..12]$?
    $endgroup$
    – Arnauld
    9 hours ago















$begingroup$
Welcome to the site! While this challenge is understandable, there are still a few issues. For example, why between 1 and 12, and 0 and 4 particularly? Also, please keep in mind that homework questions are not on-topic here, so if this is homework (or similar), I'd recommend loosening the requirements of the challenge (allowing the integers/range to be any number, etc.). Finally, what do you mean by "Restarting with 1 after 12 and vise versa."?
$endgroup$
– caird coinheringaahing
10 hours ago





$begingroup$
Welcome to the site! While this challenge is understandable, there are still a few issues. For example, why between 1 and 12, and 0 and 4 particularly? Also, please keep in mind that homework questions are not on-topic here, so if this is homework (or similar), I'd recommend loosening the requirements of the challenge (allowing the integers/range to be any number, etc.). Finally, what do you mean by "Restarting with 1 after 12 and vise versa."?
$endgroup$
– caird coinheringaahing
10 hours ago













$begingroup$
@cairdcoinheringaahing Hey thank you, I picked those numbers randomly, but two has to be bigger than one. How big the range is does not really matter. With restarting I mean that your range overlaps over two so if one is 2 and two is 11 and the range is 3, one is still inside the range because it restarts at two with one
$endgroup$
– Tom Unger
10 hours ago




$begingroup$
@cairdcoinheringaahing Hey thank you, I picked those numbers randomly, but two has to be bigger than one. How big the range is does not really matter. With restarting I mean that your range overlaps over two so if one is 2 and two is 11 and the range is 3, one is still inside the range because it restarts at two with one
$endgroup$
– Tom Unger
10 hours ago












$begingroup$
So if one is 2, two is 11, and range is 3, is the task basically to check if one is in the list [8, 9, 10, 11, 12, 1, 2]? That the range cycles round if it goes out of bounds?
$endgroup$
– caird coinheringaahing
9 hours ago




$begingroup$
So if one is 2, two is 11, and range is 3, is the task basically to check if one is in the list [8, 9, 10, 11, 12, 1, 2]? That the range cycles round if it goes out of bounds?
$endgroup$
– caird coinheringaahing
9 hours ago












$begingroup$
Exactly, sorry If my description was irritating
$endgroup$
– Tom Unger
9 hours ago




$begingroup$
Exactly, sorry If my description was irritating
$endgroup$
– Tom Unger
9 hours ago




1




1




$begingroup$
one and two really should be called A and B for the sake of clarity. Also, it's still unclear IMO what is given as input and what is a constant. Are $1$ and $12$ the input values, or are the input values guaranteed to be in $[1..12]$?
$endgroup$
– Arnauld
9 hours ago




$begingroup$
one and two really should be called A and B for the sake of clarity. Also, it's still unclear IMO what is given as input and what is a constant. Are $1$ and $12$ the input values, or are the input values guaranteed to be in $[1..12]$?
$endgroup$
– Arnauld
9 hours ago










16 Answers
16






active

oldest

votes


















3












$begingroup$

JavaScript (ES6), 38 bytes





(a,b,r)=>((a=a<b?b-a:a-b)>6?12-a:a)<=r


Try it online!





JavaScript (Node.js), 53 bytes



Silly branchless method. Expects BigInts. Returns $0textn$ or $1textn$.





(a,b,r)=>0x4C5C038B885n>>((a-=b)*a+347n*r)%282n%46n&1n


Try it online!






share|improve this answer











$endgroup$






















    2












    $begingroup$


    Python 2, 52 bytes





    lambda a,b,c:a in[i%12or 12for i in range(b-c,b-~c)]


    Try it online!




    Python 2, 52 bytes





    lambda a,b,c:any(set(range(b-c,b-~c))&a,a-12,a+12)


    Try it online!





    Python 3, 50 bytes





    lambda a,b,c:any(*range(b-c,b-~c)&a,a-12,a+12)


    Try it online!






    share|improve this answer











    $endgroup$






















      2












      $begingroup$


      Jelly, 10 8 10 bytes



      ŒR’+%12‘Ɠe


      Try it online!



      Saved 2 bytes thanks to Mr. Xcoder



      +2 bytes due a bug if one = 12



      I believe this meets the criteria. Takes one from STDIN, range as left argument and two as right argument






      share|improve this answer











      $endgroup$














      • $begingroup$
        ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!
        $endgroup$
        – Mr. Xcoder
        9 hours ago











      • $begingroup$
        @Mr.Xcoder So it does! Thanks
        $endgroup$
        – caird coinheringaahing
        9 hours ago










      • $begingroup$
        Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).
        $endgroup$
        – Kevin Cruijssen
        8 hours ago






      • 1




        $begingroup$
        @KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it
        $endgroup$
        – caird coinheringaahing
        8 hours ago


















      1












      $begingroup$

      Java 10, 70 38 bytes





      (o,t,r)->((o=o<t?t-o:o-t)>6?12-o:o)<=r


      -32 bytes by porting @Arnauld's JavaScript answer.



      Try it online.



      Explanation:



      (o,t,r)-> // Method with three integer parameters and boolean return-type
      ((o=o<t?t-o:o-t) // Replace `o` with abs(t-o)
      >6? // And if it's smaller than 6:
      12-o // Use 12-o
      : // Else (it's larger than or equal to 6):
      o // Use o itself
      )<=r // And check if that is smaller than or equal to r





      share|improve this answer











      $endgroup$






















        1












        $begingroup$


        05AB1E, 11 8 bytes



        αD12α‚ß@


        -3 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!



        Inputs in the same order as the challenge description: one; two; range.



        Try it online or verify all test cases.



        Explanation:





        $temp=lvert two-onervert$
        $result=rangegeq min(temp,lvert12-temprvert)$



        α # Take the absolute difference between the first two (implicit) inputs one & two
        D # Duplicate it
        12α # And take the absolute difference with 12
        ‚ß # Pair, pop, and push the minimum of the two values on the stack
        @ # And check if the (implicit) input range is larger than or equal to this value
        # (after which the result is output implicitly)





        share|improve this answer











        $endgroup$






















          0












          $begingroup$


          Wolfram Language (Mathematica), 24 bytes



          Abs@Mod[#-#2,12,-6]<=#3&


          Try it online!






          share|improve this answer









          $endgroup$






















            0












            $begingroup$


            Perl 5, 63 bytes





            sub fgrep$_[0]==$_%12,(1..36)[11+$_[1]-$_[2]..11+$_[1]+$_[2]]


            Try it online!



            Ungolfed:



            sub f 
            my($one, $two, $range) = @_;
            my @n = (1..36);
            return 0 + grep $one==$_%12, @n[ 11+$two-$range ..
            11+$two+$range ];






            share|improve this answer











            $endgroup$






















              0












              $begingroup$

              Haskell, 42 bytes



              t#r=(`elem`[1+(n-1)`mod`12|n<-[t-r..t+r]])


              two # range returns a function which when applied to one returns a Bool.



              Try it online!






              share|improve this answer









              $endgroup$






















                0












                $begingroup$


                Japt, 11 bytes



                aV
                aC mU §W


                Try it






                share|improve this answer











                $endgroup$






















                  0












                  $begingroup$

                  Ruby, 45 characters



                  ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o


                  Nothing fancy, just a chance to use Array#rotate.



                  Sample run:



                  irb(main):001:0> ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o[2, 11, 3]
                  => true


                  Try it online!






                  share|improve this answer









                  $endgroup$






















                    0












                    $begingroup$


                    Python 2, 31 bytes





                    lambda o,t,r:5-r<(o-t+6)%12<7+r


                    Try it online!



                    Python 2, 33 bytes





                    lambda o,t,r:abs((o-t+6)%12-6)<=r


                    Try it online!






                    share|improve this answer











                    $endgroup$






















                      0












                      $begingroup$


                      Haskell, 27 bytes





                      o%t=(abs(mod(o-t+6)12-6)<=)


                      Try it online!






                      share|improve this answer









                      $endgroup$






















                        0












                        $begingroup$


                        Charcoal, 11 bytes



                        ‹⁵⁺N↔⁻⁶↔⁻NN


                        Try it online! Link is to verbose version of code. Takes the size of the range as the first input. Output uses Charcoal's default Boolean format of - for true, nothing for false. Explanation:



                         NN Two inputs
                        ↔⁻ Absolute difference
                        ⁶ Literal 6
                        ↔⁻ Absolute difference
                        ⁺N Plus range
                        ‹⁵ Is greater than 5





                        share|improve this answer









                        $endgroup$






















                          0












                          $begingroup$


                          R, 48 bytes





                          function(a,b,r)a%in%c(9:12,1:12,1:4)[-r:r+b+4]


                          Try it online!



                          Pretty straightforward, I struggled for a while to find the best way to test if a was in the given range. There is likely a method I haven't seen or tried yet.






                          share|improve this answer









                          $endgroup$






















                            0












                            $begingroup$


                            Julia 1.0, 35 bytes





                            f(o,t,r)=o in@.mod(t-1+(-r:r),12)+1


                            Try it online!






                            share|improve this answer









                            $endgroup$






















                              0












                              $begingroup$


                              Stax, 7 bytes



                              ₧╝g╙╖²╞


                              Run and debug it



                              It takes input as space separated [range] [one] [two] and outputs 0 for false, 1 for true.



                              In pseudo-code:



                              d = abs(one - two)
                              return min(d, 12 - d) <= range


                              Hm, that's probably almost a python submission.






                              share|improve this answer









                              $endgroup$

















                                Your Answer






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

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

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

                                else
                                createEditor();

                                );

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



                                );






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









                                draft saved

                                draft discarded


















                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f190056%2fnumber-in-overlapping-range%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









                                3












                                $begingroup$

                                JavaScript (ES6), 38 bytes





                                (a,b,r)=>((a=a<b?b-a:a-b)>6?12-a:a)<=r


                                Try it online!





                                JavaScript (Node.js), 53 bytes



                                Silly branchless method. Expects BigInts. Returns $0textn$ or $1textn$.





                                (a,b,r)=>0x4C5C038B885n>>((a-=b)*a+347n*r)%282n%46n&1n


                                Try it online!






                                share|improve this answer











                                $endgroup$



















                                  3












                                  $begingroup$

                                  JavaScript (ES6), 38 bytes





                                  (a,b,r)=>((a=a<b?b-a:a-b)>6?12-a:a)<=r


                                  Try it online!





                                  JavaScript (Node.js), 53 bytes



                                  Silly branchless method. Expects BigInts. Returns $0textn$ or $1textn$.





                                  (a,b,r)=>0x4C5C038B885n>>((a-=b)*a+347n*r)%282n%46n&1n


                                  Try it online!






                                  share|improve this answer











                                  $endgroup$

















                                    3












                                    3








                                    3





                                    $begingroup$

                                    JavaScript (ES6), 38 bytes





                                    (a,b,r)=>((a=a<b?b-a:a-b)>6?12-a:a)<=r


                                    Try it online!





                                    JavaScript (Node.js), 53 bytes



                                    Silly branchless method. Expects BigInts. Returns $0textn$ or $1textn$.





                                    (a,b,r)=>0x4C5C038B885n>>((a-=b)*a+347n*r)%282n%46n&1n


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$



                                    JavaScript (ES6), 38 bytes





                                    (a,b,r)=>((a=a<b?b-a:a-b)>6?12-a:a)<=r


                                    Try it online!





                                    JavaScript (Node.js), 53 bytes



                                    Silly branchless method. Expects BigInts. Returns $0textn$ or $1textn$.





                                    (a,b,r)=>0x4C5C038B885n>>((a-=b)*a+347n*r)%282n%46n&1n


                                    Try it online!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 7 hours ago

























                                    answered 8 hours ago









                                    ArnauldArnauld

                                    90.1k7 gold badges105 silver badges366 bronze badges




                                    90.1k7 gold badges105 silver badges366 bronze badges


























                                        2












                                        $begingroup$


                                        Python 2, 52 bytes





                                        lambda a,b,c:a in[i%12or 12for i in range(b-c,b-~c)]


                                        Try it online!




                                        Python 2, 52 bytes





                                        lambda a,b,c:any(set(range(b-c,b-~c))&a,a-12,a+12)


                                        Try it online!





                                        Python 3, 50 bytes





                                        lambda a,b,c:any(*range(b-c,b-~c)&a,a-12,a+12)


                                        Try it online!






                                        share|improve this answer











                                        $endgroup$



















                                          2












                                          $begingroup$


                                          Python 2, 52 bytes





                                          lambda a,b,c:a in[i%12or 12for i in range(b-c,b-~c)]


                                          Try it online!




                                          Python 2, 52 bytes





                                          lambda a,b,c:any(set(range(b-c,b-~c))&a,a-12,a+12)


                                          Try it online!





                                          Python 3, 50 bytes





                                          lambda a,b,c:any(*range(b-c,b-~c)&a,a-12,a+12)


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$

















                                            2












                                            2








                                            2





                                            $begingroup$


                                            Python 2, 52 bytes





                                            lambda a,b,c:a in[i%12or 12for i in range(b-c,b-~c)]


                                            Try it online!




                                            Python 2, 52 bytes





                                            lambda a,b,c:any(set(range(b-c,b-~c))&a,a-12,a+12)


                                            Try it online!





                                            Python 3, 50 bytes





                                            lambda a,b,c:any(*range(b-c,b-~c)&a,a-12,a+12)


                                            Try it online!






                                            share|improve this answer











                                            $endgroup$




                                            Python 2, 52 bytes





                                            lambda a,b,c:a in[i%12or 12for i in range(b-c,b-~c)]


                                            Try it online!




                                            Python 2, 52 bytes





                                            lambda a,b,c:any(set(range(b-c,b-~c))&a,a-12,a+12)


                                            Try it online!





                                            Python 3, 50 bytes





                                            lambda a,b,c:any(*range(b-c,b-~c)&a,a-12,a+12)


                                            Try it online!







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited 9 hours ago

























                                            answered 9 hours ago









                                            TFeldTFeld

                                            18.3k3 gold badges14 silver badges57 bronze badges




                                            18.3k3 gold badges14 silver badges57 bronze badges
























                                                2












                                                $begingroup$


                                                Jelly, 10 8 10 bytes



                                                ŒR’+%12‘Ɠe


                                                Try it online!



                                                Saved 2 bytes thanks to Mr. Xcoder



                                                +2 bytes due a bug if one = 12



                                                I believe this meets the criteria. Takes one from STDIN, range as left argument and two as right argument






                                                share|improve this answer











                                                $endgroup$














                                                • $begingroup$
                                                  ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!
                                                  $endgroup$
                                                  – Mr. Xcoder
                                                  9 hours ago











                                                • $begingroup$
                                                  @Mr.Xcoder So it does! Thanks
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  9 hours ago










                                                • $begingroup$
                                                  Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  8 hours ago






                                                • 1




                                                  $begingroup$
                                                  @KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  8 hours ago















                                                2












                                                $begingroup$


                                                Jelly, 10 8 10 bytes



                                                ŒR’+%12‘Ɠe


                                                Try it online!



                                                Saved 2 bytes thanks to Mr. Xcoder



                                                +2 bytes due a bug if one = 12



                                                I believe this meets the criteria. Takes one from STDIN, range as left argument and two as right argument






                                                share|improve this answer











                                                $endgroup$














                                                • $begingroup$
                                                  ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!
                                                  $endgroup$
                                                  – Mr. Xcoder
                                                  9 hours ago











                                                • $begingroup$
                                                  @Mr.Xcoder So it does! Thanks
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  9 hours ago










                                                • $begingroup$
                                                  Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  8 hours ago






                                                • 1




                                                  $begingroup$
                                                  @KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  8 hours ago













                                                2












                                                2








                                                2





                                                $begingroup$


                                                Jelly, 10 8 10 bytes



                                                ŒR’+%12‘Ɠe


                                                Try it online!



                                                Saved 2 bytes thanks to Mr. Xcoder



                                                +2 bytes due a bug if one = 12



                                                I believe this meets the criteria. Takes one from STDIN, range as left argument and two as right argument






                                                share|improve this answer











                                                $endgroup$




                                                Jelly, 10 8 10 bytes



                                                ŒR’+%12‘Ɠe


                                                Try it online!



                                                Saved 2 bytes thanks to Mr. Xcoder



                                                +2 bytes due a bug if one = 12



                                                I believe this meets the criteria. Takes one from STDIN, range as left argument and two as right argument







                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 8 hours ago

























                                                answered 10 hours ago









                                                caird coinheringaahingcaird coinheringaahing

                                                7,6763 gold badges31 silver badges86 bronze badges




                                                7,6763 gold badges31 silver badges86 bronze badges














                                                • $begingroup$
                                                  ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!
                                                  $endgroup$
                                                  – Mr. Xcoder
                                                  9 hours ago











                                                • $begingroup$
                                                  @Mr.Xcoder So it does! Thanks
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  9 hours ago










                                                • $begingroup$
                                                  Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  8 hours ago






                                                • 1




                                                  $begingroup$
                                                  @KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  8 hours ago
















                                                • $begingroup$
                                                  ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!
                                                  $endgroup$
                                                  – Mr. Xcoder
                                                  9 hours ago











                                                • $begingroup$
                                                  @Mr.Xcoder So it does! Thanks
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  9 hours ago










                                                • $begingroup$
                                                  Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).
                                                  $endgroup$
                                                  – Kevin Cruijssen
                                                  8 hours ago






                                                • 1




                                                  $begingroup$
                                                  @KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it
                                                  $endgroup$
                                                  – caird coinheringaahing
                                                  8 hours ago















                                                $begingroup$
                                                ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!
                                                $endgroup$
                                                – Mr. Xcoder
                                                9 hours ago





                                                $begingroup$
                                                ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!
                                                $endgroup$
                                                – Mr. Xcoder
                                                9 hours ago













                                                $begingroup$
                                                @Mr.Xcoder So it does! Thanks
                                                $endgroup$
                                                – caird coinheringaahing
                                                9 hours ago




                                                $begingroup$
                                                @Mr.Xcoder So it does! Thanks
                                                $endgroup$
                                                – caird coinheringaahing
                                                9 hours ago












                                                $begingroup$
                                                Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).
                                                $endgroup$
                                                – Kevin Cruijssen
                                                8 hours ago




                                                $begingroup$
                                                Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).
                                                $endgroup$
                                                – Kevin Cruijssen
                                                8 hours ago




                                                1




                                                1




                                                $begingroup$
                                                @KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it
                                                $endgroup$
                                                – caird coinheringaahing
                                                8 hours ago




                                                $begingroup$
                                                @KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it
                                                $endgroup$
                                                – caird coinheringaahing
                                                8 hours ago











                                                1












                                                $begingroup$

                                                Java 10, 70 38 bytes





                                                (o,t,r)->((o=o<t?t-o:o-t)>6?12-o:o)<=r


                                                -32 bytes by porting @Arnauld's JavaScript answer.



                                                Try it online.



                                                Explanation:



                                                (o,t,r)-> // Method with three integer parameters and boolean return-type
                                                ((o=o<t?t-o:o-t) // Replace `o` with abs(t-o)
                                                >6? // And if it's smaller than 6:
                                                12-o // Use 12-o
                                                : // Else (it's larger than or equal to 6):
                                                o // Use o itself
                                                )<=r // And check if that is smaller than or equal to r





                                                share|improve this answer











                                                $endgroup$



















                                                  1












                                                  $begingroup$

                                                  Java 10, 70 38 bytes





                                                  (o,t,r)->((o=o<t?t-o:o-t)>6?12-o:o)<=r


                                                  -32 bytes by porting @Arnauld's JavaScript answer.



                                                  Try it online.



                                                  Explanation:



                                                  (o,t,r)-> // Method with three integer parameters and boolean return-type
                                                  ((o=o<t?t-o:o-t) // Replace `o` with abs(t-o)
                                                  >6? // And if it's smaller than 6:
                                                  12-o // Use 12-o
                                                  : // Else (it's larger than or equal to 6):
                                                  o // Use o itself
                                                  )<=r // And check if that is smaller than or equal to r





                                                  share|improve this answer











                                                  $endgroup$

















                                                    1












                                                    1








                                                    1





                                                    $begingroup$

                                                    Java 10, 70 38 bytes





                                                    (o,t,r)->((o=o<t?t-o:o-t)>6?12-o:o)<=r


                                                    -32 bytes by porting @Arnauld's JavaScript answer.



                                                    Try it online.



                                                    Explanation:



                                                    (o,t,r)-> // Method with three integer parameters and boolean return-type
                                                    ((o=o<t?t-o:o-t) // Replace `o` with abs(t-o)
                                                    >6? // And if it's smaller than 6:
                                                    12-o // Use 12-o
                                                    : // Else (it's larger than or equal to 6):
                                                    o // Use o itself
                                                    )<=r // And check if that is smaller than or equal to r





                                                    share|improve this answer











                                                    $endgroup$



                                                    Java 10, 70 38 bytes





                                                    (o,t,r)->((o=o<t?t-o:o-t)>6?12-o:o)<=r


                                                    -32 bytes by porting @Arnauld's JavaScript answer.



                                                    Try it online.



                                                    Explanation:



                                                    (o,t,r)-> // Method with three integer parameters and boolean return-type
                                                    ((o=o<t?t-o:o-t) // Replace `o` with abs(t-o)
                                                    >6? // And if it's smaller than 6:
                                                    12-o // Use 12-o
                                                    : // Else (it's larger than or equal to 6):
                                                    o // Use o itself
                                                    )<=r // And check if that is smaller than or equal to r






                                                    share|improve this answer














                                                    share|improve this answer



                                                    share|improve this answer








                                                    edited 8 hours ago

























                                                    answered 8 hours ago









                                                    Kevin CruijssenKevin Cruijssen

                                                    49.8k7 gold badges83 silver badges246 bronze badges




                                                    49.8k7 gold badges83 silver badges246 bronze badges
























                                                        1












                                                        $begingroup$


                                                        05AB1E, 11 8 bytes



                                                        αD12α‚ß@


                                                        -3 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!



                                                        Inputs in the same order as the challenge description: one; two; range.



                                                        Try it online or verify all test cases.



                                                        Explanation:





                                                        $temp=lvert two-onervert$
                                                        $result=rangegeq min(temp,lvert12-temprvert)$



                                                        α # Take the absolute difference between the first two (implicit) inputs one & two
                                                        D # Duplicate it
                                                        12α # And take the absolute difference with 12
                                                        ‚ß # Pair, pop, and push the minimum of the two values on the stack
                                                        @ # And check if the (implicit) input range is larger than or equal to this value
                                                        # (after which the result is output implicitly)





                                                        share|improve this answer











                                                        $endgroup$



















                                                          1












                                                          $begingroup$


                                                          05AB1E, 11 8 bytes



                                                          αD12α‚ß@


                                                          -3 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!



                                                          Inputs in the same order as the challenge description: one; two; range.



                                                          Try it online or verify all test cases.



                                                          Explanation:





                                                          $temp=lvert two-onervert$
                                                          $result=rangegeq min(temp,lvert12-temprvert)$



                                                          α # Take the absolute difference between the first two (implicit) inputs one & two
                                                          D # Duplicate it
                                                          12α # And take the absolute difference with 12
                                                          ‚ß # Pair, pop, and push the minimum of the two values on the stack
                                                          @ # And check if the (implicit) input range is larger than or equal to this value
                                                          # (after which the result is output implicitly)





                                                          share|improve this answer











                                                          $endgroup$

















                                                            1












                                                            1








                                                            1





                                                            $begingroup$


                                                            05AB1E, 11 8 bytes



                                                            αD12α‚ß@


                                                            -3 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!



                                                            Inputs in the same order as the challenge description: one; two; range.



                                                            Try it online or verify all test cases.



                                                            Explanation:





                                                            $temp=lvert two-onervert$
                                                            $result=rangegeq min(temp,lvert12-temprvert)$



                                                            α # Take the absolute difference between the first two (implicit) inputs one & two
                                                            D # Duplicate it
                                                            12α # And take the absolute difference with 12
                                                            ‚ß # Pair, pop, and push the minimum of the two values on the stack
                                                            @ # And check if the (implicit) input range is larger than or equal to this value
                                                            # (after which the result is output implicitly)





                                                            share|improve this answer











                                                            $endgroup$




                                                            05AB1E, 11 8 bytes



                                                            αD12α‚ß@


                                                            -3 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!



                                                            Inputs in the same order as the challenge description: one; two; range.



                                                            Try it online or verify all test cases.



                                                            Explanation:





                                                            $temp=lvert two-onervert$
                                                            $result=rangegeq min(temp,lvert12-temprvert)$



                                                            α # Take the absolute difference between the first two (implicit) inputs one & two
                                                            D # Duplicate it
                                                            12α # And take the absolute difference with 12
                                                            ‚ß # Pair, pop, and push the minimum of the two values on the stack
                                                            @ # And check if the (implicit) input range is larger than or equal to this value
                                                            # (after which the result is output implicitly)






                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited 8 hours ago

























                                                            answered 9 hours ago









                                                            Kevin CruijssenKevin Cruijssen

                                                            49.8k7 gold badges83 silver badges246 bronze badges




                                                            49.8k7 gold badges83 silver badges246 bronze badges
























                                                                0












                                                                $begingroup$


                                                                Wolfram Language (Mathematica), 24 bytes



                                                                Abs@Mod[#-#2,12,-6]<=#3&


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$



















                                                                  0












                                                                  $begingroup$


                                                                  Wolfram Language (Mathematica), 24 bytes



                                                                  Abs@Mod[#-#2,12,-6]<=#3&


                                                                  Try it online!






                                                                  share|improve this answer









                                                                  $endgroup$

















                                                                    0












                                                                    0








                                                                    0





                                                                    $begingroup$


                                                                    Wolfram Language (Mathematica), 24 bytes



                                                                    Abs@Mod[#-#2,12,-6]<=#3&


                                                                    Try it online!






                                                                    share|improve this answer









                                                                    $endgroup$




                                                                    Wolfram Language (Mathematica), 24 bytes



                                                                    Abs@Mod[#-#2,12,-6]<=#3&


                                                                    Try it online!







                                                                    share|improve this answer












                                                                    share|improve this answer



                                                                    share|improve this answer










                                                                    answered 8 hours ago









                                                                    RomanRoman

                                                                    6251 silver badge6 bronze badges




                                                                    6251 silver badge6 bronze badges
























                                                                        0












                                                                        $begingroup$


                                                                        Perl 5, 63 bytes





                                                                        sub fgrep$_[0]==$_%12,(1..36)[11+$_[1]-$_[2]..11+$_[1]+$_[2]]


                                                                        Try it online!



                                                                        Ungolfed:



                                                                        sub f 
                                                                        my($one, $two, $range) = @_;
                                                                        my @n = (1..36);
                                                                        return 0 + grep $one==$_%12, @n[ 11+$two-$range ..
                                                                        11+$two+$range ];






                                                                        share|improve this answer











                                                                        $endgroup$



















                                                                          0












                                                                          $begingroup$


                                                                          Perl 5, 63 bytes





                                                                          sub fgrep$_[0]==$_%12,(1..36)[11+$_[1]-$_[2]..11+$_[1]+$_[2]]


                                                                          Try it online!



                                                                          Ungolfed:



                                                                          sub f 
                                                                          my($one, $two, $range) = @_;
                                                                          my @n = (1..36);
                                                                          return 0 + grep $one==$_%12, @n[ 11+$two-$range ..
                                                                          11+$two+$range ];






                                                                          share|improve this answer











                                                                          $endgroup$

















                                                                            0












                                                                            0








                                                                            0





                                                                            $begingroup$


                                                                            Perl 5, 63 bytes





                                                                            sub fgrep$_[0]==$_%12,(1..36)[11+$_[1]-$_[2]..11+$_[1]+$_[2]]


                                                                            Try it online!



                                                                            Ungolfed:



                                                                            sub f 
                                                                            my($one, $two, $range) = @_;
                                                                            my @n = (1..36);
                                                                            return 0 + grep $one==$_%12, @n[ 11+$two-$range ..
                                                                            11+$two+$range ];






                                                                            share|improve this answer











                                                                            $endgroup$




                                                                            Perl 5, 63 bytes





                                                                            sub fgrep$_[0]==$_%12,(1..36)[11+$_[1]-$_[2]..11+$_[1]+$_[2]]


                                                                            Try it online!



                                                                            Ungolfed:



                                                                            sub f 
                                                                            my($one, $two, $range) = @_;
                                                                            my @n = (1..36);
                                                                            return 0 + grep $one==$_%12, @n[ 11+$two-$range ..
                                                                            11+$two+$range ];







                                                                            share|improve this answer














                                                                            share|improve this answer



                                                                            share|improve this answer








                                                                            edited 8 hours ago

























                                                                            answered 8 hours ago









                                                                            Kjetil S.Kjetil S.

                                                                            7072 silver badges5 bronze badges




                                                                            7072 silver badges5 bronze badges
























                                                                                0












                                                                                $begingroup$

                                                                                Haskell, 42 bytes



                                                                                t#r=(`elem`[1+(n-1)`mod`12|n<-[t-r..t+r]])


                                                                                two # range returns a function which when applied to one returns a Bool.



                                                                                Try it online!






                                                                                share|improve this answer









                                                                                $endgroup$



















                                                                                  0












                                                                                  $begingroup$

                                                                                  Haskell, 42 bytes



                                                                                  t#r=(`elem`[1+(n-1)`mod`12|n<-[t-r..t+r]])


                                                                                  two # range returns a function which when applied to one returns a Bool.



                                                                                  Try it online!






                                                                                  share|improve this answer









                                                                                  $endgroup$

















                                                                                    0












                                                                                    0








                                                                                    0





                                                                                    $begingroup$

                                                                                    Haskell, 42 bytes



                                                                                    t#r=(`elem`[1+(n-1)`mod`12|n<-[t-r..t+r]])


                                                                                    two # range returns a function which when applied to one returns a Bool.



                                                                                    Try it online!






                                                                                    share|improve this answer









                                                                                    $endgroup$



                                                                                    Haskell, 42 bytes



                                                                                    t#r=(`elem`[1+(n-1)`mod`12|n<-[t-r..t+r]])


                                                                                    two # range returns a function which when applied to one returns a Bool.



                                                                                    Try it online!







                                                                                    share|improve this answer












                                                                                    share|improve this answer



                                                                                    share|improve this answer










                                                                                    answered 8 hours ago









                                                                                    Leo TenenbaumLeo Tenenbaum

                                                                                    1,5782 gold badges7 silver badges16 bronze badges




                                                                                    1,5782 gold badges7 silver badges16 bronze badges
























                                                                                        0












                                                                                        $begingroup$


                                                                                        Japt, 11 bytes



                                                                                        aV
                                                                                        aC mU §W


                                                                                        Try it






                                                                                        share|improve this answer











                                                                                        $endgroup$



















                                                                                          0












                                                                                          $begingroup$


                                                                                          Japt, 11 bytes



                                                                                          aV
                                                                                          aC mU §W


                                                                                          Try it






                                                                                          share|improve this answer











                                                                                          $endgroup$

















                                                                                            0












                                                                                            0








                                                                                            0





                                                                                            $begingroup$


                                                                                            Japt, 11 bytes



                                                                                            aV
                                                                                            aC mU §W


                                                                                            Try it






                                                                                            share|improve this answer











                                                                                            $endgroup$




                                                                                            Japt, 11 bytes



                                                                                            aV
                                                                                            aC mU §W


                                                                                            Try it







                                                                                            share|improve this answer














                                                                                            share|improve this answer



                                                                                            share|improve this answer








                                                                                            edited 8 hours ago

























                                                                                            answered 8 hours ago









                                                                                            Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                            4,9861 silver badge30 bronze badges




                                                                                            4,9861 silver badge30 bronze badges
























                                                                                                0












                                                                                                $begingroup$

                                                                                                Ruby, 45 characters



                                                                                                ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o


                                                                                                Nothing fancy, just a chance to use Array#rotate.



                                                                                                Sample run:



                                                                                                irb(main):001:0> ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o[2, 11, 3]
                                                                                                => true


                                                                                                Try it online!






                                                                                                share|improve this answer









                                                                                                $endgroup$



















                                                                                                  0












                                                                                                  $begingroup$

                                                                                                  Ruby, 45 characters



                                                                                                  ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o


                                                                                                  Nothing fancy, just a chance to use Array#rotate.



                                                                                                  Sample run:



                                                                                                  irb(main):001:0> ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o[2, 11, 3]
                                                                                                  => true


                                                                                                  Try it online!






                                                                                                  share|improve this answer









                                                                                                  $endgroup$

















                                                                                                    0












                                                                                                    0








                                                                                                    0





                                                                                                    $begingroup$

                                                                                                    Ruby, 45 characters



                                                                                                    ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o


                                                                                                    Nothing fancy, just a chance to use Array#rotate.



                                                                                                    Sample run:



                                                                                                    irb(main):001:0> ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o[2, 11, 3]
                                                                                                    => true


                                                                                                    Try it online!






                                                                                                    share|improve this answer









                                                                                                    $endgroup$



                                                                                                    Ruby, 45 characters



                                                                                                    ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o


                                                                                                    Nothing fancy, just a chance to use Array#rotate.



                                                                                                    Sample run:



                                                                                                    irb(main):001:0> ->o,t,r[*1..12].rotate(t-r-1)[0..r*2].any?o[2, 11, 3]
                                                                                                    => true


                                                                                                    Try it online!







                                                                                                    share|improve this answer












                                                                                                    share|improve this answer



                                                                                                    share|improve this answer










                                                                                                    answered 7 hours ago









                                                                                                    manatworkmanatwork

                                                                                                    16.7k4 gold badges38 silver badges72 bronze badges




                                                                                                    16.7k4 gold badges38 silver badges72 bronze badges
























                                                                                                        0












                                                                                                        $begingroup$


                                                                                                        Python 2, 31 bytes





                                                                                                        lambda o,t,r:5-r<(o-t+6)%12<7+r


                                                                                                        Try it online!



                                                                                                        Python 2, 33 bytes





                                                                                                        lambda o,t,r:abs((o-t+6)%12-6)<=r


                                                                                                        Try it online!






                                                                                                        share|improve this answer











                                                                                                        $endgroup$



















                                                                                                          0












                                                                                                          $begingroup$


                                                                                                          Python 2, 31 bytes





                                                                                                          lambda o,t,r:5-r<(o-t+6)%12<7+r


                                                                                                          Try it online!



                                                                                                          Python 2, 33 bytes





                                                                                                          lambda o,t,r:abs((o-t+6)%12-6)<=r


                                                                                                          Try it online!






                                                                                                          share|improve this answer











                                                                                                          $endgroup$

















                                                                                                            0












                                                                                                            0








                                                                                                            0





                                                                                                            $begingroup$


                                                                                                            Python 2, 31 bytes





                                                                                                            lambda o,t,r:5-r<(o-t+6)%12<7+r


                                                                                                            Try it online!



                                                                                                            Python 2, 33 bytes





                                                                                                            lambda o,t,r:abs((o-t+6)%12-6)<=r


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$




                                                                                                            Python 2, 31 bytes





                                                                                                            lambda o,t,r:5-r<(o-t+6)%12<7+r


                                                                                                            Try it online!



                                                                                                            Python 2, 33 bytes





                                                                                                            lambda o,t,r:abs((o-t+6)%12-6)<=r


                                                                                                            Try it online!







                                                                                                            share|improve this answer














                                                                                                            share|improve this answer



                                                                                                            share|improve this answer








                                                                                                            edited 7 hours ago

























                                                                                                            answered 7 hours ago









                                                                                                            xnorxnor

                                                                                                            97.8k19 gold badges201 silver badges461 bronze badges




                                                                                                            97.8k19 gold badges201 silver badges461 bronze badges
























                                                                                                                0












                                                                                                                $begingroup$


                                                                                                                Haskell, 27 bytes





                                                                                                                o%t=(abs(mod(o-t+6)12-6)<=)


                                                                                                                Try it online!






                                                                                                                share|improve this answer









                                                                                                                $endgroup$



















                                                                                                                  0












                                                                                                                  $begingroup$


                                                                                                                  Haskell, 27 bytes





                                                                                                                  o%t=(abs(mod(o-t+6)12-6)<=)


                                                                                                                  Try it online!






                                                                                                                  share|improve this answer









                                                                                                                  $endgroup$

















                                                                                                                    0












                                                                                                                    0








                                                                                                                    0





                                                                                                                    $begingroup$


                                                                                                                    Haskell, 27 bytes





                                                                                                                    o%t=(abs(mod(o-t+6)12-6)<=)


                                                                                                                    Try it online!






                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$




                                                                                                                    Haskell, 27 bytes





                                                                                                                    o%t=(abs(mod(o-t+6)12-6)<=)


                                                                                                                    Try it online!







                                                                                                                    share|improve this answer












                                                                                                                    share|improve this answer



                                                                                                                    share|improve this answer










                                                                                                                    answered 7 hours ago









                                                                                                                    xnorxnor

                                                                                                                    97.8k19 gold badges201 silver badges461 bronze badges




                                                                                                                    97.8k19 gold badges201 silver badges461 bronze badges
























                                                                                                                        0












                                                                                                                        $begingroup$


                                                                                                                        Charcoal, 11 bytes



                                                                                                                        ‹⁵⁺N↔⁻⁶↔⁻NN


                                                                                                                        Try it online! Link is to verbose version of code. Takes the size of the range as the first input. Output uses Charcoal's default Boolean format of - for true, nothing for false. Explanation:



                                                                                                                         NN Two inputs
                                                                                                                        ↔⁻ Absolute difference
                                                                                                                        ⁶ Literal 6
                                                                                                                        ↔⁻ Absolute difference
                                                                                                                        ⁺N Plus range
                                                                                                                        ‹⁵ Is greater than 5





                                                                                                                        share|improve this answer









                                                                                                                        $endgroup$



















                                                                                                                          0












                                                                                                                          $begingroup$


                                                                                                                          Charcoal, 11 bytes



                                                                                                                          ‹⁵⁺N↔⁻⁶↔⁻NN


                                                                                                                          Try it online! Link is to verbose version of code. Takes the size of the range as the first input. Output uses Charcoal's default Boolean format of - for true, nothing for false. Explanation:



                                                                                                                           NN Two inputs
                                                                                                                          ↔⁻ Absolute difference
                                                                                                                          ⁶ Literal 6
                                                                                                                          ↔⁻ Absolute difference
                                                                                                                          ⁺N Plus range
                                                                                                                          ‹⁵ Is greater than 5





                                                                                                                          share|improve this answer









                                                                                                                          $endgroup$

















                                                                                                                            0












                                                                                                                            0








                                                                                                                            0





                                                                                                                            $begingroup$


                                                                                                                            Charcoal, 11 bytes



                                                                                                                            ‹⁵⁺N↔⁻⁶↔⁻NN


                                                                                                                            Try it online! Link is to verbose version of code. Takes the size of the range as the first input. Output uses Charcoal's default Boolean format of - for true, nothing for false. Explanation:



                                                                                                                             NN Two inputs
                                                                                                                            ↔⁻ Absolute difference
                                                                                                                            ⁶ Literal 6
                                                                                                                            ↔⁻ Absolute difference
                                                                                                                            ⁺N Plus range
                                                                                                                            ‹⁵ Is greater than 5





                                                                                                                            share|improve this answer









                                                                                                                            $endgroup$




                                                                                                                            Charcoal, 11 bytes



                                                                                                                            ‹⁵⁺N↔⁻⁶↔⁻NN


                                                                                                                            Try it online! Link is to verbose version of code. Takes the size of the range as the first input. Output uses Charcoal's default Boolean format of - for true, nothing for false. Explanation:



                                                                                                                             NN Two inputs
                                                                                                                            ↔⁻ Absolute difference
                                                                                                                            ⁶ Literal 6
                                                                                                                            ↔⁻ Absolute difference
                                                                                                                            ⁺N Plus range
                                                                                                                            ‹⁵ Is greater than 5






                                                                                                                            share|improve this answer












                                                                                                                            share|improve this answer



                                                                                                                            share|improve this answer










                                                                                                                            answered 3 hours ago









                                                                                                                            NeilNeil

                                                                                                                            87.3k8 gold badges46 silver badges183 bronze badges




                                                                                                                            87.3k8 gold badges46 silver badges183 bronze badges
























                                                                                                                                0












                                                                                                                                $begingroup$


                                                                                                                                R, 48 bytes





                                                                                                                                function(a,b,r)a%in%c(9:12,1:12,1:4)[-r:r+b+4]


                                                                                                                                Try it online!



                                                                                                                                Pretty straightforward, I struggled for a while to find the best way to test if a was in the given range. There is likely a method I haven't seen or tried yet.






                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$



















                                                                                                                                  0












                                                                                                                                  $begingroup$


                                                                                                                                  R, 48 bytes





                                                                                                                                  function(a,b,r)a%in%c(9:12,1:12,1:4)[-r:r+b+4]


                                                                                                                                  Try it online!



                                                                                                                                  Pretty straightforward, I struggled for a while to find the best way to test if a was in the given range. There is likely a method I haven't seen or tried yet.






                                                                                                                                  share|improve this answer









                                                                                                                                  $endgroup$

















                                                                                                                                    0












                                                                                                                                    0








                                                                                                                                    0





                                                                                                                                    $begingroup$


                                                                                                                                    R, 48 bytes





                                                                                                                                    function(a,b,r)a%in%c(9:12,1:12,1:4)[-r:r+b+4]


                                                                                                                                    Try it online!



                                                                                                                                    Pretty straightforward, I struggled for a while to find the best way to test if a was in the given range. There is likely a method I haven't seen or tried yet.






                                                                                                                                    share|improve this answer









                                                                                                                                    $endgroup$




                                                                                                                                    R, 48 bytes





                                                                                                                                    function(a,b,r)a%in%c(9:12,1:12,1:4)[-r:r+b+4]


                                                                                                                                    Try it online!



                                                                                                                                    Pretty straightforward, I struggled for a while to find the best way to test if a was in the given range. There is likely a method I haven't seen or tried yet.







                                                                                                                                    share|improve this answer












                                                                                                                                    share|improve this answer



                                                                                                                                    share|improve this answer










                                                                                                                                    answered 3 hours ago









                                                                                                                                    Sumner18Sumner18

                                                                                                                                    7202 silver badges8 bronze badges




                                                                                                                                    7202 silver badges8 bronze badges
























                                                                                                                                        0












                                                                                                                                        $begingroup$


                                                                                                                                        Julia 1.0, 35 bytes





                                                                                                                                        f(o,t,r)=o in@.mod(t-1+(-r:r),12)+1


                                                                                                                                        Try it online!






                                                                                                                                        share|improve this answer









                                                                                                                                        $endgroup$



















                                                                                                                                          0












                                                                                                                                          $begingroup$


                                                                                                                                          Julia 1.0, 35 bytes





                                                                                                                                          f(o,t,r)=o in@.mod(t-1+(-r:r),12)+1


                                                                                                                                          Try it online!






                                                                                                                                          share|improve this answer









                                                                                                                                          $endgroup$

















                                                                                                                                            0












                                                                                                                                            0








                                                                                                                                            0





                                                                                                                                            $begingroup$


                                                                                                                                            Julia 1.0, 35 bytes





                                                                                                                                            f(o,t,r)=o in@.mod(t-1+(-r:r),12)+1


                                                                                                                                            Try it online!






                                                                                                                                            share|improve this answer









                                                                                                                                            $endgroup$




                                                                                                                                            Julia 1.0, 35 bytes





                                                                                                                                            f(o,t,r)=o in@.mod(t-1+(-r:r),12)+1


                                                                                                                                            Try it online!







                                                                                                                                            share|improve this answer












                                                                                                                                            share|improve this answer



                                                                                                                                            share|improve this answer










                                                                                                                                            answered 2 hours ago









                                                                                                                                            user3263164user3263164

                                                                                                                                            1313 bronze badges




                                                                                                                                            1313 bronze badges
























                                                                                                                                                0












                                                                                                                                                $begingroup$


                                                                                                                                                Stax, 7 bytes



                                                                                                                                                ₧╝g╙╖²╞


                                                                                                                                                Run and debug it



                                                                                                                                                It takes input as space separated [range] [one] [two] and outputs 0 for false, 1 for true.



                                                                                                                                                In pseudo-code:



                                                                                                                                                d = abs(one - two)
                                                                                                                                                return min(d, 12 - d) <= range


                                                                                                                                                Hm, that's probably almost a python submission.






                                                                                                                                                share|improve this answer









                                                                                                                                                $endgroup$



















                                                                                                                                                  0












                                                                                                                                                  $begingroup$


                                                                                                                                                  Stax, 7 bytes



                                                                                                                                                  ₧╝g╙╖²╞


                                                                                                                                                  Run and debug it



                                                                                                                                                  It takes input as space separated [range] [one] [two] and outputs 0 for false, 1 for true.



                                                                                                                                                  In pseudo-code:



                                                                                                                                                  d = abs(one - two)
                                                                                                                                                  return min(d, 12 - d) <= range


                                                                                                                                                  Hm, that's probably almost a python submission.






                                                                                                                                                  share|improve this answer









                                                                                                                                                  $endgroup$

















                                                                                                                                                    0












                                                                                                                                                    0








                                                                                                                                                    0





                                                                                                                                                    $begingroup$


                                                                                                                                                    Stax, 7 bytes



                                                                                                                                                    ₧╝g╙╖²╞


                                                                                                                                                    Run and debug it



                                                                                                                                                    It takes input as space separated [range] [one] [two] and outputs 0 for false, 1 for true.



                                                                                                                                                    In pseudo-code:



                                                                                                                                                    d = abs(one - two)
                                                                                                                                                    return min(d, 12 - d) <= range


                                                                                                                                                    Hm, that's probably almost a python submission.






                                                                                                                                                    share|improve this answer









                                                                                                                                                    $endgroup$




                                                                                                                                                    Stax, 7 bytes



                                                                                                                                                    ₧╝g╙╖²╞


                                                                                                                                                    Run and debug it



                                                                                                                                                    It takes input as space separated [range] [one] [two] and outputs 0 for false, 1 for true.



                                                                                                                                                    In pseudo-code:



                                                                                                                                                    d = abs(one - two)
                                                                                                                                                    return min(d, 12 - d) <= range


                                                                                                                                                    Hm, that's probably almost a python submission.







                                                                                                                                                    share|improve this answer












                                                                                                                                                    share|improve this answer



                                                                                                                                                    share|improve this answer










                                                                                                                                                    answered 1 hour ago









                                                                                                                                                    recursiverecursive

                                                                                                                                                    7,85115 silver badges31 bronze badges




                                                                                                                                                    7,85115 silver badges31 bronze badges























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









                                                                                                                                                        draft saved

                                                                                                                                                        draft discarded


















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












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











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














                                                                                                                                                        If this is an answer to a challenge…



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


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


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


                                                                                                                                                        More generally…



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


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




                                                                                                                                                        draft saved


                                                                                                                                                        draft discarded














                                                                                                                                                        StackExchange.ready(
                                                                                                                                                        function ()
                                                                                                                                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f190056%2fnumber-in-overlapping-range%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

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

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

                                                                                                                                                        199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單