README.md 2 KB
Newer Older
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
# Three-Way Iterator Matching

*Due 4/19/19 11:59 PM*

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 iterable objects i1,i2,i3:
```
    >> i1 = [ 1,7,2,4,6, ... ] # iterable
    >> i2 = [ 3,6,7,2,1, ... ] # iterable
    >> i3 = [ 10,6,1,2,3, ... ] # iterable
```

You should be able to construct a `ThreeWayMatchOperator` object:
```
    >> threeWayIter = ThreeWayMatchOperator( (i1,i2,i3) )
```
and this operator should iterate over all values that appear in ALL
three iterators. The order is not important
```
    >> for i in threeWayIter:
    ...  print(i)
    [2,2,2]
    [1,1,1]
    [6,6,6]
```

## Getting Started
Acquaint yourselves with the basic homework submission procedures and please ask us if you have any question on Piazza or during office hours BEFORE the deadline. Remember there are no "slip days" in this class, it is your responsibility to know how to complete and submit the homework assignments. We will run a tutorial on how to use git on Thursday 4/11 2-3 (in 223 JCL). A summary is below:
28
https://mit.cs.uchicago.edu/skr/cmsc13600-public/tree/master/using-git
29

30
First, pull the most recent changes from the cmsc13600-public repository:
31 32 33
```
$ git pull
```
34
Then, copy the `hw0` folder to your submission repository. Change directories to enter your submission repository. Your code will go into `match.py` this is the only file that you will modify. Finally, add `match.py` using `git add`:
35 36 37 38 39 40 41 42 43 44 45 46
```
$ git add match.py
$ git commit -m'initialized homework'
```

## Doing the homework
You will have to implement `__next__` and `__iter__` to write a 3-way matching operator. One edge case to watch out for is if any of the iterators is empty. In this case, raise an exception. We have provided a series of basic tests in `test.py`, these tests are incomplete and are not meant to comprehensively grade your assignment.

After you finish the assignment you can submit your code with:
```
$ git push
```