I've been working on a coding challenge to return the uncommon characters between two separate strings. However I haven't had much luck in figuring it out. I've tried a number of methods that I have found when googling, none have quite worked. I did however come across a hash mapping method but the examples only included C++, Python, C — seeing as Ruby is my first programming language it's been difficult trying to translate such a complex challenge without making mistakes.
I'm not in any rush to figure this coding challenge out and would rather appreciate getting some feedback on what everyone else thinks may be worth me reading into in order to approach this question successfully.
Here is my code currently, please don't think much of it, I know it's far off from what it should be:
# Find concatenated string
# with uncommon characters of given strings
def solve(a,b)
res = "" # result
map = {}
# store all characters of b in map
[a,b].each.map{| character, element | for characters(1..26) << element[+1]
}
# Find characters of a that are not
# present in b and append to result
# Find characters of b that are not
# present in a
return res
end
Here is an example test case of what I'm trying to do, click here for link to Kata challenge:
solve("xyab","xzca") = "ybzc"
--The first string has 'yb' which is not in the second string.
--The second string has 'zc' which is not in the first string.