Blueberry garden
An alien botanist is trying to grow blueberries. He has some blueberry seeds from Earth, but they got mixed with local sunshroom and fernivore seeds. He decides to plant them anyway because he really wants to know what blueberries taste like.
His garden has 10 slots for planting, all next to each other. He plants seeds in all of those 10 slots and waits for them to grow.
![Image created with DALL-E 2](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fb8c34d25-5ba6-4f76-9279-480e6988c7ea%2FDALLE_2023-03-15_11.58.10_-_an_alien_botanist_trying_to_grow_blueberries_digital_art.png?table=block&id=475efb83-461d-4d64-8cb9-b1cc093cb4f8&cache=v2)
However, he needs to be careful, because fernivores are harmful to blueberries and will contaminate blueberry plants directly next to them. Sunshrooms are harmless and they also neutralize a fernivore plant when it grows directly next to it.
You are given 10 integers as input, each one representing one slot, and your task is to determine if there is a contamination in the garden.
- Blueberries are represented by even numbers that are not divisible by 6.
- Sunshrooms are represented by odd numbers.
- Fernivores are represented by multiples of 6.
If there is contamination, print
Activate emergency protocol!
, otherwise print Check complete, blueberries are growing!
.Input | Output |
4
8
3
6
2
7
14
16
2
13 | Check complete, blueberries are growing! |
2
3
7
2
8
12
4
8
9
10 | Activate emergency protocol! |
9
3
1
2
4
3
3
7
6
6 | Check complete, blueberries are growing! |
9
8
5
6
12
4
13
2
3
7 | Activate emergency protocol! |
- In the first example, there is one fernivore at slot #4, represented by 6. However, it is neutralized by the sunshroom at slot #3, which is represented by 3, so we print
Check complete, blueberries are growing!
.
- In the second example, there is a fernivore at slot #6 surrounded by blueberries that has contaminated the garden, therefore we print
Activate emergency protocol!
.
- In the third example, there are two fernivores at slots #9 and #10, but they are not next to any blueberries, so there will be no contamination, therefore we print
Check complete, blueberries are growing!
.
- In the last example, there are two fernivores at slots #4 and #5. The fernivore at slot #5 will contaminate the blueberry at slot #6. Notice that there is a sunshroom at slot #3, but it will only neutralize the fernivore at slot #4, so the fernivore at slot #5 will contaminate the garden!
Tip 1
Try to solve this challenge using
for … else
and break
!Tip 2
You can simplify the code by replacing the numbers with letters (
b
for Blueberries, f
for fernivore, etc.), and then performing the analysis on the resulting sequence.Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB