Student's Garden Plants

In the kindergarten garden, each child has four plants: two in the top row and two directly below them. The function plants receives a two-row diagram, where rows are separated by \n and each letter represents a plant. Students are assigned positions alphabetically, with two neighboring positions in each row: G means Grass, C means Clover, R means Radishes, and V means Violets.

Примеры

Ввод
"RC\nGG", "Alice"
Вывод
["Radishes", "Clover", "Grass", "Grass"]
Ввод
"VC\nRC", "Alice"
Вывод
["Violets", "Clover", "Radishes", "Clover"]
Ввод
"VVCCGG\nVVCCGG", "Bob"
Вывод
["Clover", "Clover", "Clover", "Clover"]

Нужно реализовать

def plants(diagram: str, student: str) -> list[str]:

Теги

stringsdict
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Visible tests
1
Input
"RC\nGG", "Alice"
Expected["Radishes","Clover","Grass","Grass"]
2
Input
"VC\nRC", "Alice"
Expected["Violets","Clover","Radishes","Clover"]
3
Input
"VVCCGG\nVVCCGG", "Bob"
Expected["Clover","Clover","Clover","Clover"]
4
Input
"VVCCGG\nVVCCGG", "Charlie"
Expected["Grass","Grass","Grass","Grass"]
5
Input
"VCRRGVRG\nRVGCCGCV", "David"
Expected["Radishes","Grass","Clover","Violets"]
6
Input
"GGCCVV\nGGCCVV", "Charlie"
Expected["Violets","Violets","Violets","Violets"]
Focus radio
Paused · SomaFM · Fluid