[Question]
  [
In the card game [Magic: the Gathering](https://en.wikipedia.org/wiki/Magic:_The_Gathering) there are five different colours, which represent loose affiliations of cards, White (`W`), Blue (`U`), Black (`B`), Red (`R`) and Green (`G`). These are often arranged in a pentagon as follows:
```
  W
G   U
 R B
```
Both in the lore of MtG as well as in many card mechanics, adjacent colours in this pentagon are usually considered allies, and non-adjacent (sort of opposite) colours are considered enemies.
In this challenge, you'll be given two colours and should determine their relationship.
## The Challenge
You're given any two distinct characters from the set `BGRUW`. You may take these as a two-character string, a string with a delimiter between the characters, two separate character values, two singleton strings, two integers representing their code points, or a list or set type containing two characters/strings/integers.
Your output should be one of two distinct and consistent values of your choice, one which indicates that the two colours are allies and one which indicates that they are enemies. One of those two values may be no output at all.
You may write a [program or a function](http://meta.codegolf.stackexchange.com/q/2419) and use any of the our [standard methods](http://meta.codegolf.stackexchange.com/q/2447) of receiving input and providing output.
You may use any [programming language](http://meta.codegolf.stackexchange.com/q/2028), but note that [these loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden by default.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest valid answer – measured in *bytes* – wins.
## Test Cases
There are only 20 possible inputs, so I'll list them all.
**Friends:**
```
WU   UB   BR   RG   GW   UW   BU   RB   GR   WG
```
**Foes:**
```
WB   UR   BG   RW   GU   BW   RU   GB   WR   UG
```
  
[Answer]
# JavaScript (ES6), ~~26 23 17 15~~ 14 bytes
Takes input as two ASCII codes in currying syntax `(a)(b)`. Returns `4` for friends or `0` for foes.
```
a=>b=>a*b/.6&4
```
[Try it online!](https://tio.run/##pY4xC8IwEIX3/opMJpEaFcRBacEIzR4IGdQhbVOt1KY0xb8fc5N29obH497j7nuat/HV2A7Tqne1DU0WTJaXWW6W5ZrtF7tQud67zrLO3Qkuxtb2tT9gekwuCGuFU6x4FC6jSBFFaNiBcEglpAJSLTC6sZcZiEdZjn7v@hQ1xLPqYcZzpDhNZEPpfLGlcZIZzLUvnP2ywCMFjzhgSCAQQMDBSXACKhoq6n@W8AE "JavaScript (Node.js) – Try It Online")
### How?
*NB: only the integer quotient of the division by 0.6 is shown below.*
```
Combo | a  | b  | a*b  | / 0.6 | AND 4
------+----+----+------+-------+------
  WU  | 87 | 85 | 7395 | 12325 |   4
  UB  | 85 | 66 | 5610 |  9350 |   4
  BR  | 66 | 82 | 5412 |  9020 |   4
  RG  | 82 | 71 | 5822 |  9703 |   4
  GW  | 71 | 87 | 6177 | 10295 |   4
  UW  | 85 | 87 | 7395 | 12325 |   4
  BU  | 66 | 85 | 5610 |  9350 |   4
  RB  | 82 | 66 | 5412 |  9020 |   4
  GR  | 71 | 82 | 5822 |  9703 |   4
  WG  | 87 | 71 | 6177 | 10295 |   4
------+----+----+------+-------+------
  WB  | 87 | 66 | 5742 |  9570 |   0
  UR  | 85 | 82 | 6970 | 11616 |   0
  BG  | 66 | 71 | 4686 |  7810 |   0
  RW  | 82 | 87 | 7134 | 11890 |   0
  GU  | 71 | 85 | 6035 | 10058 |   0
  BW  | 66 | 87 | 5742 |  9570 |   0
  RU  | 82 | 85 | 6970 | 11616 |   0
  GB  | 71 | 66 | 4686 |  7810 |   0
  WR  | 87 | 82 | 7134 | 11890 |   0
  UG  | 85 | 71 | 6035 | 10058 |   0
```
# Previous approach, 15 bytes
Takes input as two ASCII codes in currying syntax `(a)(b)`. Returns `0` for friends or `1` for foes.
```
a=>b=>a*b%103%2
```
[Try it online!](https://tio.run/##pY4xD4IwEIV3fkUX0mKQgG6aklgTujdpGNShQFEMtoQS/37tTcrsDS8v917uvqd6K9fOw7Rsje2076lXtGxoqTZNXOT7eOdba5wddTbaO8HVPGjTuQNOjtEF4VriFEsWhIkgggfhNexAGKQCUg5pzTG6ZS81EYdoiX7vuhT1xGXtQ83ngHFaSJ4k60WRhIlWMFdTWf1lgUcSHjHAEEDAgYCBE@A4VGqoyP9Z/Ac "JavaScript (Node.js) – Try It Online")
### How?
```
Combo | a  | b  | a*b  | MOD 103 | MOD 2
------+----+----+------+---------+------
  WU  | 87 | 85 | 7395 |    82   |   0
  UB  | 85 | 66 | 5610 |    48   |   0
  BR  | 66 | 82 | 5412 |    56   |   0
  RG  | 82 | 71 | 5822 |    54   |   0
  GW  | 71 | 87 | 6177 |   100   |   0
  UW  | 85 | 87 | 7395 |    82   |   0
  BU  | 66 | 85 | 5610 |    48   |   0
  RB  | 82 | 66 | 5412 |    56   |   0
  GR  | 71 | 82 | 5822 |    54   |   0
  WG  | 87 | 71 | 6177 |   100   |   0
------+----+----+------+---------+------
  WB  | 87 | 66 | 5742 |    77   |   1
  UR  | 85 | 82 | 6970 |    69   |   1
  BG  | 66 | 71 | 4686 |    51   |   1
  RW  | 82 | 87 | 7134 |    27   |   1
  GU  | 71 | 85 | 6035 |    61   |   1
  BW  | 66 | 87 | 5742 |    77   |   1
  RU  | 82 | 85 | 6970 |    69   |   1
  GB  | 71 | 66 | 4686 |    51   |   1
  WR  | 87 | 82 | 7134 |    27   |   1
  UG  | 85 | 71 | 6035 |    61   |   1
```
# Initial approach, 23 bytes
Takes input as a 2-character string. Returns `true` for friends or `false` for foes.
```
s=>parseInt(s,35)%9%7<3
```
[Try it online!](https://tio.run/##jY09C8IwFEX3/oosJQnULkXEj3TI0OAaCBnUIbSpVGpS@op/P/ZN6uZyeLx7uefhXg7aeZiWTYidT71IIOrJzeDPYWFQVFue7/PdqUptDBBHX47xzmgzDz50cKD8mF0ItYYW1MgVUq/QaoWy@ENITDWmClOrKLmVTzcxIKIm37tQkJ4B5zz7sV1DE/1HhksGlyR6NCoUKiReGi@FFYsV84csvQE "JavaScript (Node.js) – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 19 bytes
```
"WUBRGWGRBUW".count
```
[Try it online!](https://tio.run/nexus/python2#hcwxC4JwEEDx3U/xcFEXqTVw6JbbD45bWsKUJDHRf@C3t9raevPj1zeXPQ8X01ATj7xun68p7f1zYWOYKMJxQQxTNPBAHBPUCC3qdR6HVFanjE/Xde2WRF9uFU3DMfthBDdEsUAdCcxRIQz/wxyyeRmmRHEeR9p71z5W5u9zq4v9DQ "Python 2 – TIO Nexus")
An anonymous function: returns `1` for friends and `0` for foes.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
ạg105Ị
```
Takes two code points as argument. Yields **1** for friends, **0** for foes.
[Try it online!](https://tio.run/nexus/jelly#DcWhDYBADEBRzxR/A0CwQE0FgqRJ0zABeyDZAoVBEQQBySTHIscl/@XndK9T23TpWXJ6znQd37wP71aXlfpizDkcF8QwRQMPxDFBjdAqBDdEsUAdCcxRIQzXHw "Jelly – TIO Nexus")
### Background
Let **n** and **m** be the code points of two input characters. By taking **|n - m|**, we need to concern ourselves only with all 2-combinations of characters. The following table shows all 2-combinations of characters the the corresponding absolute differences.
```
WU  2
UB 19
BR 16
RG 11
GW 16
WB 21
UR  3
BG  5
RW  5
GU 14
```
All *foe* combinations are divisible by **3**, **5**, or **7**, but none of the *friend* combinations this, so friends are exactly those that are co-prime with **3 × 5 × 7 = 105**.
### How it works
```
ạg105Ị  Main link. Left argument: n (code point). Right argument: m (code point)
ạ       Yield the absolute difference of n and m.
 g105   Compute the GCD of the result and 105.
     Ị  Insignificant; return 1 if the GCD is 1, 0 if not.
```
[Answer]
# Befunge-98, ~~13~~ 12 bytes
```
~~-9%5%3%!.@
```
[Try it online!](https://tio.run/nexus/befunge-98#@19Xp2upaqpqrKqo5/D/f6gTAA)
Prints `0` for friends and `1` for foes
This uses the difference between the ASCII values of the letters.
If we take the `(((ASCII difference % 9) % 5) % 3)`, the values for the foes will be 0. Then, we not the value and print it.
Thanks to [@Martin](http://chat.stackexchange.com/transcript/message/36012839#36012839) for the golf
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~8~~ 7 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
Piggybacks off of Mistah Figgins's [fabulous Befunge answer](https://codegolf.stackexchange.com/a/112785/53748)!
```
Iị390B¤
```
**[Try it online!](https://tio.run/nexus/jelly#@@/5cHe3saWB06El/x/u7jm653D7o6Y13kAc@f9/dLSFuY6ChWmsjkK0hamOgpkZiGVmBhQzAosZ6SiYG4JY5oZAMXOYOggLrM4Upg6iF6wOotccphfEgsiC9RrB9EJljWDmgfWawk02h8uawmShppjD7TAFmxILAA)**
### How?
As Mistah Figgins noted the decision may be made by taking the absolute difference between the ASCII values mod 9 mod 5 mod 3 - 0s are then friends and 1s and 2s are enemies.
If we instead take the (plain) difference mod 9 we find that friends are 1s, 2s, 7s, and 8s while enemies are 3s, 4s, 5s, and 6s.
The code takes the difference with `I` and then indexes into the length 9 list `[1,1,0,0,0,0,1,1,0]`, which is 390 in binary, `390B`. The indexing is both modular (so effectively the indexing performs the mod 9 for free) and 1-based (hence the 1 on the very left).
[Answer]
# C++ template metaprogramming, 85 bytes
```
template<int A,int B,int=(A-B)%9%5%3>struct f;template<int A,int B>struct f<A,B,0>{};
```
less golfed:
```
template<int A, int B,int Unused=(((A-B)%9)%5)%3>
struct foe;
template<int A, int B>
struct foe<A,B,0>{};
```
As this is a metaprogramming language, a construct compiling or not is one possible output.
An instance of `f<'W','B'>` compiles if and only if `'W'` and `'B'` are foes.
Math based off [Befunge answer](https://codegolf.stackexchange.com/a/112785/23424).
[Live example](http://coliru.stacked-crooked.com/a/2a8d3932e8bbe4be).
As C++ template metaprogramming is one of the worst golfing languages, anyone who is worse than this should feel shame. ;)
[Answer]
## Ruby, ~~22~~ 19 bytes
```
->x,y{390[(x-y)%9]}
```
Input: ASCII code of the 2 characters.
Output: 1 for allies, 0 for enemies.
### How it works:
Get the difference between the 2 numbers modulo 9, use a bitmask (390 is binary 110000110) and get a single bit using the `[]` operator.
[Answer]
## [CJam](https://sourceforge.net/p/cjam), 8 bytes
```
{*51%9>}
```
An unnamed block that expects two character codes on top of the stack and replaces them with `0` (friends) or `1` (foes).
[Try it online!](https://tio.run/nexus/cjam#FYorDoAwEEQ9p6ipwRAEogjEmnGIbTZ7AgQOsE179dIxL/N575mvL8ey362XeVtjOmpvT126WwjBZEB0QDEA50YIX@ULvo7JWYxFqCot0BImZQIVp2L4AQ "CJam – TIO Nexus")
### Explanation
Well, we've seen a lot of fun arithmetic solutions now, so I guess it's fine if I present my own one now. The closest to this I've seen so far is [Steadybox's C solution](https://codegolf.stackexchange.com/a/112788/8478). This one was found with the help of a GolfScript brute forcer I wrote some time ago for anarchy golf.
Here is what this one does to the various inputs (ignoring the order, because the initial multiplication is commutative):
```
xy   x    y    x*y   %51  >9
WU   87   85   7395    0   0
UB   85   66   5610    0   0
BR   66   82   5412    6   0
RG   82   71   5822    8   0
GW   71   87   6177    6   0
WB   87   66   5742   30   1
UR   85   82   6970   34   1
BG   66   71   4686   45   1
RW   82   87   7134   45   1
GU   71   85   6035   17   1
```
We can see how taking the product of the inputs modulo 51 nicely separates the inputs into large and small results, and we can use any of the values in between to distinguish between the two cases.
[Answer]
# [Röda](https://github.com/fergusq/roda), ~~30~~ ~~22~~ 21 bytes
*Bytes saved thanks to @fergusq by using `_` to take the values on the stream as input*
```
{[_ in"WUBRGWGRBUW"]}
```
[Try it online!](https://tio.run/nexus/roda#JY0xDsJADAT7vGLlB4QX0Fzj3tLJRRQhpBBxBRcIUIW8PfGGZu3x7Om2cekuKFU8J1NXS9mlX7fHtVQsDfDCGSEB5BSRLMI0Qp03RqI1WqV1WidmYiIae8pe4mbclBVnJaucJKYc//0wTjMKhikQ6ErbCqQ/4Pl930NF5Y9zqR/hs2Gqt2bddg "Röda – TIO Nexus")
The function is run like `push "WU" | f` after assigning a name to the function
### Explanation
```
{                      /* Declares an anonymous function */
 [                 ]   /* Push */
  _ in                 /* the boolean value of the value on the stream is in */
      "WUBRGWGRBUW"    /* this string */
}
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 10 bytes
Returns **0** for friend and **1** for foe.
```
‘Û‹BWR‘ûIå
```
[Try it online!](https://tio.run/nexus/05ab1e#@/@oYcbh2Y8adjqFB4GYuz0PL/3/P9T9a16@bnJickYqAA)
or as a [Test suite](https://tio.run/nexus/05ab1e#FcaxDcJAEETRVr6OlAoIJ9l8pNV0guTMZSARuwhE4OA6cSOHeNEbaVrIuKjQQY1FmRQRbVQ4VKPgpkRM17g917W/5vvaP4r//W7zWNuY54N5jvv6AQ)
**Explanation**
```
‘Û‹BWR‘     # push the string "RUGBWR"
       û    # palendromize (append the reverse minus the first char)
        Iå  # check if input is in this string
```
[Answer]
# C, ~~33~~ ~~32~~ ~~29~~ ~~24~~ 22 bytes
```
#define f(k,l)k*l%51<9
```
Returns 1 if friends, 0 if foes.
[Answer]
# Vim, ~~22~~ 21 bytes
```
CWUBRGWGRBUW<esc>:g/<c-r>"/d<cr>
```
Input: a single line containing the two characters.
Output: empty buffer if friends, buffer containing `WUBRGWGRBUW` if enemies.
## Explanation
```
C                                 # [C]hange line (deletes line into " register and enters insert mode)
 WUBRGWGRBUW<esc>                 # insert this text and exit insert mode
                 :g/      /d<cr>  # delete all lines containing...
                    <c-r>"        # ... the previously deleted input
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 6 bytes
Inspired by @Martin Ender's [solution](https://codegolf.stackexchange.com/a/112814/61613).
Takes an array of two char codes as input.
```
×%51<9
```
[Try it online!](https://tio.run/nexus/japt#@394uqqpoY3l///RFuY6FqaxAA) | [Test Suite](https://tio.run/nexus/japt#LYy7DYAwDESnoXMTS/4gsUaqKCMwAYMwEIOZ2Jfq5HvvfPenx/ce0q4zYgw3cpk0XEh1pSo5581kbaU1cgOvTC7g5Scv3@CvrD59ho@esU9f9h/bvaDHzvY/yd38AQ)
Returns `true` for friends, `false` for foes.
**14-byte solution:**
Takes two char codes as input
```
nV a /3%3 f ¦1
```
[Try it online!](https://tio.run/nexus/japt#@58XppCooG@saqyQpnBomeH//xbmOhamAA) | [Test Suite](https://tio.run/nexus/japt#LYwxDoAgDEWvwuLWxAApbWI8BiwNg4ubXsD7eBAvhpQy/fS/93vlR3Kpe95avos73BqX6E73vb41ESZgrCCMkFLPlICD3gHI9yQPTMZHKkfjw1c@fDK/5@jVD@ZbH2yvPs4/NHu03nY0/6Hu6g8)
### Explanation:
```
nV a /3%3 f ¦1
nV a             // Absolute value of: First input (implicit) - Second input
      /3%3 f     // Divide by 3, mod 3, then floor the result
             ¦1  // Return true if the result does not equals 1, otherwise return false
```
**12-byte solution:**
```
"WUBRGW"ê èU
```
[Try it online!](https://tio.run/nexus/japt#@68UHuoU5B6udHiVwuEVof//K4U6KQEA) |
[Test Suite](https://tio.run/nexus/japt#FYq7DYBQDMRWQalhiTTpT4pSIEZgAhZCrPEGC3Fj3cd952OVrihb37be7D5nsN3SB66BYjDCbMB5xRu8xVvUpDpVeIHnJJECpVAy7Dr0Aw)
### Explanation:
```
"WUBRGW"ê èU
"WUBRGW"ê     // "WUBRGW" mirrored = "WUBRGWGRBUW"
          èU  // Returns the number of times U (input) is found
```
Returns `1` for friends and `0` for foes.
**9-byte solution**:
Inspired by @Arnauld's [solution](https://codegolf.stackexchange.com/a/112778/61613).
```
*V%24%B%2
```
[Test Suite](https://tio.run/nexus/japt#LYy7DcAwCESncRPRGIWPFKXJDnaDPEImyPCOAVcn7r1jvu2z1sfdrnb0gmd5Cs5ppgJKA0wJmFcyg6LfCFJXSgWV5JHOKXn4zsOX9FdG7z6mnz3m3n3af2T3lH3uZP8j340f)
Returns `1` for friends, `0` for foes.
**11-byte solution:**
inspired by @Mistah Figgins's [solution](https://codegolf.stackexchange.com/a/112785/61613).
```
nV %9%5%3¦0
```
[Test Suite](https://tio.run/nexus/japt#LYy7DYAwDESnSYHkggT5gxBjOE2UEWAB9mEQFgtxnOrke@986VM011OPpndewh4wbN@7tlaKMAhWKIJA1JMIJNmdgGNPjiDsfKRxdD5848Nn93uO3vzkvvfJ9@bj/MOzR@99x/Mf2q7@)
[Answer]
# [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak), ~~155, 147~~, 135 bytes
```
(([(({}[{}]))<>])){({}())<>}(((([])[][][])[]())()()())<>{}<>{({}<><(({}))>)({}[{}]<(())>){((<{}{}>))}{}{{}({}<({}())>)(<()>)}{}<>}<>{}
```
[Try it online!](https://tio.run/nexus/brain-flak#LUzBDcBACFoHH93A3BZNH@YenYMwu8W2GlFUaKAAqqgdkctAU8wsOGpH7Uk3b/Gmj5QLgzn6iBW/jfkwAklRK8JIe/r5s/ZrwqiRj4@6r7OP@wE "Brain-Flak – TIO Nexus")
This is 134 bytes of code plus one byte penalty for the `-a` flag which enables ASCII input.
This works by finding the absolute difference between the inputs, and checking if they equal 2, 11, 16, or 19. If it does, the input is a friend, and it prints a 1. If it's not, it prints nothing. Since *nothing* in brain-flak corresponds to an empty stack, which is falsy, no output is a falsy value. ([meta](https://codegolf.meta.stackexchange.com/q/10249/31716))
One thing I particularly like about this answer, is that the "absolute difference" snippet (that is, `(([(({}[{}]))<>])){({}())<>}{}{}<>{}`) is not stack clean, but it can still be used in this answer since we don't care which stack we end up on before encoding the possible differences.
On a later edit, I took advantage of this even more by abusing the leftovers on the stack that *doesn't* end up with the absolute difference on it. On the first revision, I popped both of them off to keep it slightly more sane. *Not* doing this gives two major golfs:
1. Obviously, it removes the code to pop them: `{}{}`, but more importantly:
2. It allows us to compress the `2, 11, 16, 19` sequence from 
```
(((((()()))[][][](){})[][]())[])
```
to 
```
(((([])[][][])[]())()()())
```
Fortunately, there is no extra code needed to handle these leftovers later, so they are just left on the alternate stack.
Since brain-flak is notoriously difficult to understand, here is a readable/commented version:
```
#Push the absolute difference of the two input characters. It is unknown which stack the result will end on
(([(({}[{}]))<>])){({}())<>}
#Push 2, 11, 16, 19, while abusing the values left on the stack from our "Absolute value" calculation
(((([])[][][])[]())()()())
#Pop a zero from the other stack and toggle back
<>{}<>
#While True
{
    #Move top over and duplicate the other top
    ({}<><(({}))>)
    #Equals?
    ({}[{}]<(())>){((<{}{}>))}{}
    #If so:
    {
        #Increment the number under the stack
        {}({}<({}())>)
        #Push a zero
        (<()>)
    }
    #Pop the zero
    {}
    #Go back to the other stack
    <>
#Endwhile
}
#Toggle back
<>
#Pop a zero
{}
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 14 bytes
```
“WUBRG”wÐ€IAÆP
```
Returns `1` for enemies and `0` for friends.
Test suite at **[Try it online!](https://tio.run/nexus/jelly#FYqxCYBQDETHSeMSpgliI4EQRJzDViy0dQDdwBHsPi7yF4m5Io@7vIu6Xm6sUtd7KWfdnq4t@xDfW44sfd4YMZEbNWScYE2oJMTxAxhWYQXWYR3VUBlVsRPsGEmRBBPHxITmHw "Jelly – TIO Nexus")**
### How?
```
“WUBRG”wÐ€IAÆP - Main link                                   e.g. WG
“WUBRG”        - ['W','U','B','R','G']
       wÐ€     - first index of sublist mapped over the input     [1,5]
          I    - incremental differences                           -4
           A   - absolute value                                     4
            ÆP - is prime?                                          0
```
[Answer]
# [CJam](https://sourceforge.net/p/cjam), ~~16~~ ~~12~~ ~~11~~ 10 bytes
*Golfed 4 bytes by using [Mistah Figgins's algorithm](https://codegolf.stackexchange.com/a/112785/53880)*
*Saved 1 byte thanks to Lynn*
```
l:m9%5%3%!
```
Outputs `1` for enemy colours, `0` for ally colours.
[Try it online!](https://tio.run/nexus/cjam#@59jlWupaqpqrKr4/394KAA) (Or verify [all test cases](https://tio.run/nexus/cjam#i67@n2OVa6lqqmqsqvi/1shAK7bgf3goV6gTl1MQV5A7l3s4VziQBLKBIkBxIBfIAIoA2UBBIBdIAtlAEaB4OAA "CJam – TIO Nexus"))
**Explanation**
```
l           e# Push a line of input as a string
 :m         e# Reduce the string by subtraction (using the ASCII values)
   9%5%3%   e# Mod by 9, then by 5, then by 3. By doing this, enemy
            e#  pairs go to 0, and allies go to 1, 2, -1, or -2.
         !  e# Boolean negation
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes
```
$Æ105¿Ö
```
This is a port of [my Jelly answer](https://codegolf.stackexchange.com/a/112800/12012). Takes a list of code points as input. Prints **1** for friends, **0** for foes.
[Try it online!](https://tio.run/nexus/bash#PY9BCsIwEEXX5hRD6TLYJjJJwCIo1K0HEJFSq3ZhU2w2vYBH8DqCPVidKdLNH@bxPsyURYANPIpbXUKWQX7Yj/HwUil@P8N7pFWIq39CqLpwLouugroBZ6VDcCiNAWOk0@C0tAqsks4yp2SOzMlhrrlFDiURdjQ7TDT77ODUshNBJmzaqYtkruHixaLtw903K0h8G5IUtzuV/8ey7edHMoiO8Xz0KRIX31TjDw "Bash – TIO Nexus")
### How it works
```
$        Push 1 and [n, m] (the input).
 Æ       Reduce [n, m] by subtraction, pushing n - m.
  105¿   Take the GCD of n - m and 105.
      Ö  Test if 1 is divisible by the GCD (true iff the GCD is ±1).
```
[Answer]
## [Retina](https://github.com/m-ender/retina), 18 bytes
```
O`.
BR|BU|GR|GW|UW
```
[Try it online!](https://tio.run/nexus/retina#DcixCQNBAAPBfPswOHIRShQaBELpF3K9nz3hvN5@7vf5oBz1OMc73b0r1X@J8ehQiXCYmWiQyXDRSLFYqH8 "Retina – TIO Nexus")
Quite straight-forward: sorts the input and tries to match any of the sorted ally pairs against it. Unfortunately, I don't think that Retina's string-based nature allows for any of the more interesting approaches to be competitive.
As a sneak peek for the next Retina version, I'm planning to add an option which swaps regex and target string (so the current string will be used as the regex and you give it a string to check), in which case this shorter solution will work (or something along those lines):
```
?`WUBRGWGRBUW
```
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), ~~28~~ 23 bytes
*-5 bytes thanks to fergusq*
```
"WUBRGWGRBUW"::contains
```
[Try it online!](https://tio.run/nexus/java-openjdk#RY7BysIwEITP6VMsPVnEPkDl99BLL3qphBzEw7amspAmJUkFkT77mqI/nuYwM9/MNHeGeugNhgAnJAuvTJCN2g/Yazji2N0QXtA5ZzRa8LPdnKMne4dQ7GHJxPQhhIgxycPRDcbE@aYuV0B/D8WKFV/a8Me5knXbqKatpcqrqnc2pk5gIfYpNzj/P0LVry7OzxD1WLo5llNyo7Eb2uZpQAMaQzrA7gD5dijXl1QUKys9XLKFWUmWilXDsuWm5la@AQ "Java (OpenJDK 8) – TIO Nexus")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 10 bytes
A straightforward solution, no tricks involved.
```
p~s"WUBRGW
```
[Try it online!](https://tio.run/nexus/brachylog2#@19QV6wUHuoU5B7@/79SaLgSAA "Brachylog – TIO Nexus")
### Explanation
```
p               A permutation of the input
 ~s             is a substring of
   "WUBRGW      this string
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 6 bytes
```
ạ:3%3Ḃ
```
For completeness's sake. Takes two code points as argument. Yields **0** for friends, **1** for foes.
[Try it online!](https://tio.run/nexus/jelly#DcUhCoBAEEDR7il@MRu2GadMMAgDw@B1vInJYhLDotGTrBdZF/7j13JvY@pTyWstz1Xy@a3H/O5DW2tqllrDcUEMUzTwQBwT1AjtQnBDFAvUkcAcFcJw/QE "Jelly – TIO Nexus")
### Background
Let **n** and **m** be the code points of two input characters. By taking **|n - m|**, we need to concern ourselves only with all 2-combinations of characters. The following table shows all 2-combinations of characters the the corresponding absolute differences.
```
WU UB BR RG GW  WB UR BG RW GU
 2 19 16 11 16  21  3  5  5 14
```
If we divide these integers by **3**, we get the following quotients.
```
WU UB BR RG GW  WB UR BG RW GU
 0  6  5  3  5   7  1  1  1  4
```
**1**, **4**, and **7** can be mapped to **1** by taking the results modulo **3**.
```
WU UB BR RG GW  WB UR BG RW GU
 0  0  2  0  2   1  1  1  1  1
```
Now we just have to look at the parity.
### How it works
```
ạ:3%3Ḃ  Main link. Left argument: n (code point). Right argument: m (code point)
ạ       Absolute difference; yield |n - m|.
 :3     Integer division by 3, yielding |n - m| / 3.
   %3   Modulo 3, yielding |n - m| / 3 % 3.
     Ḃ  Parity bit; yield |n - m| / 3 % 3 & 1.
```
[Answer]
# Cubix, 11 bytes
A Cubix implementation of Arnauld's solution.
```
U%O@A*'g%2W
```
# Usage
Input the two characters, and it outputs `0` for friends and `1` for foes. [Try it here.](https://ethproductions.github.io/cubix/?code=VSVPQEEqJ2clMlc=&input=V1U=)
# Explanation
The code can be expanded like this.
```
    U %
    O @
A * ' g % 2 W .
. . . . . . . .
    . .
    . .
```
The characters are executed in this order (excluding control flow):
```
A*'g%2%O@
A         # Read all input as character codes
 *        # Multiply the last two character codes
    %     # Modulo the result by
  'g      #     103
      %   # And modulo that by
     2    #     2
       O  # Output the result ...
        @ # ... and terminate
```
[Answer]
# [Python 2](https://docs.python.org/2/), 26 bytes
```
lambda a:a in"GWUBRGRBUWG"
```
[Try it online!](https://tio.run/nexus/python2#fYwxCsMwEMD2vEJkipc@INDlltsPjlu6uBSDIU1DnP@7HjtVoxAq90ff8vv5yuQ1U/dZw8XUxEPnXj4nbVjmcFwQwxQNPBDHBDVGeGvHVq8lrROD46z7tZSlpTT9HAQ3RLFAHQnMUSEM/3PoXw "Python 2 – TIO Nexus")
[Answer]
## AWK, 23 Bytes
```
{$0="WUBRGWGRBUW"~$1}1
```
Example usage:
 awk '{$0="WUBRGWGRBUW"~$1}1' <<< UB
This prints `1` if the pair is a friend, `0` otherwise.
I wanted to do something clever, but everything I thought of would be longer. 
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
“WUBRGW”ŒBẇ@
```
Outputs `1` for allies, `0` for enemies.
[Try it online!](https://tio.run/nexus/jelly#@/@oYU54qFOQe/ijhrlHJzk93NXu8P//f/cgAA "Jelly – TIO Nexus")
**Explanation**
```
“WUBRGW”ŒBẇ@   Main link
“WUBRGW”       The string "WUBRGW"
        ŒB     Bounce; yields "WUBRGWGRBUW"
          ẇ@   Check if the input exists in that string
```
[Answer]
# Ruby, 28 bytes
Outputs true for friend, false for foe:
```
p'WUBRGWGRBUW'.include?$**''
```
The ungolfed version isn't much different:
```
p 'WUBRGWGRBUW'.include?(ARGV.join(''))
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 7 bytes
Adaptation of the mod-trick from [Jonathan's Jelly answer](https://codegolf.stackexchange.com/a/112793/47066)
```
Æ451bsè
```
[Try it online!](https://tio.run/nexus/05ab1e#@3@4zcTUMKn48Ir//6MtTHUUzMxiv@bl6yYnJmekAgA)
or as a [Test suite](https://tio.run/nexus/05ab1e#BcGxCYBADIbRVT7O1kbQxjJN@h9CelcQhFtAV3ELiwx2vtcyCMOEHE8isUCGi3TSCGGOEg8sUeBGivA2Xb2eUfe6LcdZ7@itvp362jx@)
**Explanation**
```
 Æ        # reduced subtraction
  451b    # 451 to binary (111000011)
      sè  # index into this with the result of the reduced subtraction
```
[Answer]
## [GolfScript](http://www.golfscript.com/golfscript/), 7 bytes
```
~*51%9>
```
Takes two code points as input.
[Try it online!](https://tio.run/nexus/golfscript#U1dQV62urtWPVVdQ1/pfp2VqqGpp97@gVv9/eKiCgkKoE5BwCgISQe5Awj0cSISDxEJBYk4gsSCQmHsoAA "GolfScript – TIO Nexus") (Test suite which converts the input format for convenience.)
A GolfScript port of [my CJam answer](https://codegolf.stackexchange.com/a/112814/8478) (which technically, is a CJam port of the result of my GolfScript brute forcer... uhhh...).
However, since GolfScript gets modulo with negative inputs right, there's a fun alternative solution at the same byte count which uses `4` for foes instead of `1`:
```
~-)9%4&
```
[Try it online!](https://tio.run/nexus/golfscript#U1dQV62urtWPVVdQ1/pfp6tpqWqi9r@gVv9/eKiCgkKoE5BwCgISQe5Awj0cSISDxEJBYk4gsSCQmHsoAA "GolfScript – TIO Nexus")
```
xy   x    y    x-y    +1  %9  &4
WU   87   85     2     3   3   0
UB   85   66    19    20   2   0
BR   66   82   -16   -15   3   0
RG   82   71    11    12   3   0
GW   71   87   -16   -15   3   0
WB   87   66    21    22   4   4
UR   85   82     3     4   4   4
BG   66   71    -5    -4   5   4
RW   82   87    -5    -4   5   4
GU   71   85   -14   -13   5   4
```
[Answer]
# Java 7, 38 bytes
```
int b(int a,int b){return(a-b)%9%5%3;}
```
Port from [*@Mistah Figgins*' Befunge-98 answer](https://codegolf.stackexchange.com/a/112785/52210) is the shortest in Java 7 from the answers posted so far.  
As for the others:
**39 bytes:** Port from [*@Arnauld*'s JavaScript (ES6) answer](https://codegolf.stackexchange.com/a/112778/52210).
```
int a(int a,int b){return a*b%24%11%2;}
```
**39 bytes:** Port from [*@MartinEnder*'s CJam answer](https://codegolf.stackexchange.com/a/112814/52210)
```
Object e(int a,int b){return a*b%51>9;}
```
**47 bytes:** Port from [*@Steadybox*' C answer](https://codegolf.stackexchange.com/a/112788/52210)
```
Object d(int a,int b){return(a=a*b%18)>7|a==3;}
```
**52 bytes:** Port from [*@Lynn*'s Python 2 answer](https://codegolf.stackexchange.com/a/112775/52210)
```
Object c(String s){return"WUBRGWGRBUW".contains(s);}
```
*NOTE: Skipped answers which uses primes / palindromes and alike, because those are nowhere near short in Java. ;)  
~~TODO: Coming up with my own answer.. Although I doubt it's shorter than most of these.~~*
[**Try all here.**](https://tio.run/nexus/java-openjdk#rZJRS8MwFIXf/RWXQKHRWdbp0G10YEHzJEJH6cPYQ9pmWtmy0WSKzP32mV67brIKlfnQS9ucc@5NvmyTGVcKHtdnAEpznSWQSQ3cxtoqakzXudCrXAI/j63OteW6Vmew@WmI6ww2v4yp1bO61tWh/il@FYmGxB7pPJPPoHZ6EoV@wCIW@GFEnGQhNc@kshWtcaf1Db1iRveWDm8@uefVtRW/bq3rDnvGYBzLVTwzjtL4tshSmJtRyoHHE@C0ODCA0YfSYu4sVtpZmiVtk4c8EzJVfSB0gJLpIq82Cn2Q4h12MWswOyYtIKFfVD8oasCKyiL8j9VHTYAahpqIEdiUI9QNMTZ7dycELgxI5SQvPL/Tdpu2oPpwKTWrZFCNWRsTD8uY@KSYxPN0vhKYlBicDSzpgSU9qbnwvCmfqe8o0TQKr8Fx3kzapeC4070U80w0J488Q@TpI/MAaTOk7eN7gO8MlREqwwbk2/9BfhdzMvn94TdHv/eczL66RX9AXzyb7fYL)
---
*EDIT: Ok, came up with something myself that isn't too bad:*
# 50 bytes:
```
Object c(int a,int b){return(a=a*b%18)>3&a<7|a<1;}
```
**Explanation:**
```
ab  a   b   a*b     %18
WU  87  85  7395    15
UB  85  66  5610    12
BR  66  82  5412    12
RG  82  71  5822    8
GW  71  87  6177    3
UW  85  87  7395    15
BU  66  85  5610    12
RB  82  66  5412    12
GR  71  82  5822    8
WG  87  71  6177    3
WB  87  66  5742    0
UR  85  82  6970    4
BG  66  71  4686    6
RW  82  87  7134    6
GU  71  85  6035    5
BW  66  87  5742    0
RU  82  85  6970    4
GB  71  66  4686    6
WR  87  82  7134    6
UG  85  71  6035    5
```
All enemies are either in the range 4-6 (inclusive) or 0.  
EDIT2: Hmm.. I just noticed it's very similar to *@Steadybox*' answer.. :(
[Answer]
# PHP, 31 bytes
```
echo!strstr(WBGURWRUGBW,$argn);
```
Run with `echo AB | php -nR '<code>`, where `A` and `B` are the two colors.
`strtr` returns the string from the position where the input is found;  
with `WBGURWRUGBW` as haystack this returns a truthy string if the colors are foes; empty string if not.
`!` turns the truthy string to `false`, resulting in empty output  
and the empty string to `true`, resulting in output `1`.
]