First Page    Prev. Page    Next Page    Last PagePage: 1/1

Friday, Feb 10 2006

Fri

Lee's homework is due again today. This week it contained one interesting little exercise:



Do you think you are good? Can you come up with a clever solution? Let's see it

Be sure to test various inputs to make sure your algorithm outputs proper results. Sample test inputs are:

[-1,3,-2.5,-4,-10] => output is [-1,-2.5,-4,-10,3]
[0,1,2,3,4,5] => output is [0,1,2,3,4,5]
[5,4,3,2,1,0] => output is [0,5,4,3,2,1]
[5,4,3,2,1,-1] => output is [-1,5,4,3,2,1]
[-1,0,1,-3,4,-4,-7] => output is [-1,-3,-4,-7,0,1,4]
etc

Here is a quick rudimentary solution I came up with. Not particularly elegant, but it gets the job done. You may want to work on yours first, so you aren't influenced by mine.


First Page    Prev. Page    Next Page    Last PagePage: 1/1