Main Content

Patterns in numbers - room occupancy

Archive - Originally posted on "The Horse's Mouth" - 2009-05-13 06:31:10 - Graham Ellis

I have often spotted patterns in the room numbers we have occupied - describing a night where 1, 3 and 5 are occupied but 2 and 4 are not as "odd" for example, and I have been surprised at how often the let combination allows me to come up with some such form of wording. I woke ... dawn is early at the moment ... and wondered just how many of the occupancy patterns could be met be a short description. And what better way to generate the pattern than a Python program ;-)

nrooms = 5
for room in range (2 ** nrooms):
  print "occupied:",
  for df in range(nrooms):
    pw = 2 ** df
    if room / pw % 2 == 1:
      print df+1,
  print


And the results?

occupied: "empty"
occupied: 1 "singular"
occupied: 2
occupied: 1 2 "bottoms"
occupied: 3 "one in the middle"
occupied: 1 3
occupied: 2 3
occupied: 1 2 3 "lowers"
occupied: 4 "factosisable"
occupied: 1 4 "squares"
occupied: 2 4 "even"
occupied: 1 2 4 "powers of 2"
occupied: 3 4
occupied: 1 3 4
occupied: 2 3 4 "middles"
occupied: 1 2 3 4 "top missing"
occupied: 5 "just the top"
occupied: 1 5 "extreme"
occupied: 2 5
occupied: 1 2 5
occupied: 3 5
occupied: 1 3 5 "odd"
occupied: 2 3 5 "prime"
occupied: 1 2 3 5 "Fibonacci"
occupied: 4 5 "tops"
occupied: 1 4 5
occupied: 2 4 5
occupied: 1 2 4 5 "hole in th middle"
occupied: 3 4 5 "uppers"
occupied: 1 3 4 5
occupied: 2 3 4 5 "non-singular"
occupied: 1 2 3 4 5 "full"

Hmm .. the majority (but not all) do describe to a pattern!