Skip to content
Tutorials Center
My learning

Topics

Lesson 70 of 86 ยท Puzzles and Arrangements

Floor, Box, Day and Scheduling Puzzles

Solve floor, stacked-box, weekday, month and conditional scheduling puzzles with a clear method, case splits for if-then rules, and runnable checks.

Put people on floors, boxes in a pile, visits on days of the week or talks in time slots and you have the same puzzle you already know from rows: a set of items, a line of numbered slots and clues that connect them. The new difficulty is vocabulary ("above", "below", "ground floor", "the day after") and, in scheduling puzzles, conditional rules such as "if P goes before Q, then R goes last".

This lesson shows how to turn each of these puzzles into a numbered line, how to split into cases when a clue allows two possibilities, and how to deal with if-then rules without getting lost. Every worked puzzle is also run by a small program, so you can see exactly how many possibilities each clue removes. If row puzzles are new to you, start with Linear Seating Arrangements.

Turn everything into a numbered line

flowchart BT
    f1["Floor 1: lowest"] --> f2["Floor 2"] --> f3["Floor 3"] --> f4["Floor 4"] --> f5["Floor 5"] --> f6["Floor 6"] --> f7["Floor 7: topmost"]

A building is a vertical row: "above" means a larger floor number and "below" a smaller one.

Puzzle type Slots Direction words
Floors 1 (lowest) to n (topmost), sometimes "ground = 0" above, below, immediately above
Stacked boxes 1 (top) to n (bottom), or the other way round above, below, directly on top of
Weekdays Monday = 1 to Sunday = 7 before, after, the day after, two days before
Months January = 1 to December = 12 before, after, in the month after
Time slots 1st talk to nth talk earlier, later, immediately before

Decide the direction of your line before you place anything and write it next to your drawing ("1 = bottom"). Then each clue becomes arithmetic:

  • "immediately above A": floor(A) + 1
  • "G lives two floors below A": floor(A) - 2
  • "exactly three people live between B and G": the floors differ by 4
  • "as many floors above A as below A" in a building with n floors: A is on floor (n + 1) / 2 (so n must be odd)
  • "the day after Wednesday" is Thursday; "two days before Monday" is Saturday, because the week wraps around.

Ground floor needs care. In some puzzles "ground floor" is floor 0 and the first floor is above it; if the puzzle says "the building has seven floors, ground to sixth", count slots 0 to 6. Read the setup line twice.

Worked puzzle 1: seven people on seven floors

Seven people A to G live on seven floors of a building, numbered from 1 (lowest) to 7 (topmost). Exactly one person lives on each floor. Clues:

  1. As many people live above A as below A.
  2. G lives immediately below A.
  3. D lives immediately above A.
  4. B lives above D but not on the topmost floor.
  5. C lives immediately above F.

Clue 1 means A is on the middle floor, 4. Then G is on floor 3 and D on floor 5. B is above D, so on 6 or 7, and not the topmost, so B is on 6. Floors 1, 2 and 7 remain for C, E and F. C must be one floor above F, so (F, C) is (1, 2) and E takes floor 7.

From the bottom: F, C, G, A, D, B, E.

JS Floor puzzle: how clues shrink the search

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Worked puzzle 2: stacked boxes and a case split

Six boxes P, Q, R, S, T and U are stacked in one pile, one box per level. Number the levels from 1 (top) to 6 (bottom). Clues:

  1. R is exactly in the middle of the pile (level 3 or 4).
  2. Exactly two boxes lie between P and Q.
  3. S lies directly above R.
  4. T is at the top or at the bottom.
  5. U is somewhere above P.
  6. Q is below R.

"Exactly in the middle" of six is ambiguous, so treat it as a case split and test each case; one will die quickly.

Case R = 3. S is directly above, so S = 2. Two boxes between P and Q means their levels differ by 3. The free levels are 1, 4, 5, 6 and the only pair 3 apart is (1, 4). Q is below R, so Q = 4 and P = 1. Clue 5 says U is above P, but nothing is above level 1. Case dead.

Case R = 4. S = 3. The free levels are 1, 2, 5, 6; the only pair 3 apart is (2, 5). Q is below R (level 4), so Q = 5 and P = 2. U is above P, so U = 1. T takes level 6, the bottom, which agrees with clue 4.

From the top: U, P, S, R, Q, T.

Write both cases in your rough work and kill the failing one with the first clue it breaks. That beats guessing, and it is a method you will reuse in the next lessons.

Days of the week and months

Weekday puzzles are number lines of length 7. Months are lines of length 12. Remember:

  • The week wraps: the day after Sunday is Monday. If a puzzle talks about "the day after", check whether it means within the same week.
  • "Between" counts days strictly in the gap: exactly two days between A and F means the day numbers differ by 3.
  • "On a weekend" means Saturday or Sunday; "on a weekday" means Monday to Friday. Unless a puzzle says otherwise, "before" means earlier in the same week.

