I need to take two strings, compare them, and print the difference between them.
So say I have:
teamOne = \"Billy, Frankie, Stevie, John\"
teamTwo = \"Bi
I understood the question in two ways. In case you wanted to do a string difference (word by word) which covers this case:
teamOne = "Billy, Frankie, Tom, Stevie, John"
teamTwo = "Billy, Frankie, Stevie, Tom, Zach"
s1 = teamOne.split(' ')
s2 = teamTwo.split(' ')
diff = []
s1.zip(s2).each do |s1, s2|
if s1 != s2
diff << s1
end
end
puts diff.join(' ')
Result is:
Tom, Stevie, John
Accepted answer gives:
#