Skip to main content

Week 6 Tutorial: Compare swaps with all 720

Implement a swap improver, find where it stops, and measure its exact gap against all 720 permutations.

31 March 2027

You are hereW6 · Six homes · one swap

Open Week 6 in the Lab →Try your own change on this week's case.

Two-hour tutorial: preparation, coding and checks

This week’s task

Model: Editable symbolic jobs A–F first. The canonical #01–#06 case is a separate experiment with real flight costs.

Before you start · 15 minutes

Read W6. Predict what a full scan of 15 pair swaps proves and what it cannot prove.

Trace the example · 25 minutes

Inspect the starting swap result (48,55), then check all 720 sequences. The exact result is (46,51); explain the two-unit lateness gap.

Implement and compare · 55 minutes

Complete mySwaps using your timetable and the declared comparator. Log every accepted move and stop only after a full scan finds no strict improvement.

Use Open full Lab for editable inputs, strategy code, exports and the practice pack. The example on this page compares this week’s published cases; your local student runner must call the functions you complete.

Check and explain · 25 minutes

Check the final neighbourhood and retain the exact benchmark. Repeat on the canonical case and report its zero gap without claiming swaps always find an optimum.

What to keep: A1: local search, exact comparison and the complete draft. Show the tutor your prediction, experiment and explanation for this week’s participation point; keep the record to develop your assignment.

Optional extension

Edit a ready time in the six-job table and repeat the entire comparison from a fresh initial state.

W6 · Compare swaps with all 720 orders.

Week 6 · This week’s decision

Does checking every pair swap prove a global optimum?

These six jobs use small, symbolic time units. Compare a good sequence with the best of all 720 possibilities.

Checks passed

Sequence A → B → C → F → E → D. Course objective (lateness, final return, energy): 48, 55, 0. Every pair swap was checked; this proves only a local optimum.

Total lateness48
Final return55
Swaps checked30

Computed from this case · 1.31 ms · lab-1.0 · six-jobs

Starting case is ready.
720possible orders of six jobs

6 × 5 × 4 × 3 × 2 × 1

Enumeration not run

Swaps stop here. Is it the best?

A→B→C→F→E→D
MethodLatenessFinal return
Starting swaps4855
Exact resultNot runNot run

Small symbolic time units. Exhausting pair swaps proves only that this neighbourhood has no improvement.

Explore the evidence, replay or open full Lab

Open full Lab ↗ for editable inputs, strategy code and saved comparisons.

Compare the swap result (48,55) with the exact result (46,51), in symbolic time units.

Read the example above

Compare the swap result (48,55) with the exact result (46,51), in symbolic time units.

Symbolic teaching case · Published example units; not flight-model totals · Neighbourhoods, acceptance and exact comparison

The recurrence, order by order
InspectOrderReadyLoad startDepartDeliverReturnLateness
A5558110
B6111112130
C3131319257
F6252529337
E13333384313
D44343495521

Continue in the Lab →The same case, with every input open to change.

The spec

What you bring to the session. Written so a reader can tell whether it has been met without asking you.

Teaching team