The smallest smallest
Mar. 1st, 2009 12:16 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
In Ruby:
def smallest a, b=nil, *c b ? smallest( (a<b ? a : b), *c ) : a end smallest(9,8,5,2,3) # is 2Can anyone do better?
no subject
Date: 2009-03-02 09:45 am (UTC)Then again, yours is O(n) versus my O(n log n)
no subject
Date: 2009-03-02 03:20 pm (UTC)