Worked puzzle 3. Seven friends A to G each visit a museum on a different day of one week, Monday to Sunday. Clues:

  1. D visits on the last day of the week.
  2. F visits on a weekend day.
  3. Exactly two days lie between A's day and F's day.
  4. B visits the day before F.
  5. G visits the day after A.
  6. C visits before E.

D is on Sunday. F is on a weekend day and Sunday is taken, so F visits on Saturday (day 6). Exactly two days between A and F: A is on day 3, Wednesday (day 9 does not exist). B, the day before F, is on Friday. G, the day after A, is on Thursday. Monday and Tuesday remain for C and E; C is before E, so C is on Monday and E on Tuesday.

Worked puzzle 4 (months and blocks). Four exams (Maths, Physics, Chemistry, Biology) are held one per month, March to June. Maths is immediately before Physics. Biology is immediately after Chemistry. Chemistry is not in March. Treat "Maths then Physics" and "Chemistry then Biology" as two glued blocks. The blocks can be in two orders: Maths-Physics first or Chemistry-Biology first. Chemistry would be in March in the second order, which is not allowed, so March is Maths, April Physics, May Chemistry, June Biology.

JS Weekday and month puzzles

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Conditional rules in schedules

Many exam puzzles add rules of the form "if X then Y". Three facts keep you safe:

  1. If the "if" part is true, the "then" part must be true.
  2. If the "then" part is false, the "if" part must be false. This is the contrapositive: "if P is before Q then R is last" is equivalent to "if R is not last then P is not before Q (so Q is before P)".
  3. If the "if" part is false, the rule says nothing. It does not mean the "then" part is false.
flowchart LR
    R["Rule: if P is before Q<br/>then R is last"] --> T1["P before Q: R must be last"]
    R --> T2["R is not last:<br/>Q is before P"]
    R --> T3["Q before P:<br/>rule is silent about R"]

A conditional rule fixes R only in the first case; the contrapositive covers the second; the third case gives no information.

Worked puzzle 5. Five talks P, Q, R, S and T are given in slots 1 to 5, one per slot. Rules:

  1. S is immediately before T.
  2. If P is before Q, then R is last.
  3. Q is not first.
  4. If R is first, then T is not last.

Glue S and T into one block "ST". Rule 2 splits the world into two cases. P before Q: R is last; the block ST, P and Q fill slots 1 to 4. Q before P: rule 2 says nothing about R. Rule 3 removes any schedule with Q in slot 1. Rule 4 only matters if R is first. Instead of enumerating by hand, let the program list every schedule that obeys all four rules, then ask questions about the list ("must", "can", "cannot").

JS List every schedule that obeys the rules

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Questions then become quick: "Who can be last?" Only P or R. S is never last because T must follow it. Q cannot be last: that would put P before Q, which forces R to be last. T cannot be last either: then S is fourth and P, Q, R fill the first three slots; Q is not first, and R is not first (rule 4), so P is first, which puts P before Q and forces R last, a contradiction. "Is T ever first?" No: S is always immediately before T, so T can never take slot 1.

Common traps

  • Mixing up top and bottom. Floors count from the bottom; a stack of boxes is often counted from the top. Write the direction down.
  • Treating "above" as "immediately above". "Above" only says larger; "immediately above" says one more.
  • Inverting a conditional. "If P before Q then R last" does not mean "if R is last then P is before Q". The contrapositive flips and negates both parts.
  • Letting the week wrap by accident. "Two days after Saturday" is Monday, not a day in the same week, unless the puzzle limits the schedule to one week.

Next you will meet puzzles where nothing is seated at all: people are compared by height, weight and marks.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. In worked puzzle 1 the floors from the bottom are F, C, G, A, D, B, E. Who lives immediately above D?

    D is on floor 5. The floor above it, floor 6, holds B.
  2. 2. In a building, X lives on floor 4 and Y lives five floors above X. How many floors lie between them?

    Y is on floor 9. The floors strictly between 4 and 9 are 5, 6, 7 and 8, which is 4 floors.
  3. 3. In worked puzzle 3 the visits are Mon C, Tue E, Wed A, Thu G, Fri B, Sat F, Sun D. Who visits the day after B?

    B visits on Friday, and Saturday belongs to F.
  4. 4. A rule says: if P is before Q, then R is last. R is not last in a schedule. What must be true?

    That is the contrapositive: if the 'then' part is false (R not last), the 'if' part is false, so P is not before Q, which means Q is before P.
  5. 5. In the five-talk puzzle with four rules, who can sit in the last slot?

    The program lists eight valid schedules. In every one the last talk is P or R.

Summary

  • Turn floors, stacks, days and months into a numbered line and write the direction (1 = bottom, 1 = top) next to it.
  • "Above" and "below" are not "immediately above" and "immediately below"; "exactly two between" means the numbers differ by 3.
  • When a clue allows two places (the middle of an even stack, an end), split into cases and let the first failing clue kill one of them.
  • Glue items that must stay together into blocks, and place the blocks.
  • A conditional rule says nothing when its "if" part is false; use the contrapositive when the "then" part is false.

Next: Ranking, Order and Comparison Puzzles.