Pronoun operation

Retina, 62 61 56 53 52 bytes

(.+)\+(?=\1)

.*(W|.I|I.).*
We
.*Y.*
You
.{4,}
They

Further golfing and explanation comes later.

The 4 substitution steps do the following:

  • anything multiple times is itself
  • if there is any We or I + anyhing the result is We
  • for anything else containing You the result is You
  • if we still have multiple parts or a sole They it's They as only He's and They's can be left

Try it online here.

3 bytes saved thanks to Martin Büttner.


JavaScript (ES6), 130 bytes

s=>(a=",I,You,He,We,They".split`,`,m="012345014444042242042345044444042545",r=0,s.split`+`.map(p=>r=m[+m[a.indexOf(p)]+r*6]),a[r])

Explanation

s=>(

  // a = array of each pronoun (including an empty string at index 0)
  a=",I,You,He,We,They".split`,`,

  // m = 6 x 6 map of pronoun indices for each combination of pronouns
  m="012345014444042242042345044444042545",

  r=0,                        // r = index of result pronoun
  s.split`+`.map(p=>          // for each pronoun in the input string
    r=m[+m[a.indexOf(p)]+r*6] // combine each pronoun with the previous one
  ),
  a[r]                        // return the resulting pronoun
)

Test

var solution = s=>(a=",I,You,He,We,They".split`,`,m="012345014444042242042345044444042545",r=0,s.split`+`.map(p=>r=m[+m[a.indexOf(p)]+r*6]),a[r])
<input type="text" id="input" value="You+You+I+You" />
<button onclick="result.textContent=solution(input.value)">Go</button>
<pre id="result"></pre>


Python 159 153 bytes

EDIT: Thanks @Pietu1998

This is a direct translation of the Javascript ES6 answer:

a=",I,You,He,We,They".split(',')
m="012345014444042242042345044444042545"
r=0
for p in raw_input().split('+'):r=int(m[int(m[a.index(p)])+r*6])
print a[r]

Try it here