# 영어끝말잇기

> <https://programmers.co.kr/learn/courses/30/lessons/12981>

* 문제요약
  * 단어 재사용 안됨
  * 탈락발생 (나왔던 단어 / 규칙위반)
  * 탈락 발생이 몇바퀴째인지 반환
  * 탈락 발생 인덱스 반환

```python
def solution(n, words):

    a = [words[0][0]]

    # words 안에서 하나씩 a 에 추가
    for i, w in enumerate(words):
          # 새로 추가할 것이 이미 나왔던 것이나 규칙위반이면
        if (w in a) or a[-1][-1] != w[0]:
              # 현재 i 를 보고 [추가하던 인덱스, a의 row(몇번째)] 반환
            return [(i % n) + 1, (i // n) + 1]
                # 규칙위반 아니면 추가
        a.append(w)
        # 다 했으면 [0, 0] 반환
    return [0, 0]


n = 3
words = ["tank", "kick", 'know', 'wheel', 'land', 'dream', 'mother', 'robot', 'tank']

print(solution(n, words))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pyohamen.gitbook.io/til/algorithm/programmers/undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
