Is there an efficient way to find minimum xor value between a key and elements of a list?

Assume that I have a list of 10 thousand random numbers chosen in this way: random_num = list(np.random.choice(2**16, 10000, replace=False)) Now, I have a key in the same range (e.g., 1024), and I need to find 10 numbers from the sorted list that have minimum value with the key based on the xor distance: xor_dist… Read More Is there an efficient way to find minimum xor value between a key and elements of a list?

Type mismatch when using map on a zipped list in Scala

Consider this code : /** Takes a list and turns it into an infinite looping stream. */ def loop(l: List[Char]): LazyList[Char] = { l.to(LazyList) #:::loop(l) } /** Encodes a sequence of characters with a looped key. */ def codec(message: Seq[Char], key: Seq[Char], cipher: (Char, Char) => Char): Seq[Char] = { val loopedKey = loop(key.toList) val… Read More Type mismatch when using map on a zipped list in Scala