Skip to main content
-1 byte
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Perl 6, 2524 bytes

-1 byte thanks to Grimy

{$^a==$^b|5$^a-$b|$b$^b==5|0|-5|$b+55|5-2*$b}

Try it online!Try it online!

Port of @Arbo's solution. This uses the Any Junction rather than checking if a is a the list. Technicallybut technically, ^ could work as well.

Explanation:

{                        }  # Anonymous code block
 $^a==      $^a-$^b==                # Is the first inputdifference equal to
         |    |  |  |        # Any of
      $^b                       # The second0 input
          5-$b                  # 5 - b
               $b-5             # b - 5
                     $b+5       # b + 5-2*$b

Perl 6, 25 bytes

{$^a==$^b|5-$b|$b-5|$b+5}

Try it online!

Port of @Arbo's solution. This uses the Any Junction rather than checking if a is a the list. Technically, ^ could work as well.

Explanation:

{                        }  # Anonymous code block
 $^a==                      # Is the first input equal to
         |    |    |        # Any of
      $^b                       # The second input
          5-$b                  # 5 - b
               $b-5             # b - 5
                     $b+5       # b + 5

Perl 6, 24 bytes

-1 byte thanks to Grimy

{$^a-$^b==5|0|-5|5-2*$b}

Try it online!

This uses the Any Junction but technically, ^ could work as well.

Explanation:

{                      }  # Anonymous code block
 $^a-$^b==                # Is the difference equal to
           | |  |        # Any of
          0 
            5
              -5
                 5-2*$b
Source Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186

Perl 6, 25 bytes

{$^a==$^b|5-$b|$b-5|$b+5}

Try it online!

Port of @Arbo's solution. This uses the Any Junction rather than checking if a is a the list. Technically, ^ could work as well.

Explanation:

{                        }  # Anonymous code block
 $^a==                      # Is the first input equal to
         |    |    |        # Any of
      $^b                       # The second input
          5-$b                  # 5 - b
               $b-5             # b - 5
                     $b+5       # b + 5