I was going through how to sort and print the symmetric difference of two sets in python when I saw this line of code:
// Encode:
let intArray = [1, 2, 4, 65]
let output = try! JSONEncoder().encode(intArray).base64EncodedString()
print(output) // WzEsMiw0LDY1XQ==
// Decode:
let output = "WzEsMiw0LDY1XQ=="
if let data = Data(base64Encoded: output),
let array = try? JSONDecoder().decode([Int].self, from: data) {
print(array) // [1, 2, 4, 65]
} else {
print("Invalid input")
}
where s1 and s2 are the two integer sets. ss gives the perfect required result. However I can't understand how s1^s2 works. What function does '^' this perform?
EDIT: Symmetric Difference, Suppose, s1={2,4,5,9} and s2={2,4,11,12} then ss={5,9,11,12}