3 + 8 = 4 + 7
But what happens if we look at equations with strings instead of numbers? What would addition and equality mean?
Given two strings x and y, we define x + y to be the concatenation of the two strings. We also define x = y to mean that x is an anagram of y. That is, the characters in x can be permuted to form y.
You are given n distinct nonempty strings, each containing at most 10 lowercase characters. You may also assume that at most 10 distinct characters appear in all the strings. You need to determine if you can choose strings to put on both sides of an equation such that the "sums" on each side are "equal" (by our definitions above). You may use each string on either side 0 or more times, but no string may be used on both sides.
2 hello world 7 i am lord voldemort tom marvolo riddle 0
no yes i L 1 am L 1 lord L 1 voldemort L 1 tom R 1 marvolo R 1 riddle R 1