ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

728x90
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

 

๋ฌธ์ œ ํ’€์ด

 ํ–‰์—ด์˜ ๊ฐ€๋กœ ์„ธ๋กœ์˜ ๋ฌธ์ž์—ด์„ ์ž…๋ ฅ๋œ ๊ธธ์ด๋งŒํผ split ํ•˜์—ฌ ํšŒ๋ฌธ์ด ๋˜๋Š”์ง€ ํ™•์ธํ•˜๊ณ  ๊ฐ€๋Šฅํ•œ ๊ฒฝ์šฐ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค. ํšŒ๋ฌธ์ด ๋˜๊ธฐ ์œ„ํ•ด์„œ๋Š” `string == string[::-1]`์„ ๋งŒ์กฑํ•˜๋ฉด ๋œ๋‹ค. ์„ธ๋กœ ํƒ์ƒ‰์„ ์‰ฝ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด ์•ž์„œ ๋‹ค๋ฃฌ Sum ๋ฌธ์ œ์™€ ๊ฐ™์ด ํ–‰์—ด์„ ์ „์น˜ํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋‹ค.

 

์ฝ”๋“œ

for test_case in range(1, 11):
    answer = 0
    length = int(input())
    array = [list(input().strip()) for _ in range(8)]
    trans_array = list(map(list, zip(*array)))

    for i in range(8):
        for j in range(9 - length):
            garo = array[i][j:j + length]
            sero = trans_array[i][j:j + length]

            if garo == garo[::-1]:
                answer += 1

            if sero == sero[::-1]:
                answer += 1

    print('#' + str(test_case), answer)

 

728x90
๋ฐ˜์‘ํ˜•

'๐Ÿ‘จโ€๐Ÿ’ป ์ฝ”๋”ฉํ…Œ์ŠคํŠธ > SWEA' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

SWEA: 1221 GNS  (0) 2020.10.07
SWEA: 1220 Magnetic  (0) 2020.10.07
SWEA: 1209 Sum  (0) 2020.10.07
SWEA: 1208 Flatten  (0) 2020.10.07
SWEA: 1206 View  (0) 2020.10.07
๋Œ“๊ธ€
๊ธ€ ๋ณด๊ด€ํ•จ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€