The crown jewel in the collection of the eccentric museum director Idu Schurf is a room with fifteen paintings of Picasso from his blue period. Schurf has a reputation that he keeps his collection under constant movement. For his next exhibition he has has developed an extraordinary tool: the circadial permutator. The clamps that hold the paintings have been labeled 1 to 15, and on top of each clamp there is a note on the wall that says: "Move this painting to clamp …". The ellipsis are used here as a placeholder for an integer between 1 and 15. On the opening day of the exhibition, the paintings are displayed in the order as shown below. On top of each painting we show the integer that is on the note above the clamp to which the painting is attached.

14 6 15 3 4 10 1 12 5 2 7 13 8 11 9
haakje 1
Le vieux guitariste aveugle (1903), Chicago Art Institute, United States of America
haakje 2
Le gourmet (1901), National Gallery of Art, Washington, D.C., United States of America
haakje 3
Femme aux bras croisés (1902), private collection
haakje 4
La vie (1903), Cleveland Museum of Art, United States of America
haakje 5
The Tragedy (1903), National Gallery of Art, Washington, D.C., United States of America
haakje 6
Portrait bleu de Angel Fernandez de Soto (1903), private collection
haakje 7
Portrait de Suzanne Bloch (1904), São Paulo Museum of Art Collection, Brazil
haakje 8
Madame Soler (1905), Pinakothek der Moderne, Munich, Germany
haakje 9
Les noces de Pierrette (1905), Mitsui Trust Bank, Japan
haakje 10
Mère et enfant (1902), Metropolitan Museum of Art, United States of America
haakje 11
Autoportrait (1901), Musée National de Paris, France
haakje 12
La Celestine (1904), Musée National de Paris, France
haakje 13
Repas de l'aveugle (1903), Metropolitan Museum of Art, United States of America
haakje 14
Femme au chignon (1904), Art Institute of Chicago, United States of America
haakje 15
Femme à la chemise (1904), Tate Gallery, London, United Kingdom

The attendants have been given the job to remove the Picasso paintings every morning and carry out the task that is on the note. As such, the visitors of the museum can look at a refreshed exhibition on each successive day. On the second day of the exhibition, the paintings are displayed in the order as shown below. In this example you can see that the painting that was at clamp 7 on the first day, has been moved to clamp 1 on the second day.

14 6 15 3 4 10 1 12 5 2 7 13 8 11 9
haakje 1
 Portrait de Suzanne Bloch (1904), São Paulo Museum of Art Collection, Brazil
haakje 2
 Mère et enfant (1902), Metropolitan Museum of Art, United States of America
haakje 3
 La vie (1903), Cleveland Museum of Art, United States of America
haakje 4
 The Tragedy (1903), National Gallery of Art, Washington, D.C., United States of America
haakje 5
Les noces de Pierrette (1905), Mitsui Trust Bank, Japan
haakje 6
Le gourmet (1901), National Gallery of Art, Washington, D.C., United States of America
haakje 7
 Autoportrait (1901), Musée National de Paris, France
haakje 8
 Repas de l'aveugle (1903), Metropolitan Museum of Art, United States of America
haakje 9
 Femme à la chemise (1904), Tate Gallery, London, United Kingdom
haakje 10
 Portrait bleu de Angel Fernandez de Soto (1903), private collection
haakje 11
 Femme au chignon (1904), Art Institute of Chicago, United States of America
haakje 12
 Madame Soler (1905), Pinakothek der Moderne, Munich, Germany
haakje 13
La Celestine (1904), Musée National de Paris, Frankrijk
à
haakje 14
Le vieux guitariste aveugle (1903), Chicago Art Institute, United States of America
haakje 15
Femme aux bras croisés (1902), private collection

However, Schurf has not just randomly written some numbers on the notes above the clamps of the paintings. The director has organised them in such a way to ensure that the exhibition closes on the last day before all paintings are back on their original position as during the opening day. Can you compute how many days the exhibition lasts? Could Schurf have rearranged the numbers to keep the exhibition running a bit longer, and if so, how long? How long can Schurf hold an exhibition of $$n$$ Picasso paintings?

Assignment

We are going to solve a generalized version of the above problem, in which $$n$$ objects are rearranged according to a given permutation of the integers from 1 up to and including $$n$$. A permutation of the integers from 1 up to and including $$n$$ is a list that contains each integer from 1 up to and including $$n$$ just once. The order in which the integers occur is of no importance. When writing the functions described below, you need to make sure that any list passed as an argument to a functions is never modified by the function.

Example

>>> isPermutation([2, 5, 3, 1, 6, 4])
True
>>> isPermutation([1, 4, 2, 0, 5, 3])
False
>>> isPermutation([2, 5, 3, 8, 1, 6, 4])
False

>>> notes = [3, 4, 1, 2]
>>> paintings = ['mona lisa', 'the scream', 'ghent altarpiece', 'the kiss']
>>> paintings = permutator(notes, paintings)
>>> paintings
['ghent altarpiece', 'the kiss', 'mona lisa', 'the scream']
>>> paintings = permutator(notes, paintings)
>>> paintings
['mona lisa', 'the scream', 'ghent altarpiece', 'the kiss']

>>> notes = [14, 6, 15, 3, 4, 10, 1, 12, 5, 2, 7, 13, 8, 11, 9]
>>> paintings = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
>>> paintings = permutator(notes, paintings)
>>> paintings
[7, 10, 4, 5, 9, 2, 11, 13, 15, 6, 14, 8, 12, 1, 3]
>>> paintings = permutator(notes, paintings)
>>> paintings
[11, 6, 5, 9, 15, 10, 14, 12, 3, 2, 1, 13, 8, 7, 4]
>>> paintings = permutator(notes, paintings)
>>> paintings
[14, 2, 9, 15, 3, 6, 1, 8, 4, 10, 7, 12, 13, 11, 5]

>>> notes = [3, 4, 1, 2]
>>> closingday(notes)
2
>>> notes = [14, 6, 15, 3, 4, 10, 1, 12, 5, 2, 7, 13, 8, 11, 9]
>>> closingday(notes)