Equal, sum or difference!












19












$begingroup$


Write shortest possible code that will return true if the two given integer values are equal or their sum or difference is 5.



Example test cases:



4 1 => True
10 10 => True
1 3 => False
6 2 => False
1 6 => True
-256 -251 => True
6 1 => True


The shortest I could come up with in python2 is 56 characters long:



x=input();y=input();print all([x-y,x+y-5,abs(x-y)-5])<1









share|improve this question









New contributor




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







$endgroup$








  • 1




    $begingroup$
    Just for info, you can reduce your 56 by 9 by replacing x=input();y=input() with x,y=input() and giving the input as 2 integers separated by a comma.
    $endgroup$
    – ElPedro
    8 hours ago






  • 4




    $begingroup$
    welcome to PPCG! This is a good first challenge -- the challenge is clearly defined, it has ample test cases, and uses our default I/O! If you stick around for a while and keep thinking up interesting challenges, I would recommend using The Sandbox to get feedback before posting them to this site. I hope you enjoy the time you spend here!
    $endgroup$
    – Giuseppe
    8 hours ago










  • $begingroup$
    This would have been very slightly more interesting if the question was whether the absolute value of the addition or subtraction was equal to five, as then the sign of the integers doesn't matter. As it is, if I wanted to write an answer in Retina I'd have to special-case for a sum of -5. (And since Retina only really understands positive integers, this isn't easy.)
    $endgroup$
    – Neil
    6 hours ago






  • 1




    $begingroup$
    suggest a test case 6 1 => True
    $endgroup$
    – cleblanc
    6 hours ago










  • $begingroup$
    @Neil based on the recently added test case that is the case
    $endgroup$
    – Stephen
    3 hours ago
















19












$begingroup$


Write shortest possible code that will return true if the two given integer values are equal or their sum or difference is 5.



Example test cases:



4 1 => True
10 10 => True
1 3 => False
6 2 => False
1 6 => True
-256 -251 => True
6 1 => True


The shortest I could come up with in python2 is 56 characters long:



x=input();y=input();print all([x-y,x+y-5,abs(x-y)-5])<1









share|improve this question









New contributor




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







$endgroup$








  • 1




    $begingroup$
    Just for info, you can reduce your 56 by 9 by replacing x=input();y=input() with x,y=input() and giving the input as 2 integers separated by a comma.
    $endgroup$
    – ElPedro
    8 hours ago






  • 4




    $begingroup$
    welcome to PPCG! This is a good first challenge -- the challenge is clearly defined, it has ample test cases, and uses our default I/O! If you stick around for a while and keep thinking up interesting challenges, I would recommend using The Sandbox to get feedback before posting them to this site. I hope you enjoy the time you spend here!
    $endgroup$
    – Giuseppe
    8 hours ago










  • $begingroup$
    This would have been very slightly more interesting if the question was whether the absolute value of the addition or subtraction was equal to five, as then the sign of the integers doesn't matter. As it is, if I wanted to write an answer in Retina I'd have to special-case for a sum of -5. (And since Retina only really understands positive integers, this isn't easy.)
    $endgroup$
    – Neil
    6 hours ago






  • 1




    $begingroup$
    suggest a test case 6 1 => True
    $endgroup$
    – cleblanc
    6 hours ago










  • $begingroup$
    @Neil based on the recently added test case that is the case
    $endgroup$
    – Stephen
    3 hours ago














19












19








19


1



$begingroup$


Write shortest possible code that will return true if the two given integer values are equal or their sum or difference is 5.



Example test cases:



4 1 => True
10 10 => True
1 3 => False
6 2 => False
1 6 => True
-256 -251 => True
6 1 => True


The shortest I could come up with in python2 is 56 characters long:



x=input();y=input();print all([x-y,x+y-5,abs(x-y)-5])<1









share|improve this question









New contributor




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







$endgroup$




Write shortest possible code that will return true if the two given integer values are equal or their sum or difference is 5.



Example test cases:



4 1 => True
10 10 => True
1 3 => False
6 2 => False
1 6 => True
-256 -251 => True
6 1 => True


The shortest I could come up with in python2 is 56 characters long:



x=input();y=input();print all([x-y,x+y-5,abs(x-y)-5])<1






code-golf decision-problem






share|improve this question









New contributor




Vikrant Biswas 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




Vikrant Biswas 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 5 hours ago







Vikrant Biswas













New contributor




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









asked 8 hours ago









Vikrant BiswasVikrant Biswas

964




964




New contributor




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





New contributor





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






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








  • 1




    $begingroup$
    Just for info, you can reduce your 56 by 9 by replacing x=input();y=input() with x,y=input() and giving the input as 2 integers separated by a comma.
    $endgroup$
    – ElPedro
    8 hours ago






  • 4




    $begingroup$
    welcome to PPCG! This is a good first challenge -- the challenge is clearly defined, it has ample test cases, and uses our default I/O! If you stick around for a while and keep thinking up interesting challenges, I would recommend using The Sandbox to get feedback before posting them to this site. I hope you enjoy the time you spend here!
    $endgroup$
    – Giuseppe
    8 hours ago










  • $begingroup$
    This would have been very slightly more interesting if the question was whether the absolute value of the addition or subtraction was equal to five, as then the sign of the integers doesn't matter. As it is, if I wanted to write an answer in Retina I'd have to special-case for a sum of -5. (And since Retina only really understands positive integers, this isn't easy.)
    $endgroup$
    – Neil
    6 hours ago






  • 1




    $begingroup$
    suggest a test case 6 1 => True
    $endgroup$
    – cleblanc
    6 hours ago










  • $begingroup$
    @Neil based on the recently added test case that is the case
    $endgroup$
    – Stephen
    3 hours ago














  • 1




    $begingroup$
    Just for info, you can reduce your 56 by 9 by replacing x=input();y=input() with x,y=input() and giving the input as 2 integers separated by a comma.
    $endgroup$
    – ElPedro
    8 hours ago






  • 4




    $begingroup$
    welcome to PPCG! This is a good first challenge -- the challenge is clearly defined, it has ample test cases, and uses our default I/O! If you stick around for a while and keep thinking up interesting challenges, I would recommend using The Sandbox to get feedback before posting them to this site. I hope you enjoy the time you spend here!
    $endgroup$
    – Giuseppe
    8 hours ago










  • $begingroup$
    This would have been very slightly more interesting if the question was whether the absolute value of the addition or subtraction was equal to five, as then the sign of the integers doesn't matter. As it is, if I wanted to write an answer in Retina I'd have to special-case for a sum of -5. (And since Retina only really understands positive integers, this isn't easy.)
    $endgroup$
    – Neil
    6 hours ago






  • 1




    $begingroup$
    suggest a test case 6 1 => True
    $endgroup$
    – cleblanc
    6 hours ago










  • $begingroup$
    @Neil based on the recently added test case that is the case
    $endgroup$
    – Stephen
    3 hours ago








1




1




$begingroup$
Just for info, you can reduce your 56 by 9 by replacing x=input();y=input() with x,y=input() and giving the input as 2 integers separated by a comma.
$endgroup$
– ElPedro
8 hours ago




$begingroup$
Just for info, you can reduce your 56 by 9 by replacing x=input();y=input() with x,y=input() and giving the input as 2 integers separated by a comma.
$endgroup$
– ElPedro
8 hours ago




4




4




$begingroup$
welcome to PPCG! This is a good first challenge -- the challenge is clearly defined, it has ample test cases, and uses our default I/O! If you stick around for a while and keep thinking up interesting challenges, I would recommend using The Sandbox to get feedback before posting them to this site. I hope you enjoy the time you spend here!
$endgroup$
– Giuseppe
8 hours ago




$begingroup$
welcome to PPCG! This is a good first challenge -- the challenge is clearly defined, it has ample test cases, and uses our default I/O! If you stick around for a while and keep thinking up interesting challenges, I would recommend using The Sandbox to get feedback before posting them to this site. I hope you enjoy the time you spend here!
$endgroup$
– Giuseppe
8 hours ago












$begingroup$
This would have been very slightly more interesting if the question was whether the absolute value of the addition or subtraction was equal to five, as then the sign of the integers doesn't matter. As it is, if I wanted to write an answer in Retina I'd have to special-case for a sum of -5. (And since Retina only really understands positive integers, this isn't easy.)
$endgroup$
– Neil
6 hours ago




$begingroup$
This would have been very slightly more interesting if the question was whether the absolute value of the addition or subtraction was equal to five, as then the sign of the integers doesn't matter. As it is, if I wanted to write an answer in Retina I'd have to special-case for a sum of -5. (And since Retina only really understands positive integers, this isn't easy.)
$endgroup$
– Neil
6 hours ago




1




1




$begingroup$
suggest a test case 6 1 => True
$endgroup$
– cleblanc
6 hours ago




$begingroup$
suggest a test case 6 1 => True
$endgroup$
– cleblanc
6 hours ago












$begingroup$
@Neil based on the recently added test case that is the case
$endgroup$
– Stephen
3 hours ago




$begingroup$
@Neil based on the recently added test case that is the case
$endgroup$
– Stephen
3 hours ago










24 Answers
24






active

oldest

votes


















10












$begingroup$


Python 2, 30 bytes





lambda a,b:a in(b,5-b,b-5,b+5)


Try it online!



One byte saved by Arnauld



Three bytes saved by alephalpha






share|improve this answer











$endgroup$









  • 2




    $begingroup$
    lambda a,b:a in(b,5-b,b-5,b+5)
    $endgroup$
    – alephalpha
    8 hours ago










  • $begingroup$
    This is amazingly concise, thanks
    $endgroup$
    – Vikrant Biswas
    7 hours ago



















7












$begingroup$

JavaScript (ES6), 28 bytes



Takes input as (a)(b). Returns $0$ or $1$.





a=>b=>a+b==5|!(a-=b)|a*a==25


Try it online!






share|improve this answer











$endgroup$













  • $begingroup$
    Damn, took me a long long time to figure out how this handling the difference part. :)
    $endgroup$
    – Vikrant Biswas
    5 hours ago



















5












$begingroup$


R, 40 bytes (or 34)





function(x,y)any((-1:1*5)%in%c(x+y,x-y))


Try it online!



For non-R users:





  • -1:1*5 expands to [-5, 0, 5]

  • the %in% operator takes elements from the left and checks (element-wise) if they exist in the vector on the right


A direct port of @ArBo's solution has 35 34 bytes, so go upvote that answer if you like it:



function(x,y)x%in%c(y--1:1*5,5-y)





share|improve this answer











$endgroup$













  • $begingroup$
    The 34 byte one can be reduced by 1 with function(x,y)x%in%c(y--1:1*5,5-y)
    $endgroup$
    – MickyT
    3 hours ago



















4












$begingroup$


J, 12 11 bytes



1 byte saved thanks to Adám



1#.=+5=|@-,+


Try it online!



Explanation



This is equivalent to:



1 #. = + 5 = |@- , +


This can be divided into the following fork chain:



(= + (5 e. (|@- , +)))


Or, visualized using 5!:4<'f':



  ┌─ =               
├─ +
──┤ ┌─ 5
│ ├─ e.
└───┤ ┌─ |
│ ┌─ @ ─┴─ -
└────┼─ ,
└─ +


Annotated:



  ┌─ =                                     equality
├─ + added to (boolean or)
──┤ ┌─ 5 noun 5
│ ├─ e. is an element of
└───┤ ┌─ | absolute value |
│ ┌─ @ ─┴─ - (of) subtraction |
└────┼─ , paired with |
└─ + addition | any of these?





share|improve this answer











$endgroup$













  • $begingroup$
    Save a byte with e.
    $endgroup$
    – Adám
    7 hours ago










  • $begingroup$
    @Adám How so? Shortest approach I got with e. was =+.5 e.|@-,+. Maybe you forget 5e. is an invalid token in J?
    $endgroup$
    – Conor O'Brien
    7 hours ago










  • $begingroup$
    Since two integers cannot simultaneously sum to 5 and be equal, you can use + instead of +.
    $endgroup$
    – Adám
    7 hours ago










  • $begingroup$
    @Adám Ah, I see, thank you.
    $endgroup$
    – Conor O'Brien
    7 hours ago



















4












$begingroup$


Dyalog APL, 9 bytes





=∨5∊+,∘|-


Try it online!



Spelled out:



  =   ∨  5      ∊                +   , ∘    |            -
equal or 5 found in an array of sum and absolute of difference.





share|improve this answer











$endgroup$





















    3












    $begingroup$


    PowerShell, 48 44 bytes





    param($a,$b)5-in($x=$b-$a),-$x,($a+$b)-or!$x


    Try it online!



    Takes input $a and $b. Checks if 5 is -in the group $b-$a, -$x ($a-$b), or $a+$b, stores the first into $x, and -ors the -in check with !$x to check equality.



    -4 bytes thanks to mazzy.






    share|improve this answer











    $endgroup$













    • $begingroup$
      ($a-$b) is -$x :)
      $endgroup$
      – mazzy
      7 hours ago










    • $begingroup$
      @mazzy Ooo, good call.
      $endgroup$
      – AdmBorkBork
      7 hours ago



















    3












    $begingroup$

    Python 2, 38 bytes



    -2 bytes thanks to @DjMcMayhem





    lambda a,b:a+b==5or abs(a-b)==5or a==b


    Try it online!






    share|improve this answer











    $endgroup$













    • $begingroup$
      Your TIO is actually 42 bytes but you can fix it by deleting the spaces between the 5s and the ors
      $endgroup$
      – ElPedro
      8 hours ago








    • 3




      $begingroup$
      Actually, the TIO link could be 38 bytes
      $endgroup$
      – DJMcMayhem
      8 hours ago










    • $begingroup$
      @ElPedro the function itself was 40 bytes but I used f= in order to be able to call it
      $endgroup$
      – fəˈnɛtɪk
      6 hours ago






    • 1




      $begingroup$
      @DJMcMayhem I don't normally golf in python. I just did it because the question asker used python for their example
      $endgroup$
      – fəˈnɛtɪk
      6 hours ago



















    3












    $begingroup$


    C# (.NET Core), 43, 48, 47, 33 bytes



    EDIT: Tried to use % and apparently forgot how to %. Thanks to Arnauld for pointing that out!



    EDIT2: AdmBorkBork with a -1 byte golf rearranging the parentheses to sit next to the return so no additional space is needed!



    EDIT3: Thanks to dana for -14 byte golf for the one-line return shortcut and currying the function (Ty Embodiment of Ignorance for linking to TIO).




    C# (.NET Core), 33 bytes





    a=>b=>a==b|a+b==5|(a-b)*(a-b)==25


    Try it online!






    share|improve this answer











    $endgroup$













    • $begingroup$
      Bah. Trying to avoid System.Math. Back to it! Thanks for pointing that out :D
      $endgroup$
      – Destroigo
      8 hours ago






    • 1




      $begingroup$
      You can get it down to 33 bytes applying dana's tips
      $endgroup$
      – Embodiment of Ignorance
      6 hours ago





















    3












    $begingroup$

    x86 machine code, 39 bytes



    00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
    00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6 .9..D.YZ).....D.
    00000020: 83f9 fb0f 44c6 c3 ....D..


    Assembly





    section .text
    global func
    func: ;inputs int32_t ecx and edx
    push 0x1
    pop esi
    push 0x5
    pop edi
    push edx
    push ecx
    xor eax, eax

    ;ecx==edx?
    cmp ecx, edx
    cmove eax, esi

    ;ecx+edx==5?
    add ecx, edx
    cmp edi, ecx
    cmove eax, esi

    ;ecx-edx==5?
    pop ecx
    pop edx
    sub ecx, edx
    cmp ecx, 5

    ;ecx-edx==-5?
    cmove eax, esi
    cmp ecx, -5
    cmove eax, esi

    ret


    Try it online!






    share|improve this answer









    $endgroup$





















      2












      $begingroup$


      Jelly, 7 bytes



      +,ạ5eo=


      Try it online!



      How it works



      +,ạ5eo=  Main link. Arguments: x, y (integers)

      + Yield x+y.
      ạ Yield |x-y|.
      , Pair; yield (x+y, |x-y|).
      5e Test fi 5 exists in the pair.
      = Test x and y for equality.
      o Logical OR.





      share|improve this answer









      $endgroup$





















        2












        $begingroup$


        Wolfram Language (Mathematica), 26 bytes



        !{#,5-#,#-5,#+5}~FreeQ~#2&


        Try it online!






        share|improve this answer









        $endgroup$





















          2












          $begingroup$


          C (gcc), 41 34 bytes





          f(a,b){a=5==abs(a-b)|a+b==5|a==b;}


          Try it online!






          share|improve this answer











          $endgroup$









          • 1




            $begingroup$
            Why does f return a? Just some Undefined Behavior?
            $endgroup$
            – Tyilo
            7 hours ago










          • $begingroup$
            @Tyilo Yes, it's implementation specific. So happens the first parameter is stored in the same register as the return value.
            $endgroup$
            – cleblanc
            7 hours ago










          • $begingroup$
            30 bytes Try it online!
            $endgroup$
            – Logern
            6 hours ago










          • $begingroup$
            @Logern Doesn't work for f(6,1)
            $endgroup$
            – cleblanc
            6 hours ago










          • $begingroup$
            @ceilingcat Doesn't work for f(6,1)
            $endgroup$
            – cleblanc
            6 hours ago



















          1












          $begingroup$

          Scala, 45 bytes





          def f(a:Int,b:Int)=a+b==5||(a-b).abs==5||a==b


          Try it online!






          share|improve this answer









          $endgroup$





















            1












            $begingroup$


            Tcl, 53 bytes



            proc P a b {expr abs($a-$b)==5|$a==$b|abs($a+$b)==5}


            Try it online!






            share|improve this answer











            $endgroup$













            • $begingroup$
              Same byte count: tio.run/##K0nO@f@/oCg/…
              $endgroup$
              – sergiol
              7 hours ago



















            1












            $begingroup$

            Japt, 13 12 bytes



            x ¥5|50ìøUra


            Try it or run all test cases



            x ¥5|50ìøUra
            :Implicit input of array U
            x :Reduce by addition
            ¥5 :Equal to 5?
            | :Bitwise OR
            50ì :Split 50 to an array of digits
            ø :Contains?
            Ur : Reduce U
            a : By absolute difference




            Alternative



            50ìø[Ux Ura]





            share|improve this answer











            $endgroup$





















              1












              $begingroup$


              Japt, 14 13 bytes



              ¥VªaU ¥5ª5¥Nx


              Try it online!






              share|improve this answer











              $endgroup$





















                1












                $begingroup$


                05AB1E, 13 12 bytes



                ÐO5Qs`α5QrËO


                Try it online!



                Takes input as a list of integers, saving one byte. Thanks @Wisław!



                Alternate 12 byte answer



                Q¹²α5Q¹²+5QO


                Try it online!



                This one takes input on separate lines.






                share|improve this answer











                $endgroup$









                • 1




                  $begingroup$
                  Since it is not very clearly specified, can you not assume the input is a list of integers, thus eliminating the initial |?
                  $endgroup$
                  – Wisław
                  7 hours ago










                • $begingroup$
                  @Wisław Good point, I updated my answer. Thanks!
                  $endgroup$
                  – Cowabunghole
                  7 hours ago










                • $begingroup$
                  I found a 11 bytes alternative: OI`αª5¢IË~Ā. Input is a list of integers.
                  $endgroup$
                  – Wisław
                  7 hours ago












                • $begingroup$
                  OIÆÄ)5QIËM is 10.
                  $endgroup$
                  – Magic Octopus Urn
                  6 hours ago






                • 1




                  $begingroup$
                  @MagicOctopusUrn I'm not sure exactly what the rules are but I think your solution is different enough from mine to submit your own answer, no? Also, unrelated but I've seen your username on this site for a long time but only after typing it out did I realize that it's "Urn", not "Um" :)
                  $endgroup$
                  – Cowabunghole
                  6 hours ago



















                1












                $begingroup$

                Batch, 81 bytes



                @set/as=%1+%2,d=%1-%2
                @if %d% neq 0 if %d:-=% neq 5 if %s% neq 5 exit/b
                @echo 1


                Takes input as command-line arguments and outputs 1 on success, nothing on failure. Batch can't easily do disjunctions so I use De Morgan's laws to turn it into a conjunction.






                share|improve this answer









                $endgroup$





















                  1












                  $begingroup$


                  05AB1E, 10 bytes



                  OIÆ‚Ä50SåZ


                  Try it online!





                  O           # Sum the input.
                  IÆ # Reduced subtraction of the input.
                  ‚ # Wrap [sum,reduced_subtraction]
                  Ä # abs[sum,red_sub]
                  50S # [5,0]
                  å # [5,0] in abs[sum,red_sub]?
                  Z # Max of result, 0 is false, 1 is true.


                  Tried to do it using stack-only operations, but it was longer.






                  share|improve this answer









                  $endgroup$













                  • $begingroup$
                    This will unfortunately return true if the sum is 0 such as for [5, -5]
                    $endgroup$
                    – Emigna
                    4 hours ago



















                  1












                  $begingroup$


                  Charcoal, 18 bytes



                  Nθ¿№⟦θ⁺⁵θ⁻⁵θ⁻θ⁵⟧N1


                  Try it online! Link is to verbose version of code. Port of @ArBo's Python 2 solution.






                  share|improve this answer









                  $endgroup$





















                    0












                    $begingroup$


                    Runic Enchantments, 30 bytes



                    i::i::}3s=?!@-'|A"5"n:}=?!@+=@


                    Try it online!



                    With a pending update, 4 bytes can be saved, as presently integer inputs are treated as doubles and don't equal integers of the same value. Hence "5"n instead of just 5. This was an oversight and several factors are being adjusted to account for it (such as using Approximately(a, b) instead of a.Equals(b)).



                    Outputs 0 (exactly one zero) for false and any other output (literally whatever is left on the stack) for true.






                    share|improve this answer









                    $endgroup$





















                      0












                      $begingroup$


                      Perl 5, 51 + 2 (-an) = 53 bytes



                      Pretty simple really. Outputs 0 for false, 1 for true. Not gonna lie, I don't know if bitwise OR is appropriate here, but is does work for all the test cases, so that's nice.





                      ($a,$b)=@F;print($a==$b|$a+$b==5|$a-$b==5|$b-$a==5)


                      Try it online!






                      share|improve this answer











                      $endgroup$





















                        0












                        $begingroup$


                        Java (JDK), 30 bytes





                        a->b->a+b==5|a==b|(b-=a)*b==25


                        Try it online!






                        share|improve this answer









                        $endgroup$





















                          0












                          $begingroup$


                          Retina 0.8.2, 82 bytes



                          d+
                          $*
                          ^(-?1*) 1$|^(-?1*)1{5} -?2$|^-?(-?1*) (3)1{5}$|^-?(1 ?){5}$|^(1 ?-?){5}$


                          Try it online! Link includes test cases. Explanation: The first two lines convert the inputs into unary. The final line then checks for any of the permitted matches:



                          ^(-?1*) 1$                              x==y
                          ^(-?1*)1{5} -?2$ x>=0 y>=0 x=5+y i.e. x-y=5
                          x>=0 y<=0 x=5-y i.e. x+y=5
                          x<=0 y<=0 x=y-5 i.e. y-x=5
                          ^-?(-?1*) (3)1{5}$ x<=0 y<=0 y=x-5 i.e. x-y=5
                          x<=0 y>=0 y=5-x i.e. x+y=5
                          x>=0 y>=0 y=5+x i.e. y-x=5
                          ^-?(1 ?){5}$ x>=0 y>=0 y=5-x i.e. x+y=5
                          x<=0 y>=0 y=5+x i.e. y-x=5
                          ^(1 ?-?){5}$ x>=0 y>=0 x=5-y i.e. x+y=5
                          x>=0 y<=0 x=5+y i.e. x-y=5


                          Pivoted by the last column we get:



                          x==y            ^(-?1*) 1$
                          x+y=5 x>=0 y>=0 ^-?(1 ?){5}$
                          x>=0 y>=0 ^(1 ?-?){5}$
                          x>=0 y<=0 ^(-?1*)1{5} -?2$
                          x<=0 y>=0 ^-?(-?1*) (3)1{5}$
                          x<=0 y<=0 (impossible)
                          x-y=5 x>=0 y>=0 ^(-?1*)1{5} -?2$
                          x>=0 y<=0 ^(1 ?-?){5}$
                          x<=0 y>=0 (impossible)
                          x<=0 y<=0 ^-?(-?1*) (3)1{5}$
                          y-x=5 x>=0 y>=0 ^-?(-?1*) (3)1{5}$
                          x>=0 y<=0 (impossible)
                          x<=0 y>=0 ^-?(1 ?){5}$
                          x<=0 y<=0 ^(-?1*)1{5} -?2$





                          share|improve this answer









                          $endgroup$













                            Your Answer





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

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

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

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

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


                            }
                            });






                            Vikrant Biswas 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%2f178792%2fequal-sum-or-difference%23new-answer', 'question_page');
                            }
                            );

                            Post as a guest















                            Required, but never shown

























                            24 Answers
                            24






                            active

                            oldest

                            votes








                            24 Answers
                            24






                            active

                            oldest

                            votes









                            active

                            oldest

                            votes






                            active

                            oldest

                            votes









                            10












                            $begingroup$


                            Python 2, 30 bytes





                            lambda a,b:a in(b,5-b,b-5,b+5)


                            Try it online!



                            One byte saved by Arnauld



                            Three bytes saved by alephalpha






                            share|improve this answer











                            $endgroup$









                            • 2




                              $begingroup$
                              lambda a,b:a in(b,5-b,b-5,b+5)
                              $endgroup$
                              – alephalpha
                              8 hours ago










                            • $begingroup$
                              This is amazingly concise, thanks
                              $endgroup$
                              – Vikrant Biswas
                              7 hours ago
















                            10












                            $begingroup$


                            Python 2, 30 bytes





                            lambda a,b:a in(b,5-b,b-5,b+5)


                            Try it online!



                            One byte saved by Arnauld



                            Three bytes saved by alephalpha






                            share|improve this answer











                            $endgroup$









                            • 2




                              $begingroup$
                              lambda a,b:a in(b,5-b,b-5,b+5)
                              $endgroup$
                              – alephalpha
                              8 hours ago










                            • $begingroup$
                              This is amazingly concise, thanks
                              $endgroup$
                              – Vikrant Biswas
                              7 hours ago














                            10












                            10








                            10





                            $begingroup$


                            Python 2, 30 bytes





                            lambda a,b:a in(b,5-b,b-5,b+5)


                            Try it online!



                            One byte saved by Arnauld



                            Three bytes saved by alephalpha






                            share|improve this answer











                            $endgroup$




                            Python 2, 30 bytes





                            lambda a,b:a in(b,5-b,b-5,b+5)


                            Try it online!



                            One byte saved by Arnauld



                            Three bytes saved by alephalpha







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 8 hours ago

























                            answered 8 hours ago









                            ArBoArBo

                            2115




                            2115








                            • 2




                              $begingroup$
                              lambda a,b:a in(b,5-b,b-5,b+5)
                              $endgroup$
                              – alephalpha
                              8 hours ago










                            • $begingroup$
                              This is amazingly concise, thanks
                              $endgroup$
                              – Vikrant Biswas
                              7 hours ago














                            • 2




                              $begingroup$
                              lambda a,b:a in(b,5-b,b-5,b+5)
                              $endgroup$
                              – alephalpha
                              8 hours ago










                            • $begingroup$
                              This is amazingly concise, thanks
                              $endgroup$
                              – Vikrant Biswas
                              7 hours ago








                            2




                            2




                            $begingroup$
                            lambda a,b:a in(b,5-b,b-5,b+5)
                            $endgroup$
                            – alephalpha
                            8 hours ago




                            $begingroup$
                            lambda a,b:a in(b,5-b,b-5,b+5)
                            $endgroup$
                            – alephalpha
                            8 hours ago












                            $begingroup$
                            This is amazingly concise, thanks
                            $endgroup$
                            – Vikrant Biswas
                            7 hours ago




                            $begingroup$
                            This is amazingly concise, thanks
                            $endgroup$
                            – Vikrant Biswas
                            7 hours ago











                            7












                            $begingroup$

                            JavaScript (ES6), 28 bytes



                            Takes input as (a)(b). Returns $0$ or $1$.





                            a=>b=>a+b==5|!(a-=b)|a*a==25


                            Try it online!






                            share|improve this answer











                            $endgroup$













                            • $begingroup$
                              Damn, took me a long long time to figure out how this handling the difference part. :)
                              $endgroup$
                              – Vikrant Biswas
                              5 hours ago
















                            7












                            $begingroup$

                            JavaScript (ES6), 28 bytes



                            Takes input as (a)(b). Returns $0$ or $1$.





                            a=>b=>a+b==5|!(a-=b)|a*a==25


                            Try it online!






                            share|improve this answer











                            $endgroup$













                            • $begingroup$
                              Damn, took me a long long time to figure out how this handling the difference part. :)
                              $endgroup$
                              – Vikrant Biswas
                              5 hours ago














                            7












                            7








                            7





                            $begingroup$

                            JavaScript (ES6), 28 bytes



                            Takes input as (a)(b). Returns $0$ or $1$.





                            a=>b=>a+b==5|!(a-=b)|a*a==25


                            Try it online!






                            share|improve this answer











                            $endgroup$



                            JavaScript (ES6), 28 bytes



                            Takes input as (a)(b). Returns $0$ or $1$.





                            a=>b=>a+b==5|!(a-=b)|a*a==25


                            Try it online!







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 8 hours ago

























                            answered 8 hours ago









                            ArnauldArnauld

                            73.3k689307




                            73.3k689307












                            • $begingroup$
                              Damn, took me a long long time to figure out how this handling the difference part. :)
                              $endgroup$
                              – Vikrant Biswas
                              5 hours ago


















                            • $begingroup$
                              Damn, took me a long long time to figure out how this handling the difference part. :)
                              $endgroup$
                              – Vikrant Biswas
                              5 hours ago
















                            $begingroup$
                            Damn, took me a long long time to figure out how this handling the difference part. :)
                            $endgroup$
                            – Vikrant Biswas
                            5 hours ago




                            $begingroup$
                            Damn, took me a long long time to figure out how this handling the difference part. :)
                            $endgroup$
                            – Vikrant Biswas
                            5 hours ago











                            5












                            $begingroup$


                            R, 40 bytes (or 34)





                            function(x,y)any((-1:1*5)%in%c(x+y,x-y))


                            Try it online!



                            For non-R users:





                            • -1:1*5 expands to [-5, 0, 5]

                            • the %in% operator takes elements from the left and checks (element-wise) if they exist in the vector on the right


                            A direct port of @ArBo's solution has 35 34 bytes, so go upvote that answer if you like it:



                            function(x,y)x%in%c(y--1:1*5,5-y)





                            share|improve this answer











                            $endgroup$













                            • $begingroup$
                              The 34 byte one can be reduced by 1 with function(x,y)x%in%c(y--1:1*5,5-y)
                              $endgroup$
                              – MickyT
                              3 hours ago
















                            5












                            $begingroup$


                            R, 40 bytes (or 34)





                            function(x,y)any((-1:1*5)%in%c(x+y,x-y))


                            Try it online!



                            For non-R users:





                            • -1:1*5 expands to [-5, 0, 5]

                            • the %in% operator takes elements from the left and checks (element-wise) if they exist in the vector on the right


                            A direct port of @ArBo's solution has 35 34 bytes, so go upvote that answer if you like it:



                            function(x,y)x%in%c(y--1:1*5,5-y)





                            share|improve this answer











                            $endgroup$













                            • $begingroup$
                              The 34 byte one can be reduced by 1 with function(x,y)x%in%c(y--1:1*5,5-y)
                              $endgroup$
                              – MickyT
                              3 hours ago














                            5












                            5








                            5





                            $begingroup$


                            R, 40 bytes (or 34)





                            function(x,y)any((-1:1*5)%in%c(x+y,x-y))


                            Try it online!



                            For non-R users:





                            • -1:1*5 expands to [-5, 0, 5]

                            • the %in% operator takes elements from the left and checks (element-wise) if they exist in the vector on the right


                            A direct port of @ArBo's solution has 35 34 bytes, so go upvote that answer if you like it:



                            function(x,y)x%in%c(y--1:1*5,5-y)





                            share|improve this answer











                            $endgroup$




                            R, 40 bytes (or 34)





                            function(x,y)any((-1:1*5)%in%c(x+y,x-y))


                            Try it online!



                            For non-R users:





                            • -1:1*5 expands to [-5, 0, 5]

                            • the %in% operator takes elements from the left and checks (element-wise) if they exist in the vector on the right


                            A direct port of @ArBo's solution has 35 34 bytes, so go upvote that answer if you like it:



                            function(x,y)x%in%c(y--1:1*5,5-y)






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 3 hours ago

























                            answered 6 hours ago









                            ngmngm

                            3,32924




                            3,32924












                            • $begingroup$
                              The 34 byte one can be reduced by 1 with function(x,y)x%in%c(y--1:1*5,5-y)
                              $endgroup$
                              – MickyT
                              3 hours ago


















                            • $begingroup$
                              The 34 byte one can be reduced by 1 with function(x,y)x%in%c(y--1:1*5,5-y)
                              $endgroup$
                              – MickyT
                              3 hours ago
















                            $begingroup$
                            The 34 byte one can be reduced by 1 with function(x,y)x%in%c(y--1:1*5,5-y)
                            $endgroup$
                            – MickyT
                            3 hours ago




                            $begingroup$
                            The 34 byte one can be reduced by 1 with function(x,y)x%in%c(y--1:1*5,5-y)
                            $endgroup$
                            – MickyT
                            3 hours ago











                            4












                            $begingroup$


                            J, 12 11 bytes



                            1 byte saved thanks to Adám



                            1#.=+5=|@-,+


                            Try it online!



                            Explanation



                            This is equivalent to:



                            1 #. = + 5 = |@- , +


                            This can be divided into the following fork chain:



                            (= + (5 e. (|@- , +)))


                            Or, visualized using 5!:4<'f':



                              ┌─ =               
                            ├─ +
                            ──┤ ┌─ 5
                            │ ├─ e.
                            └───┤ ┌─ |
                            │ ┌─ @ ─┴─ -
                            └────┼─ ,
                            └─ +


                            Annotated:



                              ┌─ =                                     equality
                            ├─ + added to (boolean or)
                            ──┤ ┌─ 5 noun 5
                            │ ├─ e. is an element of
                            └───┤ ┌─ | absolute value |
                            │ ┌─ @ ─┴─ - (of) subtraction |
                            └────┼─ , paired with |
                            └─ + addition | any of these?





                            share|improve this answer











                            $endgroup$













                            • $begingroup$
                              Save a byte with e.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám How so? Shortest approach I got with e. was =+.5 e.|@-,+. Maybe you forget 5e. is an invalid token in J?
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago










                            • $begingroup$
                              Since two integers cannot simultaneously sum to 5 and be equal, you can use + instead of +.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám Ah, I see, thank you.
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago
















                            4












                            $begingroup$


                            J, 12 11 bytes



                            1 byte saved thanks to Adám



                            1#.=+5=|@-,+


                            Try it online!



                            Explanation



                            This is equivalent to:



                            1 #. = + 5 = |@- , +


                            This can be divided into the following fork chain:



                            (= + (5 e. (|@- , +)))


                            Or, visualized using 5!:4<'f':



                              ┌─ =               
                            ├─ +
                            ──┤ ┌─ 5
                            │ ├─ e.
                            └───┤ ┌─ |
                            │ ┌─ @ ─┴─ -
                            └────┼─ ,
                            └─ +


                            Annotated:



                              ┌─ =                                     equality
                            ├─ + added to (boolean or)
                            ──┤ ┌─ 5 noun 5
                            │ ├─ e. is an element of
                            └───┤ ┌─ | absolute value |
                            │ ┌─ @ ─┴─ - (of) subtraction |
                            └────┼─ , paired with |
                            └─ + addition | any of these?





                            share|improve this answer











                            $endgroup$













                            • $begingroup$
                              Save a byte with e.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám How so? Shortest approach I got with e. was =+.5 e.|@-,+. Maybe you forget 5e. is an invalid token in J?
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago










                            • $begingroup$
                              Since two integers cannot simultaneously sum to 5 and be equal, you can use + instead of +.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám Ah, I see, thank you.
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago














                            4












                            4








                            4





                            $begingroup$


                            J, 12 11 bytes



                            1 byte saved thanks to Adám



                            1#.=+5=|@-,+


                            Try it online!



                            Explanation



                            This is equivalent to:



                            1 #. = + 5 = |@- , +


                            This can be divided into the following fork chain:



                            (= + (5 e. (|@- , +)))


                            Or, visualized using 5!:4<'f':



                              ┌─ =               
                            ├─ +
                            ──┤ ┌─ 5
                            │ ├─ e.
                            └───┤ ┌─ |
                            │ ┌─ @ ─┴─ -
                            └────┼─ ,
                            └─ +


                            Annotated:



                              ┌─ =                                     equality
                            ├─ + added to (boolean or)
                            ──┤ ┌─ 5 noun 5
                            │ ├─ e. is an element of
                            └───┤ ┌─ | absolute value |
                            │ ┌─ @ ─┴─ - (of) subtraction |
                            └────┼─ , paired with |
                            └─ + addition | any of these?





                            share|improve this answer











                            $endgroup$




                            J, 12 11 bytes



                            1 byte saved thanks to Adám



                            1#.=+5=|@-,+


                            Try it online!



                            Explanation



                            This is equivalent to:



                            1 #. = + 5 = |@- , +


                            This can be divided into the following fork chain:



                            (= + (5 e. (|@- , +)))


                            Or, visualized using 5!:4<'f':



                              ┌─ =               
                            ├─ +
                            ──┤ ┌─ 5
                            │ ├─ e.
                            └───┤ ┌─ |
                            │ ┌─ @ ─┴─ -
                            └────┼─ ,
                            └─ +


                            Annotated:



                              ┌─ =                                     equality
                            ├─ + added to (boolean or)
                            ──┤ ┌─ 5 noun 5
                            │ ├─ e. is an element of
                            └───┤ ┌─ | absolute value |
                            │ ┌─ @ ─┴─ - (of) subtraction |
                            └────┼─ , paired with |
                            └─ + addition | any of these?






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 7 hours ago

























                            answered 8 hours ago









                            Conor O'BrienConor O'Brien

                            29.2k263162




                            29.2k263162












                            • $begingroup$
                              Save a byte with e.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám How so? Shortest approach I got with e. was =+.5 e.|@-,+. Maybe you forget 5e. is an invalid token in J?
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago










                            • $begingroup$
                              Since two integers cannot simultaneously sum to 5 and be equal, you can use + instead of +.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám Ah, I see, thank you.
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago


















                            • $begingroup$
                              Save a byte with e.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám How so? Shortest approach I got with e. was =+.5 e.|@-,+. Maybe you forget 5e. is an invalid token in J?
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago










                            • $begingroup$
                              Since two integers cannot simultaneously sum to 5 and be equal, you can use + instead of +.
                              $endgroup$
                              – Adám
                              7 hours ago










                            • $begingroup$
                              @Adám Ah, I see, thank you.
                              $endgroup$
                              – Conor O'Brien
                              7 hours ago
















                            $begingroup$
                            Save a byte with e.
                            $endgroup$
                            – Adám
                            7 hours ago




                            $begingroup$
                            Save a byte with e.
                            $endgroup$
                            – Adám
                            7 hours ago












                            $begingroup$
                            @Adám How so? Shortest approach I got with e. was =+.5 e.|@-,+. Maybe you forget 5e. is an invalid token in J?
                            $endgroup$
                            – Conor O'Brien
                            7 hours ago




                            $begingroup$
                            @Adám How so? Shortest approach I got with e. was =+.5 e.|@-,+. Maybe you forget 5e. is an invalid token in J?
                            $endgroup$
                            – Conor O'Brien
                            7 hours ago












                            $begingroup$
                            Since two integers cannot simultaneously sum to 5 and be equal, you can use + instead of +.
                            $endgroup$
                            – Adám
                            7 hours ago




                            $begingroup$
                            Since two integers cannot simultaneously sum to 5 and be equal, you can use + instead of +.
                            $endgroup$
                            – Adám
                            7 hours ago












                            $begingroup$
                            @Adám Ah, I see, thank you.
                            $endgroup$
                            – Conor O'Brien
                            7 hours ago




                            $begingroup$
                            @Adám Ah, I see, thank you.
                            $endgroup$
                            – Conor O'Brien
                            7 hours ago











                            4












                            $begingroup$


                            Dyalog APL, 9 bytes





                            =∨5∊+,∘|-


                            Try it online!



                            Spelled out:



                              =   ∨  5      ∊                +   , ∘    |            -
                            equal or 5 found in an array of sum and absolute of difference.





                            share|improve this answer











                            $endgroup$


















                              4












                              $begingroup$


                              Dyalog APL, 9 bytes





                              =∨5∊+,∘|-


                              Try it online!



                              Spelled out:



                                =   ∨  5      ∊                +   , ∘    |            -
                              equal or 5 found in an array of sum and absolute of difference.





                              share|improve this answer











                              $endgroup$
















                                4












                                4








                                4





                                $begingroup$


                                Dyalog APL, 9 bytes





                                =∨5∊+,∘|-


                                Try it online!



                                Spelled out:



                                  =   ∨  5      ∊                +   , ∘    |            -
                                equal or 5 found in an array of sum and absolute of difference.





                                share|improve this answer











                                $endgroup$




                                Dyalog APL, 9 bytes





                                =∨5∊+,∘|-


                                Try it online!



                                Spelled out:



                                  =   ∨  5      ∊                +   , ∘    |            -
                                equal or 5 found in an array of sum and absolute of difference.






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 3 hours ago

























                                answered 8 hours ago









                                dzaimadzaima

                                14.6k21755




                                14.6k21755























                                    3












                                    $begingroup$


                                    PowerShell, 48 44 bytes





                                    param($a,$b)5-in($x=$b-$a),-$x,($a+$b)-or!$x


                                    Try it online!



                                    Takes input $a and $b. Checks if 5 is -in the group $b-$a, -$x ($a-$b), or $a+$b, stores the first into $x, and -ors the -in check with !$x to check equality.



                                    -4 bytes thanks to mazzy.






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      ($a-$b) is -$x :)
                                      $endgroup$
                                      – mazzy
                                      7 hours ago










                                    • $begingroup$
                                      @mazzy Ooo, good call.
                                      $endgroup$
                                      – AdmBorkBork
                                      7 hours ago
















                                    3












                                    $begingroup$


                                    PowerShell, 48 44 bytes





                                    param($a,$b)5-in($x=$b-$a),-$x,($a+$b)-or!$x


                                    Try it online!



                                    Takes input $a and $b. Checks if 5 is -in the group $b-$a, -$x ($a-$b), or $a+$b, stores the first into $x, and -ors the -in check with !$x to check equality.



                                    -4 bytes thanks to mazzy.






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      ($a-$b) is -$x :)
                                      $endgroup$
                                      – mazzy
                                      7 hours ago










                                    • $begingroup$
                                      @mazzy Ooo, good call.
                                      $endgroup$
                                      – AdmBorkBork
                                      7 hours ago














                                    3












                                    3








                                    3





                                    $begingroup$


                                    PowerShell, 48 44 bytes





                                    param($a,$b)5-in($x=$b-$a),-$x,($a+$b)-or!$x


                                    Try it online!



                                    Takes input $a and $b. Checks if 5 is -in the group $b-$a, -$x ($a-$b), or $a+$b, stores the first into $x, and -ors the -in check with !$x to check equality.



                                    -4 bytes thanks to mazzy.






                                    share|improve this answer











                                    $endgroup$




                                    PowerShell, 48 44 bytes





                                    param($a,$b)5-in($x=$b-$a),-$x,($a+$b)-or!$x


                                    Try it online!



                                    Takes input $a and $b. Checks if 5 is -in the group $b-$a, -$x ($a-$b), or $a+$b, stores the first into $x, and -ors the -in check with !$x to check equality.



                                    -4 bytes thanks to mazzy.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 7 hours ago

























                                    answered 8 hours ago









                                    AdmBorkBorkAdmBorkBork

                                    26.5k364229




                                    26.5k364229












                                    • $begingroup$
                                      ($a-$b) is -$x :)
                                      $endgroup$
                                      – mazzy
                                      7 hours ago










                                    • $begingroup$
                                      @mazzy Ooo, good call.
                                      $endgroup$
                                      – AdmBorkBork
                                      7 hours ago


















                                    • $begingroup$
                                      ($a-$b) is -$x :)
                                      $endgroup$
                                      – mazzy
                                      7 hours ago










                                    • $begingroup$
                                      @mazzy Ooo, good call.
                                      $endgroup$
                                      – AdmBorkBork
                                      7 hours ago
















                                    $begingroup$
                                    ($a-$b) is -$x :)
                                    $endgroup$
                                    – mazzy
                                    7 hours ago




                                    $begingroup$
                                    ($a-$b) is -$x :)
                                    $endgroup$
                                    – mazzy
                                    7 hours ago












                                    $begingroup$
                                    @mazzy Ooo, good call.
                                    $endgroup$
                                    – AdmBorkBork
                                    7 hours ago




                                    $begingroup$
                                    @mazzy Ooo, good call.
                                    $endgroup$
                                    – AdmBorkBork
                                    7 hours ago











                                    3












                                    $begingroup$

                                    Python 2, 38 bytes



                                    -2 bytes thanks to @DjMcMayhem





                                    lambda a,b:a+b==5or abs(a-b)==5or a==b


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      Your TIO is actually 42 bytes but you can fix it by deleting the spaces between the 5s and the ors
                                      $endgroup$
                                      – ElPedro
                                      8 hours ago








                                    • 3




                                      $begingroup$
                                      Actually, the TIO link could be 38 bytes
                                      $endgroup$
                                      – DJMcMayhem
                                      8 hours ago










                                    • $begingroup$
                                      @ElPedro the function itself was 40 bytes but I used f= in order to be able to call it
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago






                                    • 1




                                      $begingroup$
                                      @DJMcMayhem I don't normally golf in python. I just did it because the question asker used python for their example
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago
















                                    3












                                    $begingroup$

                                    Python 2, 38 bytes



                                    -2 bytes thanks to @DjMcMayhem





                                    lambda a,b:a+b==5or abs(a-b)==5or a==b


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      Your TIO is actually 42 bytes but you can fix it by deleting the spaces between the 5s and the ors
                                      $endgroup$
                                      – ElPedro
                                      8 hours ago








                                    • 3




                                      $begingroup$
                                      Actually, the TIO link could be 38 bytes
                                      $endgroup$
                                      – DJMcMayhem
                                      8 hours ago










                                    • $begingroup$
                                      @ElPedro the function itself was 40 bytes but I used f= in order to be able to call it
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago






                                    • 1




                                      $begingroup$
                                      @DJMcMayhem I don't normally golf in python. I just did it because the question asker used python for their example
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago














                                    3












                                    3








                                    3





                                    $begingroup$

                                    Python 2, 38 bytes



                                    -2 bytes thanks to @DjMcMayhem





                                    lambda a,b:a+b==5or abs(a-b)==5or a==b


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$



                                    Python 2, 38 bytes



                                    -2 bytes thanks to @DjMcMayhem





                                    lambda a,b:a+b==5or abs(a-b)==5or a==b


                                    Try it online!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 6 hours ago

























                                    answered 8 hours ago









                                    fəˈnɛtɪkfəˈnɛtɪk

                                    3,6431637




                                    3,6431637












                                    • $begingroup$
                                      Your TIO is actually 42 bytes but you can fix it by deleting the spaces between the 5s and the ors
                                      $endgroup$
                                      – ElPedro
                                      8 hours ago








                                    • 3




                                      $begingroup$
                                      Actually, the TIO link could be 38 bytes
                                      $endgroup$
                                      – DJMcMayhem
                                      8 hours ago










                                    • $begingroup$
                                      @ElPedro the function itself was 40 bytes but I used f= in order to be able to call it
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago






                                    • 1




                                      $begingroup$
                                      @DJMcMayhem I don't normally golf in python. I just did it because the question asker used python for their example
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago


















                                    • $begingroup$
                                      Your TIO is actually 42 bytes but you can fix it by deleting the spaces between the 5s and the ors
                                      $endgroup$
                                      – ElPedro
                                      8 hours ago








                                    • 3




                                      $begingroup$
                                      Actually, the TIO link could be 38 bytes
                                      $endgroup$
                                      – DJMcMayhem
                                      8 hours ago










                                    • $begingroup$
                                      @ElPedro the function itself was 40 bytes but I used f= in order to be able to call it
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago






                                    • 1




                                      $begingroup$
                                      @DJMcMayhem I don't normally golf in python. I just did it because the question asker used python for their example
                                      $endgroup$
                                      – fəˈnɛtɪk
                                      6 hours ago
















                                    $begingroup$
                                    Your TIO is actually 42 bytes but you can fix it by deleting the spaces between the 5s and the ors
                                    $endgroup$
                                    – ElPedro
                                    8 hours ago






                                    $begingroup$
                                    Your TIO is actually 42 bytes but you can fix it by deleting the spaces between the 5s and the ors
                                    $endgroup$
                                    – ElPedro
                                    8 hours ago






                                    3




                                    3




                                    $begingroup$
                                    Actually, the TIO link could be 38 bytes
                                    $endgroup$
                                    – DJMcMayhem
                                    8 hours ago




                                    $begingroup$
                                    Actually, the TIO link could be 38 bytes
                                    $endgroup$
                                    – DJMcMayhem
                                    8 hours ago












                                    $begingroup$
                                    @ElPedro the function itself was 40 bytes but I used f= in order to be able to call it
                                    $endgroup$
                                    – fəˈnɛtɪk
                                    6 hours ago




                                    $begingroup$
                                    @ElPedro the function itself was 40 bytes but I used f= in order to be able to call it
                                    $endgroup$
                                    – fəˈnɛtɪk
                                    6 hours ago




                                    1




                                    1




                                    $begingroup$
                                    @DJMcMayhem I don't normally golf in python. I just did it because the question asker used python for their example
                                    $endgroup$
                                    – fəˈnɛtɪk
                                    6 hours ago




                                    $begingroup$
                                    @DJMcMayhem I don't normally golf in python. I just did it because the question asker used python for their example
                                    $endgroup$
                                    – fəˈnɛtɪk
                                    6 hours ago











                                    3












                                    $begingroup$


                                    C# (.NET Core), 43, 48, 47, 33 bytes



                                    EDIT: Tried to use % and apparently forgot how to %. Thanks to Arnauld for pointing that out!



                                    EDIT2: AdmBorkBork with a -1 byte golf rearranging the parentheses to sit next to the return so no additional space is needed!



                                    EDIT3: Thanks to dana for -14 byte golf for the one-line return shortcut and currying the function (Ty Embodiment of Ignorance for linking to TIO).




                                    C# (.NET Core), 33 bytes





                                    a=>b=>a==b|a+b==5|(a-b)*(a-b)==25


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      Bah. Trying to avoid System.Math. Back to it! Thanks for pointing that out :D
                                      $endgroup$
                                      – Destroigo
                                      8 hours ago






                                    • 1




                                      $begingroup$
                                      You can get it down to 33 bytes applying dana's tips
                                      $endgroup$
                                      – Embodiment of Ignorance
                                      6 hours ago


















                                    3












                                    $begingroup$


                                    C# (.NET Core), 43, 48, 47, 33 bytes



                                    EDIT: Tried to use % and apparently forgot how to %. Thanks to Arnauld for pointing that out!



                                    EDIT2: AdmBorkBork with a -1 byte golf rearranging the parentheses to sit next to the return so no additional space is needed!



                                    EDIT3: Thanks to dana for -14 byte golf for the one-line return shortcut and currying the function (Ty Embodiment of Ignorance for linking to TIO).




                                    C# (.NET Core), 33 bytes





                                    a=>b=>a==b|a+b==5|(a-b)*(a-b)==25


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$













                                    • $begingroup$
                                      Bah. Trying to avoid System.Math. Back to it! Thanks for pointing that out :D
                                      $endgroup$
                                      – Destroigo
                                      8 hours ago






                                    • 1




                                      $begingroup$
                                      You can get it down to 33 bytes applying dana's tips
                                      $endgroup$
                                      – Embodiment of Ignorance
                                      6 hours ago
















                                    3












                                    3








                                    3





                                    $begingroup$


                                    C# (.NET Core), 43, 48, 47, 33 bytes



                                    EDIT: Tried to use % and apparently forgot how to %. Thanks to Arnauld for pointing that out!



                                    EDIT2: AdmBorkBork with a -1 byte golf rearranging the parentheses to sit next to the return so no additional space is needed!



                                    EDIT3: Thanks to dana for -14 byte golf for the one-line return shortcut and currying the function (Ty Embodiment of Ignorance for linking to TIO).




                                    C# (.NET Core), 33 bytes





                                    a=>b=>a==b|a+b==5|(a-b)*(a-b)==25


                                    Try it online!






                                    share|improve this answer











                                    $endgroup$




                                    C# (.NET Core), 43, 48, 47, 33 bytes



                                    EDIT: Tried to use % and apparently forgot how to %. Thanks to Arnauld for pointing that out!



                                    EDIT2: AdmBorkBork with a -1 byte golf rearranging the parentheses to sit next to the return so no additional space is needed!



                                    EDIT3: Thanks to dana for -14 byte golf for the one-line return shortcut and currying the function (Ty Embodiment of Ignorance for linking to TIO).




                                    C# (.NET Core), 33 bytes





                                    a=>b=>a==b|a+b==5|(a-b)*(a-b)==25


                                    Try it online!







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited 5 hours ago

























                                    answered 8 hours ago









                                    DestroigoDestroigo

                                    1815




                                    1815












                                    • $begingroup$
                                      Bah. Trying to avoid System.Math. Back to it! Thanks for pointing that out :D
                                      $endgroup$
                                      – Destroigo
                                      8 hours ago






                                    • 1




                                      $begingroup$
                                      You can get it down to 33 bytes applying dana's tips
                                      $endgroup$
                                      – Embodiment of Ignorance
                                      6 hours ago




















                                    • $begingroup$
                                      Bah. Trying to avoid System.Math. Back to it! Thanks for pointing that out :D
                                      $endgroup$
                                      – Destroigo
                                      8 hours ago






                                    • 1




                                      $begingroup$
                                      You can get it down to 33 bytes applying dana's tips
                                      $endgroup$
                                      – Embodiment of Ignorance
                                      6 hours ago


















                                    $begingroup$
                                    Bah. Trying to avoid System.Math. Back to it! Thanks for pointing that out :D
                                    $endgroup$
                                    – Destroigo
                                    8 hours ago




                                    $begingroup$
                                    Bah. Trying to avoid System.Math. Back to it! Thanks for pointing that out :D
                                    $endgroup$
                                    – Destroigo
                                    8 hours ago




                                    1




                                    1




                                    $begingroup$
                                    You can get it down to 33 bytes applying dana's tips
                                    $endgroup$
                                    – Embodiment of Ignorance
                                    6 hours ago






                                    $begingroup$
                                    You can get it down to 33 bytes applying dana's tips
                                    $endgroup$
                                    – Embodiment of Ignorance
                                    6 hours ago













                                    3












                                    $begingroup$

                                    x86 machine code, 39 bytes



                                    00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
                                    00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6 .9..D.YZ).....D.
                                    00000020: 83f9 fb0f 44c6 c3 ....D..


                                    Assembly





                                    section .text
                                    global func
                                    func: ;inputs int32_t ecx and edx
                                    push 0x1
                                    pop esi
                                    push 0x5
                                    pop edi
                                    push edx
                                    push ecx
                                    xor eax, eax

                                    ;ecx==edx?
                                    cmp ecx, edx
                                    cmove eax, esi

                                    ;ecx+edx==5?
                                    add ecx, edx
                                    cmp edi, ecx
                                    cmove eax, esi

                                    ;ecx-edx==5?
                                    pop ecx
                                    pop edx
                                    sub ecx, edx
                                    cmp ecx, 5

                                    ;ecx-edx==-5?
                                    cmove eax, esi
                                    cmp ecx, -5
                                    cmove eax, esi

                                    ret


                                    Try it online!






                                    share|improve this answer









                                    $endgroup$


















                                      3












                                      $begingroup$

                                      x86 machine code, 39 bytes



                                      00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
                                      00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6 .9..D.YZ).....D.
                                      00000020: 83f9 fb0f 44c6 c3 ....D..


                                      Assembly





                                      section .text
                                      global func
                                      func: ;inputs int32_t ecx and edx
                                      push 0x1
                                      pop esi
                                      push 0x5
                                      pop edi
                                      push edx
                                      push ecx
                                      xor eax, eax

                                      ;ecx==edx?
                                      cmp ecx, edx
                                      cmove eax, esi

                                      ;ecx+edx==5?
                                      add ecx, edx
                                      cmp edi, ecx
                                      cmove eax, esi

                                      ;ecx-edx==5?
                                      pop ecx
                                      pop edx
                                      sub ecx, edx
                                      cmp ecx, 5

                                      ;ecx-edx==-5?
                                      cmove eax, esi
                                      cmp ecx, -5
                                      cmove eax, esi

                                      ret


                                      Try it online!






                                      share|improve this answer









                                      $endgroup$
















                                        3












                                        3








                                        3





                                        $begingroup$

                                        x86 machine code, 39 bytes



                                        00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
                                        00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6 .9..D.YZ).....D.
                                        00000020: 83f9 fb0f 44c6 c3 ....D..


                                        Assembly





                                        section .text
                                        global func
                                        func: ;inputs int32_t ecx and edx
                                        push 0x1
                                        pop esi
                                        push 0x5
                                        pop edi
                                        push edx
                                        push ecx
                                        xor eax, eax

                                        ;ecx==edx?
                                        cmp ecx, edx
                                        cmove eax, esi

                                        ;ecx+edx==5?
                                        add ecx, edx
                                        cmp edi, ecx
                                        cmove eax, esi

                                        ;ecx-edx==5?
                                        pop ecx
                                        pop edx
                                        sub ecx, edx
                                        cmp ecx, 5

                                        ;ecx-edx==-5?
                                        cmove eax, esi
                                        cmp ecx, -5
                                        cmove eax, esi

                                        ret


                                        Try it online!






                                        share|improve this answer









                                        $endgroup$



                                        x86 machine code, 39 bytes



                                        00000000: 6a01 5e6a 055f 5251 31c0 39d1 0f44 c601  j.^j._RQ1.9..D..
                                        00000010: d139 cf0f 44c6 595a 29d1 83f9 050f 44c6 .9..D.YZ).....D.
                                        00000020: 83f9 fb0f 44c6 c3 ....D..


                                        Assembly





                                        section .text
                                        global func
                                        func: ;inputs int32_t ecx and edx
                                        push 0x1
                                        pop esi
                                        push 0x5
                                        pop edi
                                        push edx
                                        push ecx
                                        xor eax, eax

                                        ;ecx==edx?
                                        cmp ecx, edx
                                        cmove eax, esi

                                        ;ecx+edx==5?
                                        add ecx, edx
                                        cmp edi, ecx
                                        cmove eax, esi

                                        ;ecx-edx==5?
                                        pop ecx
                                        pop edx
                                        sub ecx, edx
                                        cmp ecx, 5

                                        ;ecx-edx==-5?
                                        cmove eax, esi
                                        cmp ecx, -5
                                        cmove eax, esi

                                        ret


                                        Try it online!







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered 5 hours ago









                                        LogernLogern

                                        75546




                                        75546























                                            2












                                            $begingroup$


                                            Jelly, 7 bytes



                                            +,ạ5eo=


                                            Try it online!



                                            How it works



                                            +,ạ5eo=  Main link. Arguments: x, y (integers)

                                            + Yield x+y.
                                            ạ Yield |x-y|.
                                            , Pair; yield (x+y, |x-y|).
                                            5e Test fi 5 exists in the pair.
                                            = Test x and y for equality.
                                            o Logical OR.





                                            share|improve this answer









                                            $endgroup$


















                                              2












                                              $begingroup$


                                              Jelly, 7 bytes



                                              +,ạ5eo=


                                              Try it online!



                                              How it works



                                              +,ạ5eo=  Main link. Arguments: x, y (integers)

                                              + Yield x+y.
                                              ạ Yield |x-y|.
                                              , Pair; yield (x+y, |x-y|).
                                              5e Test fi 5 exists in the pair.
                                              = Test x and y for equality.
                                              o Logical OR.





                                              share|improve this answer









                                              $endgroup$
















                                                2












                                                2








                                                2





                                                $begingroup$


                                                Jelly, 7 bytes



                                                +,ạ5eo=


                                                Try it online!



                                                How it works



                                                +,ạ5eo=  Main link. Arguments: x, y (integers)

                                                + Yield x+y.
                                                ạ Yield |x-y|.
                                                , Pair; yield (x+y, |x-y|).
                                                5e Test fi 5 exists in the pair.
                                                = Test x and y for equality.
                                                o Logical OR.





                                                share|improve this answer









                                                $endgroup$




                                                Jelly, 7 bytes



                                                +,ạ5eo=


                                                Try it online!



                                                How it works



                                                +,ạ5eo=  Main link. Arguments: x, y (integers)

                                                + Yield x+y.
                                                ạ Yield |x-y|.
                                                , Pair; yield (x+y, |x-y|).
                                                5e Test fi 5 exists in the pair.
                                                = Test x and y for equality.
                                                o Logical OR.






                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered 8 hours ago









                                                DennisDennis

                                                187k32297736




                                                187k32297736























                                                    2












                                                    $begingroup$


                                                    Wolfram Language (Mathematica), 26 bytes



                                                    !{#,5-#,#-5,#+5}~FreeQ~#2&


                                                    Try it online!






                                                    share|improve this answer









                                                    $endgroup$


















                                                      2












                                                      $begingroup$


                                                      Wolfram Language (Mathematica), 26 bytes



                                                      !{#,5-#,#-5,#+5}~FreeQ~#2&


                                                      Try it online!






                                                      share|improve this answer









                                                      $endgroup$
















                                                        2












                                                        2








                                                        2





                                                        $begingroup$


                                                        Wolfram Language (Mathematica), 26 bytes



                                                        !{#,5-#,#-5,#+5}~FreeQ~#2&


                                                        Try it online!






                                                        share|improve this answer









                                                        $endgroup$




                                                        Wolfram Language (Mathematica), 26 bytes



                                                        !{#,5-#,#-5,#+5}~FreeQ~#2&


                                                        Try it online!







                                                        share|improve this answer












                                                        share|improve this answer



                                                        share|improve this answer










                                                        answered 8 hours ago









                                                        alephalphaalephalpha

                                                        21.2k32991




                                                        21.2k32991























                                                            2












                                                            $begingroup$


                                                            C (gcc), 41 34 bytes





                                                            f(a,b){a=5==abs(a-b)|a+b==5|a==b;}


                                                            Try it online!






                                                            share|improve this answer











                                                            $endgroup$









                                                            • 1




                                                              $begingroup$
                                                              Why does f return a? Just some Undefined Behavior?
                                                              $endgroup$
                                                              – Tyilo
                                                              7 hours ago










                                                            • $begingroup$
                                                              @Tyilo Yes, it's implementation specific. So happens the first parameter is stored in the same register as the return value.
                                                              $endgroup$
                                                              – cleblanc
                                                              7 hours ago










                                                            • $begingroup$
                                                              30 bytes Try it online!
                                                              $endgroup$
                                                              – Logern
                                                              6 hours ago










                                                            • $begingroup$
                                                              @Logern Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago










                                                            • $begingroup$
                                                              @ceilingcat Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago
















                                                            2












                                                            $begingroup$


                                                            C (gcc), 41 34 bytes





                                                            f(a,b){a=5==abs(a-b)|a+b==5|a==b;}


                                                            Try it online!






                                                            share|improve this answer











                                                            $endgroup$









                                                            • 1




                                                              $begingroup$
                                                              Why does f return a? Just some Undefined Behavior?
                                                              $endgroup$
                                                              – Tyilo
                                                              7 hours ago










                                                            • $begingroup$
                                                              @Tyilo Yes, it's implementation specific. So happens the first parameter is stored in the same register as the return value.
                                                              $endgroup$
                                                              – cleblanc
                                                              7 hours ago










                                                            • $begingroup$
                                                              30 bytes Try it online!
                                                              $endgroup$
                                                              – Logern
                                                              6 hours ago










                                                            • $begingroup$
                                                              @Logern Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago










                                                            • $begingroup$
                                                              @ceilingcat Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago














                                                            2












                                                            2








                                                            2





                                                            $begingroup$


                                                            C (gcc), 41 34 bytes





                                                            f(a,b){a=5==abs(a-b)|a+b==5|a==b;}


                                                            Try it online!






                                                            share|improve this answer











                                                            $endgroup$




                                                            C (gcc), 41 34 bytes





                                                            f(a,b){a=5==abs(a-b)|a+b==5|a==b;}


                                                            Try it online!







                                                            share|improve this answer














                                                            share|improve this answer



                                                            share|improve this answer








                                                            edited 7 hours ago

























                                                            answered 8 hours ago









                                                            cleblanccleblanc

                                                            3,200316




                                                            3,200316








                                                            • 1




                                                              $begingroup$
                                                              Why does f return a? Just some Undefined Behavior?
                                                              $endgroup$
                                                              – Tyilo
                                                              7 hours ago










                                                            • $begingroup$
                                                              @Tyilo Yes, it's implementation specific. So happens the first parameter is stored in the same register as the return value.
                                                              $endgroup$
                                                              – cleblanc
                                                              7 hours ago










                                                            • $begingroup$
                                                              30 bytes Try it online!
                                                              $endgroup$
                                                              – Logern
                                                              6 hours ago










                                                            • $begingroup$
                                                              @Logern Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago










                                                            • $begingroup$
                                                              @ceilingcat Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago














                                                            • 1




                                                              $begingroup$
                                                              Why does f return a? Just some Undefined Behavior?
                                                              $endgroup$
                                                              – Tyilo
                                                              7 hours ago










                                                            • $begingroup$
                                                              @Tyilo Yes, it's implementation specific. So happens the first parameter is stored in the same register as the return value.
                                                              $endgroup$
                                                              – cleblanc
                                                              7 hours ago










                                                            • $begingroup$
                                                              30 bytes Try it online!
                                                              $endgroup$
                                                              – Logern
                                                              6 hours ago










                                                            • $begingroup$
                                                              @Logern Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago










                                                            • $begingroup$
                                                              @ceilingcat Doesn't work for f(6,1)
                                                              $endgroup$
                                                              – cleblanc
                                                              6 hours ago








                                                            1




                                                            1




                                                            $begingroup$
                                                            Why does f return a? Just some Undefined Behavior?
                                                            $endgroup$
                                                            – Tyilo
                                                            7 hours ago




                                                            $begingroup$
                                                            Why does f return a? Just some Undefined Behavior?
                                                            $endgroup$
                                                            – Tyilo
                                                            7 hours ago












                                                            $begingroup$
                                                            @Tyilo Yes, it's implementation specific. So happens the first parameter is stored in the same register as the return value.
                                                            $endgroup$
                                                            – cleblanc
                                                            7 hours ago




                                                            $begingroup$
                                                            @Tyilo Yes, it's implementation specific. So happens the first parameter is stored in the same register as the return value.
                                                            $endgroup$
                                                            – cleblanc
                                                            7 hours ago












                                                            $begingroup$
                                                            30 bytes Try it online!
                                                            $endgroup$
                                                            – Logern
                                                            6 hours ago




                                                            $begingroup$
                                                            30 bytes Try it online!
                                                            $endgroup$
                                                            – Logern
                                                            6 hours ago












                                                            $begingroup$
                                                            @Logern Doesn't work for f(6,1)
                                                            $endgroup$
                                                            – cleblanc
                                                            6 hours ago




                                                            $begingroup$
                                                            @Logern Doesn't work for f(6,1)
                                                            $endgroup$
                                                            – cleblanc
                                                            6 hours ago












                                                            $begingroup$
                                                            @ceilingcat Doesn't work for f(6,1)
                                                            $endgroup$
                                                            – cleblanc
                                                            6 hours ago




                                                            $begingroup$
                                                            @ceilingcat Doesn't work for f(6,1)
                                                            $endgroup$
                                                            – cleblanc
                                                            6 hours ago











                                                            1












                                                            $begingroup$

                                                            Scala, 45 bytes





                                                            def f(a:Int,b:Int)=a+b==5||(a-b).abs==5||a==b


                                                            Try it online!






                                                            share|improve this answer









                                                            $endgroup$


















                                                              1












                                                              $begingroup$

                                                              Scala, 45 bytes





                                                              def f(a:Int,b:Int)=a+b==5||(a-b).abs==5||a==b


                                                              Try it online!






                                                              share|improve this answer









                                                              $endgroup$
















                                                                1












                                                                1








                                                                1





                                                                $begingroup$

                                                                Scala, 45 bytes





                                                                def f(a:Int,b:Int)=a+b==5||(a-b).abs==5||a==b


                                                                Try it online!






                                                                share|improve this answer









                                                                $endgroup$



                                                                Scala, 45 bytes





                                                                def f(a:Int,b:Int)=a+b==5||(a-b).abs==5||a==b


                                                                Try it online!







                                                                share|improve this answer












                                                                share|improve this answer



                                                                share|improve this answer










                                                                answered 8 hours ago









                                                                Xavier GuihotXavier Guihot

                                                                2037




                                                                2037























                                                                    1












                                                                    $begingroup$


                                                                    Tcl, 53 bytes



                                                                    proc P a b {expr abs($a-$b)==5|$a==$b|abs($a+$b)==5}


                                                                    Try it online!






                                                                    share|improve this answer











                                                                    $endgroup$













                                                                    • $begingroup$
                                                                      Same byte count: tio.run/##K0nO@f@/oCg/…
                                                                      $endgroup$
                                                                      – sergiol
                                                                      7 hours ago
















                                                                    1












                                                                    $begingroup$


                                                                    Tcl, 53 bytes



                                                                    proc P a b {expr abs($a-$b)==5|$a==$b|abs($a+$b)==5}


                                                                    Try it online!






                                                                    share|improve this answer











                                                                    $endgroup$













                                                                    • $begingroup$
                                                                      Same byte count: tio.run/##K0nO@f@/oCg/…
                                                                      $endgroup$
                                                                      – sergiol
                                                                      7 hours ago














                                                                    1












                                                                    1








                                                                    1





                                                                    $begingroup$


                                                                    Tcl, 53 bytes



                                                                    proc P a b {expr abs($a-$b)==5|$a==$b|abs($a+$b)==5}


                                                                    Try it online!






                                                                    share|improve this answer











                                                                    $endgroup$




                                                                    Tcl, 53 bytes



                                                                    proc P a b {expr abs($a-$b)==5|$a==$b|abs($a+$b)==5}


                                                                    Try it online!







                                                                    share|improve this answer














                                                                    share|improve this answer



                                                                    share|improve this answer








                                                                    edited 7 hours ago

























                                                                    answered 8 hours ago









                                                                    sergiolsergiol

                                                                    2,5271925




                                                                    2,5271925












                                                                    • $begingroup$
                                                                      Same byte count: tio.run/##K0nO@f@/oCg/…
                                                                      $endgroup$
                                                                      – sergiol
                                                                      7 hours ago


















                                                                    • $begingroup$
                                                                      Same byte count: tio.run/##K0nO@f@/oCg/…
                                                                      $endgroup$
                                                                      – sergiol
                                                                      7 hours ago
















                                                                    $begingroup$
                                                                    Same byte count: tio.run/##K0nO@f@/oCg/…
                                                                    $endgroup$
                                                                    – sergiol
                                                                    7 hours ago




                                                                    $begingroup$
                                                                    Same byte count: tio.run/##K0nO@f@/oCg/…
                                                                    $endgroup$
                                                                    – sergiol
                                                                    7 hours ago











                                                                    1












                                                                    $begingroup$

                                                                    Japt, 13 12 bytes



                                                                    x ¥5|50ìøUra


                                                                    Try it or run all test cases



                                                                    x ¥5|50ìøUra
                                                                    :Implicit input of array U
                                                                    x :Reduce by addition
                                                                    ¥5 :Equal to 5?
                                                                    | :Bitwise OR
                                                                    50ì :Split 50 to an array of digits
                                                                    ø :Contains?
                                                                    Ur : Reduce U
                                                                    a : By absolute difference




                                                                    Alternative



                                                                    50ìø[Ux Ura]





                                                                    share|improve this answer











                                                                    $endgroup$


















                                                                      1












                                                                      $begingroup$

                                                                      Japt, 13 12 bytes



                                                                      x ¥5|50ìøUra


                                                                      Try it or run all test cases



                                                                      x ¥5|50ìøUra
                                                                      :Implicit input of array U
                                                                      x :Reduce by addition
                                                                      ¥5 :Equal to 5?
                                                                      | :Bitwise OR
                                                                      50ì :Split 50 to an array of digits
                                                                      ø :Contains?
                                                                      Ur : Reduce U
                                                                      a : By absolute difference




                                                                      Alternative



                                                                      50ìø[Ux Ura]





                                                                      share|improve this answer











                                                                      $endgroup$
















                                                                        1












                                                                        1








                                                                        1





                                                                        $begingroup$

                                                                        Japt, 13 12 bytes



                                                                        x ¥5|50ìøUra


                                                                        Try it or run all test cases



                                                                        x ¥5|50ìøUra
                                                                        :Implicit input of array U
                                                                        x :Reduce by addition
                                                                        ¥5 :Equal to 5?
                                                                        | :Bitwise OR
                                                                        50ì :Split 50 to an array of digits
                                                                        ø :Contains?
                                                                        Ur : Reduce U
                                                                        a : By absolute difference




                                                                        Alternative



                                                                        50ìø[Ux Ura]





                                                                        share|improve this answer











                                                                        $endgroup$



                                                                        Japt, 13 12 bytes



                                                                        x ¥5|50ìøUra


                                                                        Try it or run all test cases



                                                                        x ¥5|50ìøUra
                                                                        :Implicit input of array U
                                                                        x :Reduce by addition
                                                                        ¥5 :Equal to 5?
                                                                        | :Bitwise OR
                                                                        50ì :Split 50 to an array of digits
                                                                        ø :Contains?
                                                                        Ur : Reduce U
                                                                        a : By absolute difference




                                                                        Alternative



                                                                        50ìø[Ux Ura]






                                                                        share|improve this answer














                                                                        share|improve this answer



                                                                        share|improve this answer








                                                                        edited 7 hours ago

























                                                                        answered 8 hours ago









                                                                        ShaggyShaggy

                                                                        19.2k21666




                                                                        19.2k21666























                                                                            1












                                                                            $begingroup$


                                                                            Japt, 14 13 bytes



                                                                            ¥VªaU ¥5ª5¥Nx


                                                                            Try it online!






                                                                            share|improve this answer











                                                                            $endgroup$


















                                                                              1












                                                                              $begingroup$


                                                                              Japt, 14 13 bytes



                                                                              ¥VªaU ¥5ª5¥Nx


                                                                              Try it online!






                                                                              share|improve this answer











                                                                              $endgroup$
















                                                                                1












                                                                                1








                                                                                1





                                                                                $begingroup$


                                                                                Japt, 14 13 bytes



                                                                                ¥VªaU ¥5ª5¥Nx


                                                                                Try it online!






                                                                                share|improve this answer











                                                                                $endgroup$




                                                                                Japt, 14 13 bytes



                                                                                ¥VªaU ¥5ª5¥Nx


                                                                                Try it online!







                                                                                share|improve this answer














                                                                                share|improve this answer



                                                                                share|improve this answer








                                                                                edited 7 hours ago

























                                                                                answered 8 hours ago









                                                                                OliverOliver

                                                                                4,7701831




                                                                                4,7701831























                                                                                    1












                                                                                    $begingroup$


                                                                                    05AB1E, 13 12 bytes



                                                                                    ÐO5Qs`α5QrËO


                                                                                    Try it online!



                                                                                    Takes input as a list of integers, saving one byte. Thanks @Wisław!



                                                                                    Alternate 12 byte answer



                                                                                    Q¹²α5Q¹²+5QO


                                                                                    Try it online!



                                                                                    This one takes input on separate lines.






                                                                                    share|improve this answer











                                                                                    $endgroup$









                                                                                    • 1




                                                                                      $begingroup$
                                                                                      Since it is not very clearly specified, can you not assume the input is a list of integers, thus eliminating the initial |?
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      @Wisław Good point, I updated my answer. Thanks!
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      I found a 11 bytes alternative: OI`αª5¢IË~Ā. Input is a list of integers.
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago












                                                                                    • $begingroup$
                                                                                      OIÆÄ)5QIËM is 10.
                                                                                      $endgroup$
                                                                                      – Magic Octopus Urn
                                                                                      6 hours ago






                                                                                    • 1




                                                                                      $begingroup$
                                                                                      @MagicOctopusUrn I'm not sure exactly what the rules are but I think your solution is different enough from mine to submit your own answer, no? Also, unrelated but I've seen your username on this site for a long time but only after typing it out did I realize that it's "Urn", not "Um" :)
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      6 hours ago
















                                                                                    1












                                                                                    $begingroup$


                                                                                    05AB1E, 13 12 bytes



                                                                                    ÐO5Qs`α5QrËO


                                                                                    Try it online!



                                                                                    Takes input as a list of integers, saving one byte. Thanks @Wisław!



                                                                                    Alternate 12 byte answer



                                                                                    Q¹²α5Q¹²+5QO


                                                                                    Try it online!



                                                                                    This one takes input on separate lines.






                                                                                    share|improve this answer











                                                                                    $endgroup$









                                                                                    • 1




                                                                                      $begingroup$
                                                                                      Since it is not very clearly specified, can you not assume the input is a list of integers, thus eliminating the initial |?
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      @Wisław Good point, I updated my answer. Thanks!
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      I found a 11 bytes alternative: OI`αª5¢IË~Ā. Input is a list of integers.
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago












                                                                                    • $begingroup$
                                                                                      OIÆÄ)5QIËM is 10.
                                                                                      $endgroup$
                                                                                      – Magic Octopus Urn
                                                                                      6 hours ago






                                                                                    • 1




                                                                                      $begingroup$
                                                                                      @MagicOctopusUrn I'm not sure exactly what the rules are but I think your solution is different enough from mine to submit your own answer, no? Also, unrelated but I've seen your username on this site for a long time but only after typing it out did I realize that it's "Urn", not "Um" :)
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      6 hours ago














                                                                                    1












                                                                                    1








                                                                                    1





                                                                                    $begingroup$


                                                                                    05AB1E, 13 12 bytes



                                                                                    ÐO5Qs`α5QrËO


                                                                                    Try it online!



                                                                                    Takes input as a list of integers, saving one byte. Thanks @Wisław!



                                                                                    Alternate 12 byte answer



                                                                                    Q¹²α5Q¹²+5QO


                                                                                    Try it online!



                                                                                    This one takes input on separate lines.






                                                                                    share|improve this answer











                                                                                    $endgroup$




                                                                                    05AB1E, 13 12 bytes



                                                                                    ÐO5Qs`α5QrËO


                                                                                    Try it online!



                                                                                    Takes input as a list of integers, saving one byte. Thanks @Wisław!



                                                                                    Alternate 12 byte answer



                                                                                    Q¹²α5Q¹²+5QO


                                                                                    Try it online!



                                                                                    This one takes input on separate lines.







                                                                                    share|improve this answer














                                                                                    share|improve this answer



                                                                                    share|improve this answer








                                                                                    edited 7 hours ago

























                                                                                    answered 7 hours ago









                                                                                    CowabungholeCowabunghole

                                                                                    1,075419




                                                                                    1,075419








                                                                                    • 1




                                                                                      $begingroup$
                                                                                      Since it is not very clearly specified, can you not assume the input is a list of integers, thus eliminating the initial |?
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      @Wisław Good point, I updated my answer. Thanks!
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      I found a 11 bytes alternative: OI`αª5¢IË~Ā. Input is a list of integers.
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago












                                                                                    • $begingroup$
                                                                                      OIÆÄ)5QIËM is 10.
                                                                                      $endgroup$
                                                                                      – Magic Octopus Urn
                                                                                      6 hours ago






                                                                                    • 1




                                                                                      $begingroup$
                                                                                      @MagicOctopusUrn I'm not sure exactly what the rules are but I think your solution is different enough from mine to submit your own answer, no? Also, unrelated but I've seen your username on this site for a long time but only after typing it out did I realize that it's "Urn", not "Um" :)
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      6 hours ago














                                                                                    • 1




                                                                                      $begingroup$
                                                                                      Since it is not very clearly specified, can you not assume the input is a list of integers, thus eliminating the initial |?
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      @Wisław Good point, I updated my answer. Thanks!
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      7 hours ago










                                                                                    • $begingroup$
                                                                                      I found a 11 bytes alternative: OI`αª5¢IË~Ā. Input is a list of integers.
                                                                                      $endgroup$
                                                                                      – Wisław
                                                                                      7 hours ago












                                                                                    • $begingroup$
                                                                                      OIÆÄ)5QIËM is 10.
                                                                                      $endgroup$
                                                                                      – Magic Octopus Urn
                                                                                      6 hours ago






                                                                                    • 1




                                                                                      $begingroup$
                                                                                      @MagicOctopusUrn I'm not sure exactly what the rules are but I think your solution is different enough from mine to submit your own answer, no? Also, unrelated but I've seen your username on this site for a long time but only after typing it out did I realize that it's "Urn", not "Um" :)
                                                                                      $endgroup$
                                                                                      – Cowabunghole
                                                                                      6 hours ago








                                                                                    1




                                                                                    1




                                                                                    $begingroup$
                                                                                    Since it is not very clearly specified, can you not assume the input is a list of integers, thus eliminating the initial |?
                                                                                    $endgroup$
                                                                                    – Wisław
                                                                                    7 hours ago




                                                                                    $begingroup$
                                                                                    Since it is not very clearly specified, can you not assume the input is a list of integers, thus eliminating the initial |?
                                                                                    $endgroup$
                                                                                    – Wisław
                                                                                    7 hours ago












                                                                                    $begingroup$
                                                                                    @Wisław Good point, I updated my answer. Thanks!
                                                                                    $endgroup$
                                                                                    – Cowabunghole
                                                                                    7 hours ago




                                                                                    $begingroup$
                                                                                    @Wisław Good point, I updated my answer. Thanks!
                                                                                    $endgroup$
                                                                                    – Cowabunghole
                                                                                    7 hours ago












                                                                                    $begingroup$
                                                                                    I found a 11 bytes alternative: OI`αª5¢IË~Ā. Input is a list of integers.
                                                                                    $endgroup$
                                                                                    – Wisław
                                                                                    7 hours ago






                                                                                    $begingroup$
                                                                                    I found a 11 bytes alternative: OI`αª5¢IË~Ā. Input is a list of integers.
                                                                                    $endgroup$
                                                                                    – Wisław
                                                                                    7 hours ago














                                                                                    $begingroup$
                                                                                    OIÆÄ)5QIËM is 10.
                                                                                    $endgroup$
                                                                                    – Magic Octopus Urn
                                                                                    6 hours ago




                                                                                    $begingroup$
                                                                                    OIÆÄ)5QIËM is 10.
                                                                                    $endgroup$
                                                                                    – Magic Octopus Urn
                                                                                    6 hours ago




                                                                                    1




                                                                                    1




                                                                                    $begingroup$
                                                                                    @MagicOctopusUrn I'm not sure exactly what the rules are but I think your solution is different enough from mine to submit your own answer, no? Also, unrelated but I've seen your username on this site for a long time but only after typing it out did I realize that it's "Urn", not "Um" :)
                                                                                    $endgroup$
                                                                                    – Cowabunghole
                                                                                    6 hours ago




                                                                                    $begingroup$
                                                                                    @MagicOctopusUrn I'm not sure exactly what the rules are but I think your solution is different enough from mine to submit your own answer, no? Also, unrelated but I've seen your username on this site for a long time but only after typing it out did I realize that it's "Urn", not "Um" :)
                                                                                    $endgroup$
                                                                                    – Cowabunghole
                                                                                    6 hours ago











                                                                                    1












                                                                                    $begingroup$

                                                                                    Batch, 81 bytes



                                                                                    @set/as=%1+%2,d=%1-%2
                                                                                    @if %d% neq 0 if %d:-=% neq 5 if %s% neq 5 exit/b
                                                                                    @echo 1


                                                                                    Takes input as command-line arguments and outputs 1 on success, nothing on failure. Batch can't easily do disjunctions so I use De Morgan's laws to turn it into a conjunction.






                                                                                    share|improve this answer









                                                                                    $endgroup$


















                                                                                      1












                                                                                      $begingroup$

                                                                                      Batch, 81 bytes



                                                                                      @set/as=%1+%2,d=%1-%2
                                                                                      @if %d% neq 0 if %d:-=% neq 5 if %s% neq 5 exit/b
                                                                                      @echo 1


                                                                                      Takes input as command-line arguments and outputs 1 on success, nothing on failure. Batch can't easily do disjunctions so I use De Morgan's laws to turn it into a conjunction.






                                                                                      share|improve this answer









                                                                                      $endgroup$
















                                                                                        1












                                                                                        1








                                                                                        1





                                                                                        $begingroup$

                                                                                        Batch, 81 bytes



                                                                                        @set/as=%1+%2,d=%1-%2
                                                                                        @if %d% neq 0 if %d:-=% neq 5 if %s% neq 5 exit/b
                                                                                        @echo 1


                                                                                        Takes input as command-line arguments and outputs 1 on success, nothing on failure. Batch can't easily do disjunctions so I use De Morgan's laws to turn it into a conjunction.






                                                                                        share|improve this answer









                                                                                        $endgroup$



                                                                                        Batch, 81 bytes



                                                                                        @set/as=%1+%2,d=%1-%2
                                                                                        @if %d% neq 0 if %d:-=% neq 5 if %s% neq 5 exit/b
                                                                                        @echo 1


                                                                                        Takes input as command-line arguments and outputs 1 on success, nothing on failure. Batch can't easily do disjunctions so I use De Morgan's laws to turn it into a conjunction.







                                                                                        share|improve this answer












                                                                                        share|improve this answer



                                                                                        share|improve this answer










                                                                                        answered 6 hours ago









                                                                                        NeilNeil

                                                                                        79.8k744177




                                                                                        79.8k744177























                                                                                            1












                                                                                            $begingroup$


                                                                                            05AB1E, 10 bytes



                                                                                            OIÆ‚Ä50SåZ


                                                                                            Try it online!





                                                                                            O           # Sum the input.
                                                                                            IÆ # Reduced subtraction of the input.
                                                                                            ‚ # Wrap [sum,reduced_subtraction]
                                                                                            Ä # abs[sum,red_sub]
                                                                                            50S # [5,0]
                                                                                            å # [5,0] in abs[sum,red_sub]?
                                                                                            Z # Max of result, 0 is false, 1 is true.


                                                                                            Tried to do it using stack-only operations, but it was longer.






                                                                                            share|improve this answer









                                                                                            $endgroup$













                                                                                            • $begingroup$
                                                                                              This will unfortunately return true if the sum is 0 such as for [5, -5]
                                                                                              $endgroup$
                                                                                              – Emigna
                                                                                              4 hours ago
















                                                                                            1












                                                                                            $begingroup$


                                                                                            05AB1E, 10 bytes



                                                                                            OIÆ‚Ä50SåZ


                                                                                            Try it online!





                                                                                            O           # Sum the input.
                                                                                            IÆ # Reduced subtraction of the input.
                                                                                            ‚ # Wrap [sum,reduced_subtraction]
                                                                                            Ä # abs[sum,red_sub]
                                                                                            50S # [5,0]
                                                                                            å # [5,0] in abs[sum,red_sub]?
                                                                                            Z # Max of result, 0 is false, 1 is true.


                                                                                            Tried to do it using stack-only operations, but it was longer.






                                                                                            share|improve this answer









                                                                                            $endgroup$













                                                                                            • $begingroup$
                                                                                              This will unfortunately return true if the sum is 0 such as for [5, -5]
                                                                                              $endgroup$
                                                                                              – Emigna
                                                                                              4 hours ago














                                                                                            1












                                                                                            1








                                                                                            1





                                                                                            $begingroup$


                                                                                            05AB1E, 10 bytes



                                                                                            OIÆ‚Ä50SåZ


                                                                                            Try it online!





                                                                                            O           # Sum the input.
                                                                                            IÆ # Reduced subtraction of the input.
                                                                                            ‚ # Wrap [sum,reduced_subtraction]
                                                                                            Ä # abs[sum,red_sub]
                                                                                            50S # [5,0]
                                                                                            å # [5,0] in abs[sum,red_sub]?
                                                                                            Z # Max of result, 0 is false, 1 is true.


                                                                                            Tried to do it using stack-only operations, but it was longer.






                                                                                            share|improve this answer









                                                                                            $endgroup$




                                                                                            05AB1E, 10 bytes



                                                                                            OIÆ‚Ä50SåZ


                                                                                            Try it online!





                                                                                            O           # Sum the input.
                                                                                            IÆ # Reduced subtraction of the input.
                                                                                            ‚ # Wrap [sum,reduced_subtraction]
                                                                                            Ä # abs[sum,red_sub]
                                                                                            50S # [5,0]
                                                                                            å # [5,0] in abs[sum,red_sub]?
                                                                                            Z # Max of result, 0 is false, 1 is true.


                                                                                            Tried to do it using stack-only operations, but it was longer.







                                                                                            share|improve this answer












                                                                                            share|improve this answer



                                                                                            share|improve this answer










                                                                                            answered 6 hours ago









                                                                                            Magic Octopus UrnMagic Octopus Urn

                                                                                            12.5k444125




                                                                                            12.5k444125












                                                                                            • $begingroup$
                                                                                              This will unfortunately return true if the sum is 0 such as for [5, -5]
                                                                                              $endgroup$
                                                                                              – Emigna
                                                                                              4 hours ago


















                                                                                            • $begingroup$
                                                                                              This will unfortunately return true if the sum is 0 such as for [5, -5]
                                                                                              $endgroup$
                                                                                              – Emigna
                                                                                              4 hours ago
















                                                                                            $begingroup$
                                                                                            This will unfortunately return true if the sum is 0 such as for [5, -5]
                                                                                            $endgroup$
                                                                                            – Emigna
                                                                                            4 hours ago




                                                                                            $begingroup$
                                                                                            This will unfortunately return true if the sum is 0 such as for [5, -5]
                                                                                            $endgroup$
                                                                                            – Emigna
                                                                                            4 hours ago











                                                                                            1












                                                                                            $begingroup$


                                                                                            Charcoal, 18 bytes



                                                                                            Nθ¿№⟦θ⁺⁵θ⁻⁵θ⁻θ⁵⟧N1


                                                                                            Try it online! Link is to verbose version of code. Port of @ArBo's Python 2 solution.






                                                                                            share|improve this answer









                                                                                            $endgroup$


















                                                                                              1












                                                                                              $begingroup$


                                                                                              Charcoal, 18 bytes



                                                                                              Nθ¿№⟦θ⁺⁵θ⁻⁵θ⁻θ⁵⟧N1


                                                                                              Try it online! Link is to verbose version of code. Port of @ArBo's Python 2 solution.






                                                                                              share|improve this answer









                                                                                              $endgroup$
















                                                                                                1












                                                                                                1








                                                                                                1





                                                                                                $begingroup$


                                                                                                Charcoal, 18 bytes



                                                                                                Nθ¿№⟦θ⁺⁵θ⁻⁵θ⁻θ⁵⟧N1


                                                                                                Try it online! Link is to verbose version of code. Port of @ArBo's Python 2 solution.






                                                                                                share|improve this answer









                                                                                                $endgroup$




                                                                                                Charcoal, 18 bytes



                                                                                                Nθ¿№⟦θ⁺⁵θ⁻⁵θ⁻θ⁵⟧N1


                                                                                                Try it online! Link is to verbose version of code. Port of @ArBo's Python 2 solution.







                                                                                                share|improve this answer












                                                                                                share|improve this answer



                                                                                                share|improve this answer










                                                                                                answered 6 hours ago









                                                                                                NeilNeil

                                                                                                79.8k744177




                                                                                                79.8k744177























                                                                                                    0












                                                                                                    $begingroup$


                                                                                                    Runic Enchantments, 30 bytes



                                                                                                    i::i::}3s=?!@-'|A"5"n:}=?!@+=@


                                                                                                    Try it online!



                                                                                                    With a pending update, 4 bytes can be saved, as presently integer inputs are treated as doubles and don't equal integers of the same value. Hence "5"n instead of just 5. This was an oversight and several factors are being adjusted to account for it (such as using Approximately(a, b) instead of a.Equals(b)).



                                                                                                    Outputs 0 (exactly one zero) for false and any other output (literally whatever is left on the stack) for true.






                                                                                                    share|improve this answer









                                                                                                    $endgroup$


















                                                                                                      0












                                                                                                      $begingroup$


                                                                                                      Runic Enchantments, 30 bytes



                                                                                                      i::i::}3s=?!@-'|A"5"n:}=?!@+=@


                                                                                                      Try it online!



                                                                                                      With a pending update, 4 bytes can be saved, as presently integer inputs are treated as doubles and don't equal integers of the same value. Hence "5"n instead of just 5. This was an oversight and several factors are being adjusted to account for it (such as using Approximately(a, b) instead of a.Equals(b)).



                                                                                                      Outputs 0 (exactly one zero) for false and any other output (literally whatever is left on the stack) for true.






                                                                                                      share|improve this answer









                                                                                                      $endgroup$
















                                                                                                        0












                                                                                                        0








                                                                                                        0





                                                                                                        $begingroup$


                                                                                                        Runic Enchantments, 30 bytes



                                                                                                        i::i::}3s=?!@-'|A"5"n:}=?!@+=@


                                                                                                        Try it online!



                                                                                                        With a pending update, 4 bytes can be saved, as presently integer inputs are treated as doubles and don't equal integers of the same value. Hence "5"n instead of just 5. This was an oversight and several factors are being adjusted to account for it (such as using Approximately(a, b) instead of a.Equals(b)).



                                                                                                        Outputs 0 (exactly one zero) for false and any other output (literally whatever is left on the stack) for true.






                                                                                                        share|improve this answer









                                                                                                        $endgroup$




                                                                                                        Runic Enchantments, 30 bytes



                                                                                                        i::i::}3s=?!@-'|A"5"n:}=?!@+=@


                                                                                                        Try it online!



                                                                                                        With a pending update, 4 bytes can be saved, as presently integer inputs are treated as doubles and don't equal integers of the same value. Hence "5"n instead of just 5. This was an oversight and several factors are being adjusted to account for it (such as using Approximately(a, b) instead of a.Equals(b)).



                                                                                                        Outputs 0 (exactly one zero) for false and any other output (literally whatever is left on the stack) for true.







                                                                                                        share|improve this answer












                                                                                                        share|improve this answer



                                                                                                        share|improve this answer










                                                                                                        answered 5 hours ago









                                                                                                        Draco18sDraco18s

                                                                                                        1,261619




                                                                                                        1,261619























                                                                                                            0












                                                                                                            $begingroup$


                                                                                                            Perl 5, 51 + 2 (-an) = 53 bytes



                                                                                                            Pretty simple really. Outputs 0 for false, 1 for true. Not gonna lie, I don't know if bitwise OR is appropriate here, but is does work for all the test cases, so that's nice.





                                                                                                            ($a,$b)=@F;print($a==$b|$a+$b==5|$a-$b==5|$b-$a==5)


                                                                                                            Try it online!






                                                                                                            share|improve this answer











                                                                                                            $endgroup$


















                                                                                                              0












                                                                                                              $begingroup$


                                                                                                              Perl 5, 51 + 2 (-an) = 53 bytes



                                                                                                              Pretty simple really. Outputs 0 for false, 1 for true. Not gonna lie, I don't know if bitwise OR is appropriate here, but is does work for all the test cases, so that's nice.





                                                                                                              ($a,$b)=@F;print($a==$b|$a+$b==5|$a-$b==5|$b-$a==5)


                                                                                                              Try it online!






                                                                                                              share|improve this answer











                                                                                                              $endgroup$
















                                                                                                                0












                                                                                                                0








                                                                                                                0





                                                                                                                $begingroup$


                                                                                                                Perl 5, 51 + 2 (-an) = 53 bytes



                                                                                                                Pretty simple really. Outputs 0 for false, 1 for true. Not gonna lie, I don't know if bitwise OR is appropriate here, but is does work for all the test cases, so that's nice.





                                                                                                                ($a,$b)=@F;print($a==$b|$a+$b==5|$a-$b==5|$b-$a==5)


                                                                                                                Try it online!






                                                                                                                share|improve this answer











                                                                                                                $endgroup$




                                                                                                                Perl 5, 51 + 2 (-an) = 53 bytes



                                                                                                                Pretty simple really. Outputs 0 for false, 1 for true. Not gonna lie, I don't know if bitwise OR is appropriate here, but is does work for all the test cases, so that's nice.





                                                                                                                ($a,$b)=@F;print($a==$b|$a+$b==5|$a-$b==5|$b-$a==5)


                                                                                                                Try it online!







                                                                                                                share|improve this answer














                                                                                                                share|improve this answer



                                                                                                                share|improve this answer








                                                                                                                edited 4 hours ago

























                                                                                                                answered 5 hours ago









                                                                                                                Geoffrey H.Geoffrey H.

                                                                                                                414




                                                                                                                414























                                                                                                                    0












                                                                                                                    $begingroup$


                                                                                                                    Java (JDK), 30 bytes





                                                                                                                    a->b->a+b==5|a==b|(b-=a)*b==25


                                                                                                                    Try it online!






                                                                                                                    share|improve this answer









                                                                                                                    $endgroup$


















                                                                                                                      0












                                                                                                                      $begingroup$


                                                                                                                      Java (JDK), 30 bytes





                                                                                                                      a->b->a+b==5|a==b|(b-=a)*b==25


                                                                                                                      Try it online!






                                                                                                                      share|improve this answer









                                                                                                                      $endgroup$
















                                                                                                                        0












                                                                                                                        0








                                                                                                                        0





                                                                                                                        $begingroup$


                                                                                                                        Java (JDK), 30 bytes





                                                                                                                        a->b->a+b==5|a==b|(b-=a)*b==25


                                                                                                                        Try it online!






                                                                                                                        share|improve this answer









                                                                                                                        $endgroup$




                                                                                                                        Java (JDK), 30 bytes





                                                                                                                        a->b->a+b==5|a==b|(b-=a)*b==25


                                                                                                                        Try it online!







                                                                                                                        share|improve this answer












                                                                                                                        share|improve this answer



                                                                                                                        share|improve this answer










                                                                                                                        answered 3 hours ago









                                                                                                                        Olivier GrégoireOlivier Grégoire

                                                                                                                        8,88511843




                                                                                                                        8,88511843























                                                                                                                            0












                                                                                                                            $begingroup$


                                                                                                                            Retina 0.8.2, 82 bytes



                                                                                                                            d+
                                                                                                                            $*
                                                                                                                            ^(-?1*) 1$|^(-?1*)1{5} -?2$|^-?(-?1*) (3)1{5}$|^-?(1 ?){5}$|^(1 ?-?){5}$


                                                                                                                            Try it online! Link includes test cases. Explanation: The first two lines convert the inputs into unary. The final line then checks for any of the permitted matches:



                                                                                                                            ^(-?1*) 1$                              x==y
                                                                                                                            ^(-?1*)1{5} -?2$ x>=0 y>=0 x=5+y i.e. x-y=5
                                                                                                                            x>=0 y<=0 x=5-y i.e. x+y=5
                                                                                                                            x<=0 y<=0 x=y-5 i.e. y-x=5
                                                                                                                            ^-?(-?1*) (3)1{5}$ x<=0 y<=0 y=x-5 i.e. x-y=5
                                                                                                                            x<=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                            x>=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                            ^-?(1 ?){5}$ x>=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                            x<=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                            ^(1 ?-?){5}$ x>=0 y>=0 x=5-y i.e. x+y=5
                                                                                                                            x>=0 y<=0 x=5+y i.e. x-y=5


                                                                                                                            Pivoted by the last column we get:



                                                                                                                            x==y            ^(-?1*) 1$
                                                                                                                            x+y=5 x>=0 y>=0 ^-?(1 ?){5}$
                                                                                                                            x>=0 y>=0 ^(1 ?-?){5}$
                                                                                                                            x>=0 y<=0 ^(-?1*)1{5} -?2$
                                                                                                                            x<=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                            x<=0 y<=0 (impossible)
                                                                                                                            x-y=5 x>=0 y>=0 ^(-?1*)1{5} -?2$
                                                                                                                            x>=0 y<=0 ^(1 ?-?){5}$
                                                                                                                            x<=0 y>=0 (impossible)
                                                                                                                            x<=0 y<=0 ^-?(-?1*) (3)1{5}$
                                                                                                                            y-x=5 x>=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                            x>=0 y<=0 (impossible)
                                                                                                                            x<=0 y>=0 ^-?(1 ?){5}$
                                                                                                                            x<=0 y<=0 ^(-?1*)1{5} -?2$





                                                                                                                            share|improve this answer









                                                                                                                            $endgroup$


















                                                                                                                              0












                                                                                                                              $begingroup$


                                                                                                                              Retina 0.8.2, 82 bytes



                                                                                                                              d+
                                                                                                                              $*
                                                                                                                              ^(-?1*) 1$|^(-?1*)1{5} -?2$|^-?(-?1*) (3)1{5}$|^-?(1 ?){5}$|^(1 ?-?){5}$


                                                                                                                              Try it online! Link includes test cases. Explanation: The first two lines convert the inputs into unary. The final line then checks for any of the permitted matches:



                                                                                                                              ^(-?1*) 1$                              x==y
                                                                                                                              ^(-?1*)1{5} -?2$ x>=0 y>=0 x=5+y i.e. x-y=5
                                                                                                                              x>=0 y<=0 x=5-y i.e. x+y=5
                                                                                                                              x<=0 y<=0 x=y-5 i.e. y-x=5
                                                                                                                              ^-?(-?1*) (3)1{5}$ x<=0 y<=0 y=x-5 i.e. x-y=5
                                                                                                                              x<=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                              x>=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                              ^-?(1 ?){5}$ x>=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                              x<=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                              ^(1 ?-?){5}$ x>=0 y>=0 x=5-y i.e. x+y=5
                                                                                                                              x>=0 y<=0 x=5+y i.e. x-y=5


                                                                                                                              Pivoted by the last column we get:



                                                                                                                              x==y            ^(-?1*) 1$
                                                                                                                              x+y=5 x>=0 y>=0 ^-?(1 ?){5}$
                                                                                                                              x>=0 y>=0 ^(1 ?-?){5}$
                                                                                                                              x>=0 y<=0 ^(-?1*)1{5} -?2$
                                                                                                                              x<=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                              x<=0 y<=0 (impossible)
                                                                                                                              x-y=5 x>=0 y>=0 ^(-?1*)1{5} -?2$
                                                                                                                              x>=0 y<=0 ^(1 ?-?){5}$
                                                                                                                              x<=0 y>=0 (impossible)
                                                                                                                              x<=0 y<=0 ^-?(-?1*) (3)1{5}$
                                                                                                                              y-x=5 x>=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                              x>=0 y<=0 (impossible)
                                                                                                                              x<=0 y>=0 ^-?(1 ?){5}$
                                                                                                                              x<=0 y<=0 ^(-?1*)1{5} -?2$





                                                                                                                              share|improve this answer









                                                                                                                              $endgroup$
















                                                                                                                                0












                                                                                                                                0








                                                                                                                                0





                                                                                                                                $begingroup$


                                                                                                                                Retina 0.8.2, 82 bytes



                                                                                                                                d+
                                                                                                                                $*
                                                                                                                                ^(-?1*) 1$|^(-?1*)1{5} -?2$|^-?(-?1*) (3)1{5}$|^-?(1 ?){5}$|^(1 ?-?){5}$


                                                                                                                                Try it online! Link includes test cases. Explanation: The first two lines convert the inputs into unary. The final line then checks for any of the permitted matches:



                                                                                                                                ^(-?1*) 1$                              x==y
                                                                                                                                ^(-?1*)1{5} -?2$ x>=0 y>=0 x=5+y i.e. x-y=5
                                                                                                                                x>=0 y<=0 x=5-y i.e. x+y=5
                                                                                                                                x<=0 y<=0 x=y-5 i.e. y-x=5
                                                                                                                                ^-?(-?1*) (3)1{5}$ x<=0 y<=0 y=x-5 i.e. x-y=5
                                                                                                                                x<=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                                x>=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                                ^-?(1 ?){5}$ x>=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                                x<=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                                ^(1 ?-?){5}$ x>=0 y>=0 x=5-y i.e. x+y=5
                                                                                                                                x>=0 y<=0 x=5+y i.e. x-y=5


                                                                                                                                Pivoted by the last column we get:



                                                                                                                                x==y            ^(-?1*) 1$
                                                                                                                                x+y=5 x>=0 y>=0 ^-?(1 ?){5}$
                                                                                                                                x>=0 y>=0 ^(1 ?-?){5}$
                                                                                                                                x>=0 y<=0 ^(-?1*)1{5} -?2$
                                                                                                                                x<=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                                x<=0 y<=0 (impossible)
                                                                                                                                x-y=5 x>=0 y>=0 ^(-?1*)1{5} -?2$
                                                                                                                                x>=0 y<=0 ^(1 ?-?){5}$
                                                                                                                                x<=0 y>=0 (impossible)
                                                                                                                                x<=0 y<=0 ^-?(-?1*) (3)1{5}$
                                                                                                                                y-x=5 x>=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                                x>=0 y<=0 (impossible)
                                                                                                                                x<=0 y>=0 ^-?(1 ?){5}$
                                                                                                                                x<=0 y<=0 ^(-?1*)1{5} -?2$





                                                                                                                                share|improve this answer









                                                                                                                                $endgroup$




                                                                                                                                Retina 0.8.2, 82 bytes



                                                                                                                                d+
                                                                                                                                $*
                                                                                                                                ^(-?1*) 1$|^(-?1*)1{5} -?2$|^-?(-?1*) (3)1{5}$|^-?(1 ?){5}$|^(1 ?-?){5}$


                                                                                                                                Try it online! Link includes test cases. Explanation: The first two lines convert the inputs into unary. The final line then checks for any of the permitted matches:



                                                                                                                                ^(-?1*) 1$                              x==y
                                                                                                                                ^(-?1*)1{5} -?2$ x>=0 y>=0 x=5+y i.e. x-y=5
                                                                                                                                x>=0 y<=0 x=5-y i.e. x+y=5
                                                                                                                                x<=0 y<=0 x=y-5 i.e. y-x=5
                                                                                                                                ^-?(-?1*) (3)1{5}$ x<=0 y<=0 y=x-5 i.e. x-y=5
                                                                                                                                x<=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                                x>=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                                ^-?(1 ?){5}$ x>=0 y>=0 y=5-x i.e. x+y=5
                                                                                                                                x<=0 y>=0 y=5+x i.e. y-x=5
                                                                                                                                ^(1 ?-?){5}$ x>=0 y>=0 x=5-y i.e. x+y=5
                                                                                                                                x>=0 y<=0 x=5+y i.e. x-y=5


                                                                                                                                Pivoted by the last column we get:



                                                                                                                                x==y            ^(-?1*) 1$
                                                                                                                                x+y=5 x>=0 y>=0 ^-?(1 ?){5}$
                                                                                                                                x>=0 y>=0 ^(1 ?-?){5}$
                                                                                                                                x>=0 y<=0 ^(-?1*)1{5} -?2$
                                                                                                                                x<=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                                x<=0 y<=0 (impossible)
                                                                                                                                x-y=5 x>=0 y>=0 ^(-?1*)1{5} -?2$
                                                                                                                                x>=0 y<=0 ^(1 ?-?){5}$
                                                                                                                                x<=0 y>=0 (impossible)
                                                                                                                                x<=0 y<=0 ^-?(-?1*) (3)1{5}$
                                                                                                                                y-x=5 x>=0 y>=0 ^-?(-?1*) (3)1{5}$
                                                                                                                                x>=0 y<=0 (impossible)
                                                                                                                                x<=0 y>=0 ^-?(1 ?){5}$
                                                                                                                                x<=0 y<=0 ^(-?1*)1{5} -?2$






                                                                                                                                share|improve this answer












                                                                                                                                share|improve this answer



                                                                                                                                share|improve this answer










                                                                                                                                answered 14 mins ago









                                                                                                                                NeilNeil

                                                                                                                                79.8k744177




                                                                                                                                79.8k744177






















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










                                                                                                                                    draft saved

                                                                                                                                    draft discarded


















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













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












                                                                                                                                    Vikrant Biswas 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%2f178792%2fequal-sum-or-difference%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

                                                                                                                                    GameSpot

                                                                                                                                    connect to host localhost port 22: Connection refused

                                                                                                                                    Getting a Wifi WPA2 wifi connection