1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-16 20:56:57 +02:00
CodeWars/7kyu/speed_control/solution.c

21 lines
334 B
C
Raw Normal View History

#include <math.h>
int gps(int s, double* x, int sz) {
if (sz < 2) {
return 0;
}
double maxDiff = x[1] - x[0];
int maxIndex = 0;
for (int i = 0; i < sz - 1; i++) {
double diff = x[i + 1] - x[i];
if (diff > maxDiff) {
maxDiff = diff;
maxIndex = i;
}
}
return floor((3600 * maxDiff) / s);
}