18 or 20 Trees and 2 isolated prisoners

Alice and Bob are trapped by an evil logician. Prison compound have 20 trees. Alice can see 12 trees from her prison cell. Bob can see 8 trees from his prison cell. They are told that there is no tree that is visible to both of them and together they see all the trees in compound.

Prison cells are built in a way that prisoners are completely isolated and can't communicate to each other in any way.

Each day the logician goes to Alice and ask if there are 18 trees or 20 trees in compound. He tells to Alice that if she answer it correctly then both she and Bob will be freed. However if she answers incorrectly then both will be executed. She can also choose not to answer and simply say pass.

Same is asked to Bob with same options and same consequences of answer. If Bob also choose to say pass, then same process is repeated in same order next day.

Can they earn freedom from evil logician.

Hint 1

Thinks about what information Bob can determine from pass from Alice and same way what information Alice can determine from pass from Bob

Hint 2

Don't get stuck on number 12 and 8

Hint 3

If Alice says pass on first day then Bob knows that Alice have 18 or less trees as otherwise she would have answered 20 in case if she could see 19 or 20 trees.

Hint 4

In first pass from Alice Bob got to know that Alice have 18 or less trees. If Bob could see 0 or 1 tree he could have answered as 18.

Solution

Day 1:

First Alice is asked the question. If Alice could see 19 or 20 trees she would have answered 20. But she sees 12 trees hence she choose to say PASS

Now Bob is asked the question.

Bob knows that only reason he is getting question asked is because Alice have opted for PASS. If Alice would have answered correctly then he would have been free. If Alice would have answered incorrectly then he would have been executed.

Hence from PASS call of Alice, Bob can determine that Alice sees 18 or less trees.

If Bob could see 0 tree then he would know that answer will be 18 as Alice can have 18 trees Max so in that case Alice will be having 18 trees as per him

If Bob could see 1 tree then also he could answer as 18 as sum of trees need to be either 18 or 20 but given Alice can have maximum 18 trees sum (18+1) will not reach 20 so Alice will have 17 trees as per him

But as Bob see 8 trees rather than 0 or 1, he choose to call PASS


Day 2:

Alice is asked the question so she knows that Bob opted for PASS on Day 1.

From this Alice knows that Bob have 2 or more trees else Bob could have answered.

If Alice could see 17 or 18 trees she could answer 20 as Bob have minimum 2 trees. But Alice sees 12 trees hence she choose to say PASS

Now Bob is asked the question so he knows that Alice has opted for PASS.

Bob also can determine that this means Alice have maximum 16 trees else she would have answered.

If Bob could see 2 or 3 trees he could have answered 18 as sum of max from Alice and what Bob sees is less than 20. But he sees 8 trees so he choose to call PASS


Keep iterating and on Day 5 Alice will know that Bob sees at least 8 trees. As Alice sees 12 trees, she will be able to answer as 20 and get free from the prison of evil logician.

Hope you enjoyed solving this puzzle.