Transportation problem: Difference between revisions
Content added Content deleted
(+ D entry) |
(→{{header|Java}}: added some comments) |
||
Line 1,327: | Line 1,327: | ||
path.addFirst(s); |
path.addFirst(s); |
||
// remove (and keep removing) elements that do not have a |
|||
// vertical AND horizontal neighbor |
|||
while (path.removeIf(e -> { |
while (path.removeIf(e -> { |
||
Shipment[] nbrs = getNeighbors(e, path); |
Shipment[] nbrs = getNeighbors(e, path); |
||
Line 1,332: | Line 1,334: | ||
})); |
})); |
||
// place the remaining elements in the correct plus-minus order |
|||
Shipment[] stones = path.toArray(new Shipment[path.size()]); |
Shipment[] stones = path.toArray(new Shipment[path.size()]); |
||
Shipment prev = s; |
Shipment prev = s; |