Here is problem 2, version 1.  I think it works if you test it with python.  If you test it with ipython, you have to be careful about negative integers in the input
Merge branch 'master' of https://github.com/nyucusp/gx5003-fall2013