# Guess the Secret Word

Ted, Barney and Marshall are three Students of HIMYM School. They were extremly good at logic.

Teacher Lily was new to the school and she want to test this students.

She wrote six words on the board:
dog, max, tag, cat, has, dim

Then she hands a piece of paper to Ted, another to Barney and another to Marshall. Teacher Lily wrote 1 letter in each paper and told them that by combining all these letter it forms the word, which is one of these six.

No one can see other's paper.

Then following conversation held between all 4

Teacher: Ted, do you know the word?

Ted: Yes, I do.

Teacher: Barney, do you know the word?

Barney: If Ted knows, I know.

Teacher: That's impressive, What about you Marshall?

Marshall: If Ted and Barney knows the word, I know.

They all know the word. So, what is the secret word?

Explanation:
When teacher asked ted, if he know the word and Ted reply "yes".

lets say Ted got letter 'a'. 'a' occurs in 'max', 'tag', 'cat' and 'has'

From letter 'a', Ted cannot conclude the secret letter

This means letter in Ted's paper must be unique.

Lets ckeck the uniques letter

#### dog, max, tag, cat, has, dim

Therefore letter in Ted's paper must be one of these(o, x, c, h or s, i)

And from this we can conclude that tag has no unique letter and tag is not the secret word.

Then teacher asked Barney, if he know the word and Barney reply "If Ted knows, I know".

After listing Ted's answer Barney know the answer, which means, Barney got the unique letter from the non colored letters.

lets chech the unique letter for Barney

#### dog, max, cat, has, dim

Here, in word 'has' if Ted got letter 'h', Baney could have 's' and vice versa

From this we can conclude that max and dim are not the secret words.

Then Teacher asked Marshall, if he know the answer, and Marshall reply "If Ted and Barney knows the word, I know".

After listing both answer, he was able to figure out the secret word.

we can conclude that the letter of Marshall must be unique from the remaining, lets color them green

#### dog, cat, has

Only 'h' was unique as 'a' appear twice(cat and has)

The secret word is "dog".