-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetricDevelopment.ts
46 lines (37 loc) · 1.12 KB
/
metricDevelopment.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// replace the values of the following two lines with your own values
let crowns: number[] = [50, 34];
let speeds: number[] = [13, 14, 15, 16, 17, 18, 19, 21, 23, 26];
crowns = crowns.sort();
speeds = speeds.sort().reverse();
console.log('Bike gear calculator\n');
console.log('Crowns:\t', crowns);
console.log('Speeds:\t', speeds);
interface Development {
// #region Properties (5)
c_index: number;
crown: number;
metricDevelopment: number;
s_index: number;
speed: number;
// #endregion Properties (5)
}
let developments: Development[] = [];
for (let c in crowns) {
for (let s in speeds) {
let d: Development = {
crown: crowns[c],
speed: speeds[s],
metricDevelopment: crowns[c] / speeds[s],
c_index: +c + 1,
s_index: +s + 1
};
developments.push(d);
}
}
let developmentsSorted = developments.sort((a, b) => {
return a.metricDevelopment - b.metricDevelopment;
});
console.log('\nMetric developments sorted:\n');
for (let d of developmentsSorted) {
console.log('(' + d.c_index + ',', d.s_index + ')\t', d.crown, 'x', d.speed + '\t=>', d.metricDevelopment);
}