Sunday, April 27, 2014

Simple Python Problems

a=[1,2,3,0]
b=[0,5,4,6,7]

Sort the union of two sets:
sorted(unique(a+b))                           =>  [0, 1, 2, 3, 4, 5, 6, 7]
sorted(unique(a+b),reverse=True)     => [7, 6, 5, 4, 3, 2, 1, 0]