mit-parity
You are given n binary strings s1, ..., sn, each of the same length m. Along with each si you are given a bit bi. You are also given some nonnegative integer k and want to know whether there exists a subset S of {0, 1, . . . ,m−1} of size at most k such that for each i = 1, 2, . . . , n, the bit bi is the XOR of the bits of si at the indices in S. The si are 0-indexed strings. Recall that the XOR of a set of bits is 1 if the number of bits equal to 1 is odd, else the XOR is 0 (in particular, the XOR of an empty set of bits is 0).
For example, if s1 = 1010 and S = {0, 3}, then b1 would be 1 (the first bit of s1) XOR’d with 0 (the last bit of s1), which is 1.
Given n, k, and the strings s1, . . . , si and their corresponding bi, find a set S of size at most k which produces the given bi. You should also detect when no such S exists.
3 1
111 1
001 0
011 1Output:
1
1Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.