match.py 1.03 KB
 Sanjay Krishnan committed Apr 05, 2019 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 class ThreeWayMatchOperator: """ In this assignment, you will write a 3-way match operator similar to the 2-way match operator you saw in lecture. Consider the following example where you are given three iterators i1,i2,i3: >> i1 = [ 1,7,2,4,6, ... ] # iterator >> i2 = [ 3,6,7,2,1, ... ] # iterator >> i3 = [ 10,6,1,2,3, ... ] # iterator You can construct a ThreeWayMatchOperator object: >> threeWayIter = ThreeWayMatchOperator( (i1,i2,i3) ) and this operator should return all values that appear in ALL three iterators. The order is not important >> for i in threeWayIter: ... print(i) 1. [2,2,2] 2. [1,1,1] 3. [6,6,6] Edge cases: * Return an error if any of the iterators has 0 values """ def __init__(self, input): self.in1, self.in2, self.in3 = input def __iter__(self): raise NotImplemented("You must implement an initializer") def __next__(self): raise NotImplemented("You must implement a next function")