Find minimum difference between numbers in array
The R language

23 characters,  O(n log n)

min(diff(sort(scan())))


Example:

&gt; min(diff(sort(scan())))
1: 55 99 6
4: 29 1 523 3
8: 
Read 7 items
[1] 2


...The [1] 2 shows the result 2. (the [1] is to keep track of where in the result vector your are since in R all values are vectors - in this case of length 1)