Skip to content

Sunday Times Teaser 3077 – Shuffling Series Schedules

by Brian Gladman on September 10, 2021

by Colin Vout

Published Sunday September 12 2021 (link)

A TV company planned a set of programmes to fill a weekly slot (one programme per week for many weeks) with six consecutive series of three different types (Arts, Biography and Comedy). None of the series was followed by another of the same type (eg, there could be an Arts series for three weeks then a Comedy series for four weeks and so on). Then it decided to change the order of the series within the same overall slot, but to minimise disruption it would not alter the gaps between series of the same type. It did this by scheduling each of the three Arts series 6 weeks earlier than first planned, each of the two Biography series 20 weeks later than first planned, and the Comedy series 21 weeks earlier than first planned.

How many programmes are there in each of the six series (listed in their final order)?

From → Uncategorized

4 Comments Leave one →
  1. Brian Gladman permalink

    This is quite slow in CPython but less than 500ms in PyPy. But Jim Randell has produced a neat and faster solution here. I also think it is a better approach because it avoids setting any limits on series lengths that are being considered. Here is Jim’s approach using the NumPy package:

    • Frits permalink

      @Brian, I think linalg.solve can be called on a higher level (shift lines 63-77 two positions to the left))

      • Brian Gladman permalink

        Thanks Ftrits,

        I just noticed this myself this morning as I was tidying up the code.

  2. Frits permalink

    Slow initial attempt (11 seconds with PyPy).

    Following is not the most elegant program but it runs in 9ms with Cpython.

Leave a Reply

Note: HTML is allowed. Your email address will not be published.

Subscribe to this comment feed via RSS