Algorithm Problem/Python
[python] SWEA - 7675. ํต์ญ์ฌ ์ฑ๊ฒฝ์ด
deo2kim
2020. 12. 7. 17:52
๋ฐ์ํ
๐ค๋ฌธ์ ํด๊ฒฐ
-
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
SW Expert Academy
SW ํ๋ก๊ทธ๋๋ฐ ์ญ๋ ๊ฐํ์ ๋์์ด ๋๋ ๋ค์ํ ํ์ต ์ปจํ ์ธ ๋ฅผ ํ์ธํ์ธ์!
swexpertacademy.com
๋ฐ์ํ