-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4_14.js
More file actions
50 lines (35 loc) · 920 Bytes
/
Copy path4_14.js
File metadata and controls
50 lines (35 loc) · 920 Bytes
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
function tripleThreat(a) {
for (let i = 0; i < a.length - 2; i++) {
if ((a[i] === a[i + 1] - 1) && (a[i] === a[i + 2] - 2)) {
return 1;
}
}
return 0;
}
function createPackage(small, big, goal) {
if (goal === 0) return small;
let origSmall = small
while (big > 0 && goal >= 5) {
goal = goal - 5;
big--;
}
if (goal === 0) return origSmall - small;
while (small > 0 && goal > 0) {
goal = goal - 1;
small--;
}
if (goal === 0) return origSmall - small;
return -1
}
// # @param { Integer[] } nums
// # @return { Integer[][] }
// def permute(nums)
// num_arrays = (1..nums).inject{| num, acc | num * acc }
// perm_arrays = Array.new(num_arrays) { Array.new(nums.length) }
// offset = 0
// nums.each_with_index do | num, idx |
// num_arrays.times do
// end
// end
// perm_arrays
// end