MapleStory Finger Point

๐Ÿƒ‍โ™‚๏ธBaekjoon/Python

#1316 - python

HYEJU01 2024. 4. 20. 02:02
N = int(input())
cnt = N

for i in range(N):
    list = input()
    for j in range(0, len(list)-1):
        if list[j] == list[j+1]:
            pass
        elif list[j] in list[j+1:]:
            cnt -= 1
            break

print(cnt)

 

๐Ÿ’ฌ ์—ฐ์†๋œ ๋ฌธ์ž ํ™•์ธํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์•Œ์•„์•ผํ•จ.

    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            return True

์ˆœํšŒ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ len(s) - 1 

์•ž ๋’ค๋ฅผ ๋น„๊ตํ–ˆ์„๋•Œ ์ฐธ์ด๋ฉด ์—ฐ์†๋˜๋Š” ๋ฌธ์ž

 

 

๐Ÿ’ฌ  ๊ฐ’์ด ๋‹ค๋ฅผ ๊ฒฝ์šฐ ์ฒ˜๋ฆฌ ๋ฐฉ๋ฒ•

 0๋ฒˆ์งธ ๋ฌธ์ž๊ฐ€  ([0+1:] 1๋ฒˆ์งธ ~ 3๋ฒˆ์งธ ์ธ๋ฑ์Šค ๊นŒ์ง€ ๋น„๊ตํ•ด์„œ ) ๋’ค์ชฝ์— ๊ฐ’์ด ์žˆ๋Š”๊ฐ€?

True -> cnt -1  ( ๊ทธ๋ฃน ๋‹จ์–ด์—์„œ ์ œ์™ธ์‹œํ‚ค๊ธฐ) 

False -> ๋‹ค์‹œ for ๋ฌธ ๋Œ๋ฆฌ๊ธฐ

 

  • ๐Ÿ’ฌ value in collection  :: value: ๊ฒ€์‚ฌํ•  ๊ฐ’ / collection: ๊ฒ€์‚ฌํ•  ์ปฌ๋ ‰์…˜ (๋ฆฌ์ŠคํŠธ, ํŠœํ”Œ, ์ง‘ํ•ฉ, ๋ฌธ์ž์—ด ๋“ฑ)