# Plants vs Zombies!

Several plants and zombies (no more than 20 creatures in total) came to the party “Plants VS Zombies”, and it turned out that all the creatures are of different heights. When a plant speaks to a lower creature, it tells the truth, and speaking to a higher creature, it lies. Zombies, on the other hand, lie to lower creatures, and tell the truth to higher ones.

When starting the party, each participant approached each other and said either “I am higher than you” or “I am lower." The phrase “I am lower” was repeated 20 times. Saying goodbye, everyone had to approach each one again and say “I am higher and I am a plant." If some creature could not say this phrase, then it clapped its hands. There were 18 claps. Calculate how many creatures came to the party, and arrange them by height.

There are

11 creatures, with this height order: P > P > P > P > P > P > P > P > Z > P > Z.

Reasoning:

The phrase "I am lower" was repeated 20 times:

Plants tell the truth to lower creatures (so they would say "I am higher"), and lie to higher creatures (so they would also say "I am higher"). Zombies lie to lower creatures (saying "I am lower"), and tell the truth to higher creatures, also saying "I am lower". Therefore, saying "I am lower" means being a zombie.

So we know that

zombies spoke 20 times. If there are $$z$$ zombies and $$p$$ plants, then each zombie talks to $$(z+p-1)$$ creatures, so we have $$z \cdot (z+p-1) = 20 \quad\quad\quad (1)$$

As $$p\ge 0$$ and $$z+p\le 20$$, there are three possibilities:

$$z=5$$, $$z=4$$, or $$z=2$$.

The phrase "I am higher and I am a plant" could not be said in 18 occasions:

This phrase can be said by plants to lower creatures (because they tell the truth), or by plants to higher creatures (because they lie), or by zombies to lower creatures (because they lie). So the only case in which clapping is necessary is when a zombie talks to a higher creature.

Let us check the three possibilities for $$z$$:

If $$z=5$$, then $$z+p-1=4$$ (from (1)), so $$p=0$$. With $$5$$ zombies and no plants, zombies talk to higher creatures 10 times, so $$z$$ cannot be $$5$$.

If $$z=4$$, then from (1) we need $$z+p-1=5$$, so $$p=2$$. We need 18 instances of "zombie talks to higher creature", but even in the best case (P>P>Z>Z>Z>Z), this happens only 14 times. So $$z$$ cannot be 4.

If $$z=2$$, from (1) we have $$z+p-1=10$$, so $$p=9$$. We need 18 instances of "zombie talks to higher creature". As both zombies cannot be in the same position, the only possibility is that one zombie talks to 10 higher creatures, and the other one talks to 8 higher creatures. This leads to the final result:
P > P > P > P > P > P > P > P > Z > P > Z

• Nice reasoning! Commented Apr 4, 2021 at 11:33