TNP Challenge 2.2 Chefs Garden (TNP2_23) Editorial

We need to find whether the 3 petals(which may include flower itself) contain in single cell when they wither.So the positioning of flowers are represented as either A,B,C or . respectively.

For finding solution of we can consider the ASCII value of A,B, & C(65,66,& 67 respectively). For petals of 3 flowers to be in a single cell,the 3 flowers must be in consecutive cells,in any order.When they combine we can assume that the values get add up to be in a single cell.So we can check whether the sum of 3 consecutive array is 198(65+66+67=198) & 1st and third elements in that 3 consecutive cells must not be same.

If both the conditions are true, then we can say that a single cell can contain petals of 3 flowers.