-
Notifications
You must be signed in to change notification settings - Fork 0
/
schoolbus.js
executable file
·47 lines (38 loc) · 1.03 KB
/
schoolbus.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
#!/bin/sh
':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"
"use strict";
//basic schoolbus algorithm
function schoolbus_basic(offsets, minRacking, maxRacking, xfer){
for (let i = 0; i < offsets.length; i++) {
xfer('f', i, 'b', i);
}
var currentOffset = minRacking;
while (currentOffset <= maxRacking) {
for (let i = 0; i < offsets.length; i++) {
if (offsets[i] == currentOffset) {
xfer('b', i, 'f', i+currentOffset);
}
}
currentOffset++;
}
}
module.exports.schoolbus_basic = schoolbus_basic;
if (require.main === module) {
console.log("Doing some test transfers.");
const testDriver = require('./test-driver.js');
//adaptor to fit into testDriver
function _schoolbus_basic(offsets, firsts, orders, limit, xfer) {
schoolbus_basic(offsets, -limit, limit, xfer);
}
if (process.argv.length > 2) {
testDriver.runTests(_schoolbus_basic, {
skipCables:true,
skipLong:true,
//ignoreStacks:true,
//ignoreEmpty:true,
ignoreFirsts:true,
outDir:'results/schoolbus'
});
return;
}
}