# The Haunted Mansion

Dear friend:

Shortly after buying this old mansion, I had the unpleasant surprise of seeing that it is bewitched with two sounds of the aftermath that make it practically uninhabitable. It is a picaresque song and a sardonic laugh.

I still have some hope, however, since experience has shown me that his behavior obeys certain dark but infallible laws and that it can be modified by touching the organ and burning incense.

In each minute, each sound is present or absent: what each of them will do in the next minute depends on what happens in the current minute as follows:

The song will keep the same state (present or absent) in the next minute unless if during the current minute the laughter is not heard and I play the organ, in which case the song takes the opposite state (If it was heard it will stop being heard and vice versa) .

As for laughter, if I don't burn incense, it will be heard or not depending on whether the song is present or absent (so that laughter imitates the song with a minute delay). Now, if I burn incense, laughter will do just the opposite of what the song did.

The moment I write to him, I am hearing both laughter and singing. I will be very grateful if you tell me what organ manipulations and incense should I follow to restore calm.

#### Solution

The conditions of the statement can be summarized
So:

• A - YES NO (LAUGHTER) AND ORGAN -> CANTO CAMBIA
• B - In any other case CANTO DOES NOT CHANGE
• C - IF INCENSE -> LAUGHTER will do the opposite of singing
• D - IF NOT (INCENSE), laughter will do the same as singing

The method to follow is summarized in the following table:

 Minute 1 2 3 4 5 LAUGHTER YES DO NOT DO NOT DO NOT DO NOT SINGING YES YES DO NOT DO NOT DO NOT INCENSE YES YES DO NOT DO NOT ORGAN IF NOT YES DO NOT DO NOT

When burning incense in minute 1, in 2 the laughter will not be heard (by C).
In minute 2, the song will be heard, whether the organ sounds or not (for A and B).
When burning incense in minute 2, in 3 laughter will not be heard (by C).
When the organ sounds in minute 2, in 3 the song will not be heard (by A).
By not burning incense in minute 3, in 4 laughter will not be heard (by D).
By not touching the organ in minute 3, in 4 the song will not be heard (by B).

Therefore, the manipulations we will make will be: in the first minute, burn incense; in the second minute burn incense and touch the organ, from the third minute we will stop touching the organ and burn incense and the calm will be eternal.