-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
84 lines (72 loc) · 1.53 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
type LibraryResult = {
title: string,
user_id: number,
authors: string[],
description: string,
imageLink: string,
subject: string,
infoLink: string,
favorited: boolean,
isbn13: string,
date: Date,
rating: number,
datesRead: string[]
};
type FavoriteResult = {
title: string,
user_id: number,
authors: string[],
description: string,
subject: string,
imageLink: string,
infoLink: string,
isbn13: string,
date: Date
rating: number,
};
type ReadResult = {
title: string,
user_id: number,
authors: string[],
description: string,
imageLink: string,
subject: string,
infoLink: string,
inProgress: boolean,
isbn13: string,
date: Date
};
type PlateResult = {
weight: number,
count: number
}
if(Number.isNaN(parseInt(process.argv[2])) || process.argv[2] == null) {
console.log('please enter a valid barbell weight')
process.exit();
}
let barGoal = parseInt(process.argv[2]);
let barWeight = process.argv[3] ? parseInt(process.argv[3]) : 45;
barGoal -= barWeight;
const WEIGHT_VALUES = [
45,
35,
25,
15,
10,
5,
2.5
];
let results: PlateResult[] = [];
for(let i = 0; i < WEIGHT_VALUES.length; i++)
{
let count = Math.floor(barGoal / (WEIGHT_VALUES[i] * 2))
count *=2
results.push({
weight: WEIGHT_VALUES[i],
count
});
barGoal -= WEIGHT_VALUES[i] * count;
}
results.map(weight => {
console.log(`You will need ${weight.count} of ${weight.weight}.`)
});