Created
February 12, 2012 12:48
-
-
Save kysnm/1808323 to your computer and use it in GitHub Desktop.
離散数学読書会(@2012-02-12)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myset(a1, a2) | |
h = Hash.new(0) | |
a1.each{|a| h[a] += 1} | |
a2.each{|a| h[a] += 1} | |
puts "a and b" | |
p h.select{|k, v| v == 2}.keys | |
puts "a or b" | |
p h.keys | |
puts "a - b" | |
p a1.select{|a| h[a] == 1} | |
end | |
myset([1, 3, -5, 8, -4], [7, -4, 2, 3, 8, -6, 5]) | |
myset([1, 3, -5, 8, -4], [7, -2, 3, 2, -6, 9, -4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment