Write a function or program which takes as input a set of distinct, non-negative integers \$\{x_1, \ldots, x_n\}\$ and outputs the smallest gap between any two values in the set, i.e. \$\min_{i\neq j}|x_i-x_j|\$.
Scoring
This is not code golf. Your score is the smallest gap of the set of code points of characters in your code (highest score wins). In other words: convert your code to integer code points (using ASCII or whatever code page is standard for your language); remove duplicates; use that as input to your program; the output is your score.
For instance, if your code is min(alldifferences(input))
, to get your score convert m->109
, i->105
, n->110
, (->40
, ... and your score will be 1, since the codepoints for m
and n
are only 1 apart.
You may assume that the input contains at least 2 distinct values; behaviour is undefined otherwise. Your code must include at least two distinct characters.
If your encoding is ASCII, you can use this online R code to verify your score.
Test cases
Input | Output
0 1 2 3 4 | 1
2 4 8 16 32 | 2
1 | undefined
3 14 159 2653 | 11
4 6 8 9 12 14 | 1
3 14 2 | 1
Default rules for input/output apply. In particular, since the input is a set, you may assume any structure for the input.
[3,14,2]
. Output should be1
, right? \$\endgroup\$