In the PDF, complete part 2.
Here is so relevant code I completed in part 1.
// Durstenfeld shuffle – modern version of the Fisher-Yates shuffle
// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
function shuffle(a) {
for (let i = a.length – 1; i > 0; –i) {
let j = Math.floor(Math.random() * (i + 1));
let temp = a[i];
a[i] = a[j];
a[j] = temp;
}
return a;
}
function generateInputHelper(n) {
let a = Array.create(n, 0);
for (let i = 0; i < n; ++i) {
a[i] = i;
}
return shuffle(a);
}
function generateInput(n) {
let array2d = [];
for (let i = 0; i < n; ++i) {
array2d.push(generateInputHelper(n));
}
return array2d;
}
The runOracle function should follow this format which was defined in part 1:
function oracle(f) {
let numTests = 20; // Change this to some reasonably large value.
for (let i = 0; i < numTests; ++i) {
let n = 6; // Change this to some reasonable size
let companies = generateInput(n);
let candidates = generateInput(n);
let hires = f(companies, candidates);
test('Hires length is correct', function() {
assert(companies.length === hires.length);
});
}
Place this order or similar order and get an amazing discount. USE Discount code “GET20” for 20% discount