๋ฐ์ํ
๐ค๋ฌธ์ ํด๊ฒฐ
-
D3 | ๋ฌธ์์ด
๐จ ๋ฌธ์ฅ์ผ๋ก ๊ตฌ๋ถํ๊ณ , ๋จ์ด๋ก ๊ตฌ๋ถํ๊ธฐ
๐จ ์ด๋ฆ์ด ๋๋ ์กฐ๊ฑด์
์ฒซ๋ฒ์งธ ๊ธ์๊ฐ ๋๋ฌธ์์ด๊ณ , ๋๋จธ์ง๋ ์๋ฌธ์์ด๋ค.
์ฒซ๋ฒ์งธ ๊ธ์๊ฐ ํ๋์ผ ๊ฒฝ์ฐ๋ ์ด๋ฆ์ด๋ค.
( ์ซ์๊ฐ ์์ด๋ฉด x, ์ฒซ๋ฒ์งธ๋ ๋ฌด์กฐ๊ฑด ์๋ฌธ์, ๋ค์ ์ ์ด๋ ๋๋ํ๋ ๋ฌผ์ํ๋ ํ์์๋ค )
์์ ๋๊ฐ์ง ๊ฒฝ์ฐ๊ฐ ๋์ด๋ค. ๋ฌธ์ ๋ฅผ ์กฐ๊ธ ํท๊ฐ๋ฆฌ๊ฒ....
๐ป์์ค ์ฝ๋
for tc in range(int(input())):
N = int(input())
answer = list()
sentence = input()
# ๋ฌธ์ฅ ๊ตฌ๋ถํ๊ธฐ
start = 0
for i in range(len(sentence)):
if sentence[i] in ('!', '?', '.'):
# ๋จ์ด๋ก ๊ตฌ๋ถํ๊ธฐ
cnt = 0
for word in sentence[start:i].split():
# ์ด๋ฆ์ธ์ง ํ๋ณํ๊ธฐ
if (len(word) == 1 and word[0].isupper()) or (
word[0].isupper() and word.isalpha() and word[1:].islower()):
cnt += 1
start = i + 2
answer.append(cnt)
print(f'#{tc + 1}', *answer)
๐๋ฌธ์ ํ์ธ
์ถ์ฒ: SW Expert Academy
๋ฐ์ํ
'Algorithm Problem > Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[python] SWEA - 5688. ์ธ์ ๊ณฑ๊ทผ์ ์ฐพ์๋ผ (0) | 2020.12.10 |
---|---|
[python] SWEA - 9700. USB ๊ฝ๊ธฐ์ ๋ฏธ์คํฐ๋ฆฌ (0) | 2020.12.09 |
[python] SWEA - 10580. ์ ๋ด๋ (0) | 2020.12.06 |
[python] SWEA - 4047. ์์ค์ด์ ์นด๋ ์นด์ดํ (0) | 2020.12.01 |
[python] ๋ฐฑ์ค - 17140. ์ด์ฐจ์ ๋ฐฐ์ด๊ณผ ์ฐ์ฐ (2) | 2020.11.30 |