Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
4
Task/Symmetric-difference/Ruby/symmetric-difference-1.rb
Normal file
4
Task/Symmetric-difference/Ruby/symmetric-difference-1.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a = ["John", "Serena", "Bob", "Mary", "Serena"]
|
||||
b = ["Jim", "Mary", "John", "Jim", "Bob"]
|
||||
# the union minus the intersection:
|
||||
p sym_diff = (a | b)-(a & b) # => ["Serena", "Jim"]
|
||||
4
Task/Symmetric-difference/Ruby/symmetric-difference-2.rb
Normal file
4
Task/Symmetric-difference/Ruby/symmetric-difference-2.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
require 'set'
|
||||
a = Set["John", "Serena", "Bob", "Mary", "Serena"] #Set removes duplicates
|
||||
b = Set["Jim", "Mary", "John", "Jim", "Bob"]
|
||||
p sym_diff = a ^ b # => #<Set: {"Jim", "Serena"}>
|
||||
Loading…
Add table
Add a link
Reference in a new issue