# Enigmatic Code

Programming Enigma Puzzles

## Enigma 324: A week’s work

From New Scientist #1472, 5th September 1985 [link]

As you probably know, Nondag, Ondag, Pondag, Quondag, Rondag, Shondag and Tvondag are the days of the Ruritanian week. But I wonder if you know which is which.

Well, think of the week as starting with Monday. You can get three Ruritanian days right by calling out the alphabetical order above. That does not help much, of course, as you do not know which three. So her is another order which gets three right: Quondag, Ondag, Nondag, Pondag, Rondag, Tvondag, Shondag. And here is another which also gets three right: Tvondag, Quondag, Pondag, Ondag, Nondag, Shondag, Rondag.

That should be enough to go on. What is the fully correct order?

[enigma324]

### One response to “Enigma 324: A week’s work”

1. Jim Randell 18 December 2015 at 8:11 am

It’s easy enough to try all the possible orderings against the given ones.

This Python program runs in 52ms.

```from itertools import permutations
from enigma import join, printf

# days (by their initials)
days = 'NOPQRST'

# count the number of elements in the same position
def check(xs, ys):
return sum(x == y for (x, y) in zip(xs, ys))

# consider possible orderings
for ds in permutations(days):
# all the following sequences should have 3 days in the correct position
if all(check(ds, ss) == 3 for ss in (days, 'QONPRTS', 'TQPONSR')):
printf("days = {ds}", ds=join(ds, sep=' '))
```

Solution: The correct order is: Nondag (Monday), Quondag (Tuesday), Pondag (Wednesday), Ondag (Thursday), Rondag (Friday), Tvondag (Saturday), Shondag (Sunday).