in reply to Re^3: compare two strings and return only he unique values.
in thread compare two strings and return only he unique values.
Your code quite effectively forms a union of the two strings' characters. However, the OP's request was to 1) compare two strings, and 2) return only the unique values. Where does your code compare the two strings? Forming a union of their characters does not compare the two strings. In fact, if we strictly regard their union as a non-multiset of characters, "a" is unique, since (set notation): {a} = {a,a} = {a,a,a}. Thus, "a" should still appear in their union--even with two occurrences within one string.
As has been point out, the OP's specs are equivocal, yet I tend to favor "unique" as meaning a character (replicated or not) that only belongs to one or the other string (i.e., "unique to")--and is not in both.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^5: compare two strings and return only he unique values.
by blue_cowdawg (Monsignor) on Feb 04, 2013 at 21:53 UTC | |
by Kenosis (Priest) on Feb 04, 2013 at 22:21 UTC | |
by blue_cowdawg (Monsignor) on Feb 05, 2013 at 13:49 UTC | |
by Kenosis (Priest) on Feb 05, 2013 at 14:00 UTC |