# your code goes here import itertools from functools import reduce import operator my_list = [2,10,13,23,11] r = 3 # Length of combinations # Get all combinations of length r combinations_r = list(itertools.combinations(my_list, r)) print(f"Combinations of length {r}: {combinations_r}") for comb in combinations_r: comb = list(comb) # print(comb) print(f"XOR{comb} = {reduce(operator.xor, comb)}")
Standard input is empty
Combinations of length 3: [(2, 10, 13), (2, 10, 23), (2, 10, 11), (2, 13, 23), (2, 13, 11), (2, 23, 11), (10, 13, 23), (10, 13, 11), (10, 23, 11), (13, 23, 11)] XOR[2, 10, 13] = 5 XOR[2, 10, 23] = 31 XOR[2, 10, 11] = 3 XOR[2, 13, 23] = 24 XOR[2, 13, 11] = 4 XOR[2, 23, 11] = 30 XOR[10, 13, 23] = 16 XOR[10, 13, 11] = 12 XOR[10, 23, 11] = 22 XOR[13, 23, 11] = 17