-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1.js
59 lines (47 loc) · 1.25 KB
/
1.js
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
function pyrva([...input]) {
let [sizeOfaSide, sheetsOfPaper, ...sheetData] = input
let sizeOfCube = 6 * Number(sizeOfaSide) * Number(sizeOfaSide)
let coveredFace = 0
for (let i = 2; i <= 2 * sheetsOfPaper; i += 2) {
if (i % 10 === 0) {
continue
}
let paperFace = (sheetData[i - 2] * sheetData[i - 1])
if (((i / 2)) % 3 === 0) {
paperFace = paperFace - paperFace / 4
}
coveredFace += paperFace
// if (coveredFace >= sizeOfCube) {
// break
// }
}
if (coveredFace >= sizeOfCube) {
console.log("You've covered the gift box!")
console.log(`${(((coveredFace - sizeOfCube) / coveredFace) * 100).toFixed(2)}% wrap paper left.`)
} else {
console.log('You are out of paper!')
console.log(`${(100 - ((coveredFace / sizeOfCube) * 100)).toFixed(2)}% of the box is not covered.`)
}
}
// pyrva(
// (["10",
// "5",
// "3",
// "0.5",
// "2.4",
// "5",
// "3.7",
// "1",
// "3",
// "34.7",
// "5",
// "80"])
// )
// pyrva(
// (["2",
// "2",
// "0.2",
// "7",
// "6",
// "8.5"])
// )