2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,20 +1,5 @@
|
|||
Given two [[set]]s ''A'' and ''B'', where ''A'' contains:
|
||||
|
||||
* John
|
||||
* Bob
|
||||
* Mary
|
||||
* Serena
|
||||
|
||||
and ''B'' contains:
|
||||
|
||||
* Jim
|
||||
* Mary
|
||||
* John
|
||||
* Bob
|
||||
|
||||
compute
|
||||
|
||||
:<math>(A \setminus B) \cup (B \setminus A).</math>
|
||||
;Task
|
||||
Given two [[set]]s ''A'' and ''B'', compute <math>(A \setminus B) \cup (B \setminus A).</math>
|
||||
|
||||
That is, enumerate the items that are in ''A'' or ''B'' but not both. This set is called the [[wp:Symmetric difference|symmetric difference]] of ''A'' and ''B''.
|
||||
|
||||
|
|
@ -22,6 +7,13 @@ In other words: <math>(A \cup B) \setminus (A \cap B)</math> (the set of items t
|
|||
|
||||
Optionally, give the individual differences (<math>A \setminus B</math> and <math>B \setminus A</math>) as well.
|
||||
|
||||
|
||||
;Test cases
|
||||
A = {John, Bob, Mary, Serena}
|
||||
B = {Jim, Mary, John, Bob}
|
||||
|
||||
|
||||
;Notes
|
||||
# If your code uses lists of items to represent sets then ensure duplicate items in lists are correctly handled. For example two lists representing sets of <code>a = ["John", "Serena", "Bob", "Mary", "Serena"]</code> and <code>b = ["Jim", "Mary", "John", "Jim", "Bob"]</code> should produce the result of just two strings: <code>["Serena", "Jim"]</code>, in any order.
|
||||
# In the mathematical notation above <code>A \ B</code> gives the set of items in A that are not in B; <code>A ∪ B</code> gives the set of items in both A and B, (their ''union''); and <code>A ∩ B</code> gives the set of items that are in both A and B (their ''intersection'').
|
||||
<br><br>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue