Skip to main content
added absolute difference code
Source Link

Ruby (>=1.9), 2323 38 bytes

EDIT: whoops, forgot about the absolute difference part. Non-competing until I update it.

->(a,b){a==b or a+b==5 or(a-b).abs==5}

Try it online!Try it online!

It's an anonymous function, so the TIO has some extra code to take input and return the output. Put the two numbers on separate lines. Also works with negatives! (e.g.

Returns true if they are equal or add to 5, or if their absolute difference is 5, and false if not.

I'm quite surprised the other Ruby answer didn't use this approach.

Ruby (>=1.9), 23 bytes

EDIT: whoops, forgot about the absolute difference part. Non-competing until I update it.

->(a,b){a==b or a+b==5}

Try it online!

It's an anonymous function, so the TIO has some extra code to take input and return the output. Put the two numbers on separate lines. Also works with negatives! (e.g.

Returns true if they are equal or add to 5, and false if not.

I'm quite surprised the other Ruby answer didn't use this approach.

Ruby (>=1.9), 23 38 bytes

->(a,b){a==b or a+b==5 or(a-b).abs==5}

Try it online!

It's an anonymous function, so the TIO has some extra code to take input and return the output. Put the two numbers on separate lines.

Returns true if they are equal or add to 5, or if their absolute difference is 5, and false if not.

Source Link

Ruby (>=1.9), 23 bytes

EDIT: whoops, forgot about the absolute difference part. Non-competing until I update it.

->(a,b){a==b or a+b==5}

Try it online!

It's an anonymous function, so the TIO has some extra code to take input and return the output. Put the two numbers on separate lines. Also works with negatives! (e.g.

Returns true if they are equal or add to 5, and false if not.

I'm quite surprised the other Ruby answer didn't use this approach.