๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€(BOJ)

[ ํŒŒ์ด์ฌ(python) ] ๋ฐฑ์ค€ 7567 - ๊ทธ๋ฆ‡

by YWTechIT 2021. 6. 14.
728x90

๐Ÿ“ ๋ฐฑ์ค€ 7567 - ๊ทธ๋ฆ‡

๋ฐฑ์ค€ 7567 - ๊ทธ๋ฆ‡


โšก๏ธ ๋‚˜์˜ ํ’€์ด

๋‹จ์ˆœ ๊ตฌํ˜„ ๋ฌธ์ œ์ธ๋ฐ, ๊ทธ๋ฆ‡์„ ํฌ๊ฐค ๋•Œ์˜ ๋ฐฉํ–ฅ์ด ์ผ์น˜ํ•˜๋Š”์ง€ ์•„๋‹Œ์ง€ ํŒ๋ณ„ํ•˜๋ฉด ๋œ๋‹ค. ๋งจ ์ฒ˜์Œ ๊ทธ๋ฆ‡์€ ์ด์ „ ๊ทธ๋ฆ‡๊ณผ ๋น„๊ตํ•  ์ˆ˜ ์—†๊ธฐ ๋•Œ๋ฌธ์— ๋งจ ์ฒ˜์Œ ๊ทธ๋ฆ‡์˜ ์ ์ˆ˜ 10์ ์„ ์„ ์–ธ ํ•ด์ค€ ์ƒํƒœ์—์„œ ๋ฐ˜๋ณต๋ฌธ์˜ ๋ฒ”์œ„๋ฅผ index๊ฐ€ 1์ธ ์ง€์ ๋ถ€ํ„ฐ len(bowl)๊นŒ์ง€ ํ™•์ธํ•œ๋‹ค. ๋ฐ˜๋ณต๋ฌธ ๋‚ด๋ถ€์—์„œ ์ด์ „ ๊ทธ๋ฆ‡๊ณผ ๊ฐ™์œผ๋ฉด 5์ ์„ ๋ˆ„์ ์‹œํ‚ค๊ณ , ๋‹ค๋ฅด๋ฉด 10์ ์„ ๋ˆ„์ ์‹œํ‚จ๋‹ค.

bowl = input()
score = 10

for i in range(1, len(bowl)):
    if bowl[i-1] == bowl[i]:
        score += 5
    else:
        score += 10
print(score)
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€