Returns the index of the smallest number in a slice. O(n).
slice must not be empty.
pub fn findMin(comptime T: type, slice: []const T) usize
pub fn findMin(comptime T: type, slice: []const T) usize {
assert(slice.len > 0);
var best = slice[0];
var index: usize = 0;
for (slice[1..], 0..) |item, i| {
if (item < best) {
best = item;
index = i + 1;
}
}
return index;
}