+ 1
How do I check if two labels contain the same letters?
I need a way to check if two labels contain the same letters, though they don't need to be exactly in the same order. For example: Label1 ==''abcde'' Label2==''abdec'' I then would like them to give me the same value, so it doesn't matter in what order the input is, as long as it contains the same letters/numbers.
3 Answers
+ 1
Thanks for making that, though it's not exactly what I needed. I've found out what my code missed and will edit my post later with the right code. Cheers!
0
Something like this ?
https://code.sololearn.com/cRva9WRuVuWy
0
if (Label1 .All(val => Label2.Contains(val)) && Label2.All(val => Label1 .Contains(val)))
if Label1 has all of the letters that Label2 has, it's true, AND, if Label2 has all of the letters that Label1 has, it's true!
If either of them contain any different ones from each other, it will return false.
Examples of this are:
Label1: "abcdef"
Label2: "cdfbae" = True
Label1: "abcde"
Label2: "cdbaef" = False