custom-permutation 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -44
- package/lib/CustomPermutation.d.ts +2 -3
- package/lib/CustomPermutation.js +19 -60
- package/lib/CustomPermutation.js.map +1 -1
- package/lib/CustomPermutationGenerator.d.ts +7 -19
- package/lib/CustomPermutationGenerator.js +111 -165
- package/lib/CustomPermutationGenerator.js.map +1 -1
- package/lib/PermutationGeneratorForSet.d.ts +10 -17
- package/lib/PermutationGeneratorForSet.js +124 -242
- package/lib/PermutationGeneratorForSet.js.map +1 -1
- package/lib/index.js +10 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/lib/Enums.d.ts +0 -39
- package/lib/Enums.js +0 -49
- package/lib/Enums.js.map +0 -1
- package/lib/Permutation.d.ts +0 -26
- package/lib/Permutation.js +0 -265
- package/lib/Permutation.js.map +0 -1
- package/lib/Utils.d.ts +0 -4
- package/lib/Utils.js +0 -34
- package/lib/Utils.js.map +0 -1
package/lib/Enums.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CheckResultEnum = exports.PermResultTypeEnum = exports.CheckFunctionsErrorTypeEnum = exports.MonthEnum = exports.SlotTypeEnum = void 0;
|
|
4
|
-
var SlotTypeEnum;
|
|
5
|
-
(function (SlotTypeEnum) {
|
|
6
|
-
SlotTypeEnum[SlotTypeEnum["Weekday"] = 1] = "Weekday";
|
|
7
|
-
SlotTypeEnum[SlotTypeEnum["Holiday"] = 2] = "Holiday";
|
|
8
|
-
})(SlotTypeEnum = exports.SlotTypeEnum || (exports.SlotTypeEnum = {}));
|
|
9
|
-
var MonthEnum;
|
|
10
|
-
(function (MonthEnum) {
|
|
11
|
-
MonthEnum[MonthEnum["January"] = 0] = "January";
|
|
12
|
-
MonthEnum[MonthEnum["February"] = 1] = "February";
|
|
13
|
-
MonthEnum[MonthEnum["March"] = 2] = "March";
|
|
14
|
-
MonthEnum[MonthEnum["April"] = 3] = "April";
|
|
15
|
-
MonthEnum[MonthEnum["May"] = 4] = "May";
|
|
16
|
-
MonthEnum[MonthEnum["June"] = 5] = "June";
|
|
17
|
-
MonthEnum[MonthEnum["July"] = 6] = "July";
|
|
18
|
-
MonthEnum[MonthEnum["August"] = 7] = "August";
|
|
19
|
-
MonthEnum[MonthEnum["September"] = 8] = "September";
|
|
20
|
-
MonthEnum[MonthEnum["October"] = 9] = "October";
|
|
21
|
-
MonthEnum[MonthEnum["November"] = 10] = "November";
|
|
22
|
-
MonthEnum[MonthEnum["December"] = 11] = "December";
|
|
23
|
-
})(MonthEnum = exports.MonthEnum || (exports.MonthEnum = {}));
|
|
24
|
-
var CheckFunctionsErrorTypeEnum;
|
|
25
|
-
(function (CheckFunctionsErrorTypeEnum) {
|
|
26
|
-
CheckFunctionsErrorTypeEnum[CheckFunctionsErrorTypeEnum["SamePersonInSameDayInBothList"] = 0] = "SamePersonInSameDayInBothList";
|
|
27
|
-
CheckFunctionsErrorTypeEnum[CheckFunctionsErrorTypeEnum["ConsecutiveSamePersonInSameList"] = 1] = "ConsecutiveSamePersonInSameList";
|
|
28
|
-
CheckFunctionsErrorTypeEnum[CheckFunctionsErrorTypeEnum["SamePersonAtNorthWest"] = 2] = "SamePersonAtNorthWest";
|
|
29
|
-
CheckFunctionsErrorTypeEnum[CheckFunctionsErrorTypeEnum["SamePersonAtNorthEast"] = 3] = "SamePersonAtNorthEast";
|
|
30
|
-
CheckFunctionsErrorTypeEnum[CheckFunctionsErrorTypeEnum["SamePersonAtSouthEast"] = 4] = "SamePersonAtSouthEast";
|
|
31
|
-
CheckFunctionsErrorTypeEnum[CheckFunctionsErrorTypeEnum["SamePersonAtSouthWest"] = 5] = "SamePersonAtSouthWest";
|
|
32
|
-
})(CheckFunctionsErrorTypeEnum = exports.CheckFunctionsErrorTypeEnum || (exports.CheckFunctionsErrorTypeEnum = {}));
|
|
33
|
-
// Permutation Results
|
|
34
|
-
var PermResultTypeEnum;
|
|
35
|
-
(function (PermResultTypeEnum) {
|
|
36
|
-
PermResultTypeEnum[PermResultTypeEnum["FOUND"] = 1] = "FOUND";
|
|
37
|
-
PermResultTypeEnum[PermResultTypeEnum["TRYNEXT"] = 2] = "TRYNEXT";
|
|
38
|
-
PermResultTypeEnum[PermResultTypeEnum["ENDOFPERMUTATION"] = 3] = "ENDOFPERMUTATION";
|
|
39
|
-
})(PermResultTypeEnum = exports.PermResultTypeEnum || (exports.PermResultTypeEnum = {}));
|
|
40
|
-
var CheckResultEnum;
|
|
41
|
-
(function (CheckResultEnum) {
|
|
42
|
-
CheckResultEnum[CheckResultEnum["TRYNEXT"] = 1] = "TRYNEXT";
|
|
43
|
-
CheckResultEnum[CheckResultEnum["TRYNEXTWD"] = 2] = "TRYNEXTWD";
|
|
44
|
-
CheckResultEnum[CheckResultEnum["TRYNEXTHD"] = 3] = "TRYNEXTHD";
|
|
45
|
-
CheckResultEnum[CheckResultEnum["TRYNEXTHDANDWDBOTH"] = 4] = "TRYNEXTHDANDWDBOTH";
|
|
46
|
-
CheckResultEnum[CheckResultEnum["NOSOLUTION"] = 5] = "NOSOLUTION";
|
|
47
|
-
CheckResultEnum[CheckResultEnum["NOTTRIEDYET"] = 6] = "NOTTRIEDYET";
|
|
48
|
-
})(CheckResultEnum = exports.CheckResultEnum || (exports.CheckResultEnum = {}));
|
|
49
|
-
//# sourceMappingURL=Enums.js.map
|
package/lib/Enums.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Enums.js","sourceRoot":"","sources":["../src/Enums.ts"],"names":[],"mappings":";;;AAAA,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,qDAAW,CAAA;AACb,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAED,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB,+CAAW,CAAA;IACX,iDAAY,CAAA;IACZ,2CAAS,CAAA;IACT,2CAAS,CAAA;IACT,uCAAO,CAAA;IACP,yCAAQ,CAAA;IACR,yCAAQ,CAAA;IACR,6CAAU,CAAA;IACV,mDAAa,CAAA;IACb,+CAAW,CAAA;IACX,kDAAa,CAAA;IACb,kDAAa,CAAA;AACf,CAAC,EAbW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAapB;AAGD,IAAY,2BAOX;AAPD,WAAY,2BAA2B;IACrC,+HAA6B,CAAA;IAC7B,mIAA+B,CAAA;IAC/B,+GAAqB,CAAA;IACrB,+GAAqB,CAAA;IACrB,+GAAqB,CAAA;IACrB,+GAAqB,CAAA;AACvB,CAAC,EAPW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAOtC;AAED,sBAAsB;AACtB,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,6DAAS,CAAA;IACT,iEAAO,CAAA;IACP,mFAAgB,CAAA;AAClB,CAAC,EAJW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAI7B;AAED,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,2DAAW,CAAA;IACX,+DAAS,CAAA;IACT,+DAAS,CAAA;IACT,iFAAkB,CAAA;IAClB,iEAAU,CAAA;IACV,mEAAW,CAAA;AACb,CAAC,EAPW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAO1B"}
|
package/lib/Permutation.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare class Permutation {
|
|
2
|
-
private list;
|
|
3
|
-
private stepCount;
|
|
4
|
-
private dayIndexes;
|
|
5
|
-
uniformedArr: any[];
|
|
6
|
-
permGen: any;
|
|
7
|
-
previous: any[];
|
|
8
|
-
current: any[];
|
|
9
|
-
cursor: number;
|
|
10
|
-
history: any[];
|
|
11
|
-
constructor(list: any[], stepCount: number, dayIndexes: number[]);
|
|
12
|
-
init(list: any[], stepCount: number, dayIndexes: number[]): void;
|
|
13
|
-
prev(): any;
|
|
14
|
-
next(): any;
|
|
15
|
-
reset(): void;
|
|
16
|
-
getList(): any[];
|
|
17
|
-
isEmpty(): boolean;
|
|
18
|
-
last(): void;
|
|
19
|
-
areArraysEqual(arr1: any[], arr2: any[]): boolean;
|
|
20
|
-
distributeItemsUniformly_old(arr: any): any[];
|
|
21
|
-
getFreqs(arr: any): {};
|
|
22
|
-
getKeysSortedByFreq(freq: any): any[];
|
|
23
|
-
distributeItemsUniformly(arr: any): any[];
|
|
24
|
-
giveNotConsecutives(arrToBePermutated: any): Generator<any, void, unknown>;
|
|
25
|
-
anyConsecutiveNonZeroItem(arr: any): boolean;
|
|
26
|
-
}
|
package/lib/Permutation.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
3
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
5
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
|
-
function step(op) {
|
|
7
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
-
while (_) try {
|
|
9
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
|
-
switch (op[0]) {
|
|
12
|
-
case 0: case 1: t = op; break;
|
|
13
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
14
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
16
|
-
default:
|
|
17
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
20
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
21
|
-
if (t[2]) _.ops.pop();
|
|
22
|
-
_.trys.pop(); continue;
|
|
23
|
-
}
|
|
24
|
-
op = body.call(thisArg, _);
|
|
25
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
26
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.Permutation = void 0;
|
|
31
|
-
var G = require('generatorics');
|
|
32
|
-
var Permutation = /** @class */ (function () {
|
|
33
|
-
function Permutation(list, stepCount, dayIndexes) {
|
|
34
|
-
if (stepCount === void 0) { stepCount = 1; }
|
|
35
|
-
this.list = list;
|
|
36
|
-
this.stepCount = stepCount;
|
|
37
|
-
this.dayIndexes = dayIndexes;
|
|
38
|
-
this.previous = [];
|
|
39
|
-
this.current = [];
|
|
40
|
-
this.cursor = 0;
|
|
41
|
-
this.history = [];
|
|
42
|
-
this.init(list, stepCount, dayIndexes);
|
|
43
|
-
}
|
|
44
|
-
Permutation.prototype.init = function (list, stepCount, dayIndexes) {
|
|
45
|
-
if (stepCount === void 0) { stepCount = 1; }
|
|
46
|
-
if (list.length === 0) {
|
|
47
|
-
console.warn('Empty list permutation!');
|
|
48
|
-
}
|
|
49
|
-
this.uniformedArr = this.distributeItemsUniformly(list.slice());
|
|
50
|
-
this.permGen = this.giveNotConsecutives(this.uniformedArr.slice());
|
|
51
|
-
// this.permGen = this.giveNotConsecutives(this.list.slice());
|
|
52
|
-
};
|
|
53
|
-
Permutation.prototype.prev = function () {
|
|
54
|
-
// cursor points the one after current element, index of cursor-1 points to the last given element, so current cursor - 2 is prev
|
|
55
|
-
if (this.cursor > 1) {
|
|
56
|
-
this.cursor -= 1;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
alert('at very first of perm');
|
|
60
|
-
}
|
|
61
|
-
return this.history[this.cursor - 1];
|
|
62
|
-
};
|
|
63
|
-
Permutation.prototype.next = function () {
|
|
64
|
-
// if cursor does not point the new element, then give from history
|
|
65
|
-
if (this.cursor < this.history.length) {
|
|
66
|
-
return this.history[this.cursor++];
|
|
67
|
-
}
|
|
68
|
-
Object.assign(this.previous, this.current);
|
|
69
|
-
var next = this.permGen.next() || {};
|
|
70
|
-
Object.assign(this.current, next.value);
|
|
71
|
-
/*prev-> this.cursor ? this.history[this.cursor-1] : [] */
|
|
72
|
-
while (this.areArraysEqual(this.previous, this.current)) {
|
|
73
|
-
// console.log("equal", this.previous, this.current)
|
|
74
|
-
Object.assign(this.previous, this.current);
|
|
75
|
-
var obj = this.permGen.next();
|
|
76
|
-
if (!obj || obj.done) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
Object.assign(this.current, obj.value);
|
|
80
|
-
}
|
|
81
|
-
this.history.push(this.current.slice());
|
|
82
|
-
this.cursor++;
|
|
83
|
-
return this.current;
|
|
84
|
-
};
|
|
85
|
-
// do not delete history, since it will be needed for prev()
|
|
86
|
-
Permutation.prototype.reset = function () {
|
|
87
|
-
// this.permGen = this.giveNotConsecutives(this.uniformedArr);
|
|
88
|
-
this.cursor = 0;
|
|
89
|
-
};
|
|
90
|
-
Permutation.prototype.getList = function () {
|
|
91
|
-
return this.list || [];
|
|
92
|
-
};
|
|
93
|
-
Permutation.prototype.isEmpty = function () {
|
|
94
|
-
return this.list.length === 0 || !this.list;
|
|
95
|
-
};
|
|
96
|
-
Permutation.prototype.last = function () {
|
|
97
|
-
this.cursor = this.history.length - 1;
|
|
98
|
-
};
|
|
99
|
-
Permutation.prototype.areArraysEqual = function (arr1, arr2) {
|
|
100
|
-
if (arr1.length !== arr2.length) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
for (var i = 0; i < arr1.length; i++) {
|
|
104
|
-
if (arr1[i] !== arr2[i]) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
};
|
|
110
|
-
// old
|
|
111
|
-
Permutation.prototype.distributeItemsUniformly_old = function (arr) {
|
|
112
|
-
var freqs = {};
|
|
113
|
-
var uniformed = [];
|
|
114
|
-
for (var i = 0; i < arr.length; i++) {
|
|
115
|
-
freqs[arr[i]] = freqs[arr[i]] + 1 || 1;
|
|
116
|
-
}
|
|
117
|
-
var keys = Object.keys(freqs);
|
|
118
|
-
var consumedKeyCount = 0;
|
|
119
|
-
while (consumedKeyCount < keys.length) {
|
|
120
|
-
consumedKeyCount = 0;
|
|
121
|
-
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
122
|
-
var key = keys_1[_i];
|
|
123
|
-
if (freqs[key]) {
|
|
124
|
-
uniformed.push(key);
|
|
125
|
-
freqs[key]--;
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
consumedKeyCount++;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return uniformed;
|
|
133
|
-
};
|
|
134
|
-
Permutation.prototype.getFreqs = function (arr) {
|
|
135
|
-
var freqs = {};
|
|
136
|
-
for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
|
|
137
|
-
var item = arr_1[_i];
|
|
138
|
-
if (freqs[item]) {
|
|
139
|
-
freqs[item]++;
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
freqs[item] = 1;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return freqs;
|
|
146
|
-
};
|
|
147
|
-
// first element will be max valued
|
|
148
|
-
Permutation.prototype.getKeysSortedByFreq = function (freq) {
|
|
149
|
-
var keys = Object.keys(freq);
|
|
150
|
-
var keysSortedByFreq = [];
|
|
151
|
-
var valuesSortedByFreq = [];
|
|
152
|
-
var _loop_1 = function () {
|
|
153
|
-
var keyOfMax = keys[0];
|
|
154
|
-
var max = freq[keyOfMax];
|
|
155
|
-
for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
|
|
156
|
-
var key = keys_2[_i];
|
|
157
|
-
if (max < freq[key]) {
|
|
158
|
-
keyOfMax = key;
|
|
159
|
-
max = freq[key];
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
keysSortedByFreq.push(keyOfMax);
|
|
163
|
-
valuesSortedByFreq.push(max);
|
|
164
|
-
keys = keys.filter(function (x) { return x !== keyOfMax; });
|
|
165
|
-
};
|
|
166
|
-
while (keys.length > 0) {
|
|
167
|
-
_loop_1();
|
|
168
|
-
}
|
|
169
|
-
return keysSortedByFreq;
|
|
170
|
-
};
|
|
171
|
-
Permutation.prototype.distributeItemsUniformly = function (arr) {
|
|
172
|
-
var freqs = this.getFreqs(arr);
|
|
173
|
-
console.log(freqs);
|
|
174
|
-
var size = 0;
|
|
175
|
-
var keys = this.getKeysSortedByFreq(freqs);
|
|
176
|
-
console.log(keys);
|
|
177
|
-
for (var _i = 0, keys_3 = keys; _i < keys_3.length; _i++) {
|
|
178
|
-
var key = keys_3[_i];
|
|
179
|
-
size += freqs[key];
|
|
180
|
-
}
|
|
181
|
-
var uniformedArr = Array(size).fill(undefined);
|
|
182
|
-
for (var _a = 0, keys_4 = keys; _a < keys_4.length; _a++) {
|
|
183
|
-
var key = keys_4[_a];
|
|
184
|
-
var freqOfKey = freqs[key];
|
|
185
|
-
var start = uniformedArr.indexOf(undefined);
|
|
186
|
-
var shift = 0;
|
|
187
|
-
var freqOfEl = freqs[key];
|
|
188
|
-
var shiftAmount = Math.ceil(size / freqOfEl);
|
|
189
|
-
var index = 0;
|
|
190
|
-
while (freqs[key]) {
|
|
191
|
-
var index_1 = start + shift;
|
|
192
|
-
// if el on index is not empty, go next
|
|
193
|
-
while (uniformedArr[index_1] && index_1 < size) {
|
|
194
|
-
index_1++;
|
|
195
|
-
}
|
|
196
|
-
// if until end no any empty, go prev
|
|
197
|
-
if (index_1 === size) {
|
|
198
|
-
while (uniformedArr[index_1] && index_1 >= 0) {
|
|
199
|
-
index_1--;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (index_1 < size && index_1 >= 0) {
|
|
203
|
-
uniformedArr[index_1] = key;
|
|
204
|
-
shift += shiftAmount;
|
|
205
|
-
freqs[key]--;
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
console.log('distributeUniformly: Element is not set to an index!');
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return uniformedArr;
|
|
214
|
-
// console.log(uniformedArr);
|
|
215
|
-
};
|
|
216
|
-
// give permutations
|
|
217
|
-
Permutation.prototype.giveNotConsecutives = function (arrToBePermutated) {
|
|
218
|
-
var differentConsecutives, perms, perm, i, j;
|
|
219
|
-
return __generator(this, function (_a) {
|
|
220
|
-
switch (_a.label) {
|
|
221
|
-
case 0:
|
|
222
|
-
differentConsecutives = [];
|
|
223
|
-
perms = G.permutation(arrToBePermutated);
|
|
224
|
-
i = 0;
|
|
225
|
-
_a.label = 1;
|
|
226
|
-
case 1:
|
|
227
|
-
if (!true) return [3 /*break*/, 4];
|
|
228
|
-
j = 0;
|
|
229
|
-
while (j++ < this.stepCount) {
|
|
230
|
-
perm = perms.next();
|
|
231
|
-
}
|
|
232
|
-
if (!perm || perm.done) {
|
|
233
|
-
return [3 /*break*/, 4];
|
|
234
|
-
}
|
|
235
|
-
if (!!this.anyConsecutiveNonZeroItem(perm.value)) return [3 /*break*/, 3];
|
|
236
|
-
differentConsecutives.push(perm.value.slice());
|
|
237
|
-
return [4 /*yield*/, (perm.value)];
|
|
238
|
-
case 2:
|
|
239
|
-
_a.sent();
|
|
240
|
-
return [3 /*break*/, 3];
|
|
241
|
-
case 3: return [3 /*break*/, 1];
|
|
242
|
-
case 4: return [2 /*return*/];
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
// Since holidays and weekdays are seperated, doesn't sense to check consecutively
|
|
247
|
-
Permutation.prototype.anyConsecutiveNonZeroItem = function (arr) {
|
|
248
|
-
// for (let i = 1; i < arr.length; i++) {
|
|
249
|
-
// if (Number(arr[i]) && arr[i] === arr[i - 1]) {
|
|
250
|
-
// return true;
|
|
251
|
-
// }
|
|
252
|
-
// }
|
|
253
|
-
for (var i = 1; i < this.dayIndexes.length; i++) {
|
|
254
|
-
if (Math.abs(this.dayIndexes[i] - this.dayIndexes[i - 1]) == 1) { // means consecutive
|
|
255
|
-
if (arr[i] == arr[i - 1] && Number(arr[i])) {
|
|
256
|
-
return true;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return false;
|
|
261
|
-
};
|
|
262
|
-
return Permutation;
|
|
263
|
-
}());
|
|
264
|
-
exports.Permutation = Permutation;
|
|
265
|
-
//# sourceMappingURL=Permutation.js.map
|
package/lib/Permutation.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Permutation.js","sourceRoot":"","sources":["../src/Permutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEhC;IASE,qBAAoB,IAAW,EAAU,SAAqB,EAAU,UAAoB;QAAnD,0BAAA,EAAA,aAAqB;QAA1C,SAAI,GAAJ,IAAI,CAAO;QAAU,cAAS,GAAT,SAAS,CAAY;QAAU,eAAU,GAAV,UAAU,CAAU;QAL5F,aAAQ,GAAU,EAAE,CAAC;QACrB,YAAO,GAAU,EAAE,CAAC;QACpB,WAAM,GAAG,CAAC,CAAC;QACX,YAAO,GAAU,EAAE,CAAC;QAGlB,IAAI,CAAC,IAAI,CAAC,IAAI,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,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;oBAC1C,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEH,kBAAC;AAAD,CAAC,AA9QD,IA8QC;AA9QY,kCAAW"}
|
package/lib/Utils.d.ts
DELETED
package/lib/Utils.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Utils = void 0;
|
|
4
|
-
var Utils = /** @class */ (function () {
|
|
5
|
-
function Utils() {
|
|
6
|
-
}
|
|
7
|
-
Utils.shuffleArray = function (array) {
|
|
8
|
-
var _a;
|
|
9
|
-
for (var i = array.length - 1; i > 0; i--) {
|
|
10
|
-
var j = Math.floor(Math.random() * (i + 1));
|
|
11
|
-
_a = [array[j], array[i]], array[i] = _a[0], array[j] = _a[1];
|
|
12
|
-
}
|
|
13
|
-
return array;
|
|
14
|
-
};
|
|
15
|
-
Utils.shuffle = function (array, swapTimes) {
|
|
16
|
-
if (swapTimes === void 0) { swapTimes = array.length; }
|
|
17
|
-
var currentIndex = swapTimes;
|
|
18
|
-
var temporaryValue, randomIndex;
|
|
19
|
-
// While there remain elements to shuffle...
|
|
20
|
-
while (0 !== currentIndex) {
|
|
21
|
-
// Pick a remaining element...
|
|
22
|
-
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
23
|
-
currentIndex -= 1;
|
|
24
|
-
// And swap it with the current element.
|
|
25
|
-
temporaryValue = array[currentIndex];
|
|
26
|
-
array[currentIndex] = array[randomIndex];
|
|
27
|
-
array[randomIndex] = temporaryValue;
|
|
28
|
-
}
|
|
29
|
-
return array;
|
|
30
|
-
};
|
|
31
|
-
return Utils;
|
|
32
|
-
}());
|
|
33
|
-
exports.Utils = Utils;
|
|
34
|
-
//# sourceMappingURL=Utils.js.map
|
package/lib/Utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|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