[Baekjoon] 2920: ์๊ณ
โ๏ธ ๋ฌธ์ ๐๋งํฌ
๋ค์ฅ์กฐ๋ c d e f g a b C, ์ด 8๊ฐ ์์ผ๋ก ์ด๋ฃจ์ด์ ธ์๋ค. ์ด ๋ฌธ์ ์์ 8๊ฐ ์์ ๋ค์๊ณผ ๊ฐ์ด ์ซ์๋ก ๋ฐ๊พธ์ด ํํํ๋ค. c๋ 1๋ก, d๋ 2๋ก, โฆ, C๋ฅผ 8๋ก ๋ฐ๊พผ๋ค.
1๋ถํฐ 8๊น์ง ์ฐจ๋ก๋๋ก ์ฐ์ฃผํ๋ค๋ฉด ascending, 8๋ถํฐ 1๊น์ง ์ฐจ๋ก๋๋ก ์ฐ์ฃผํ๋ค๋ฉด descending, ๋ ๋ค ์๋๋ผ๋ฉด mixed ์ด๋ค.
์ฐ์ฃผํ ์์๊ฐ ์ฃผ์ด์ก์ ๋, ์ด๊ฒ์ด ascending์ธ์ง, descending์ธ์ง, ์๋๋ฉด mixed์ธ์ง ํ๋ณํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
โ๏ธ ์์ 1
์ ๋ ฅ
1 2 3 4 5 6 7 8
์ถ๋ ฅ
ascending
โ๏ธ ์์ 2
์ ๋ ฅ
8 7 6 5 4 3 2 1
์ถ๋ ฅ
descending
โ๏ธ ์์ 3
์ ๋ ฅ
8 1 7 2 6 3 5 4
์ถ๋ ฅ
mixed
โ๏ธ SOLUTION
๋ฌธ์ ์ ๊ทผ
- ๊ฐ์ ๋น๊ตํ asc, desc ๋ฆฌ์คํธ ์์ฑ
- desc ์ ๊ฒฝ์ฐ ๋ง๋ asc๋ฆฌ์คํธ๋ฅผ ์ญ์์ผ๋ก ์ ๊ฐํ์ฌ ์์ฑ
- if, elif, else๋ฌธ ์ฌ์ฉํ์ฌ ์ผ์ด์ค ๋ณ๋ก ์ถ๋ ฅ์ด ๋ค๋ฅด๊ฒ ๋๋๋ก ๊ตฌํ
test_lst = list(map(int, input().split()))
asc = [i for i in range(1, 9)]
desc = asc[::-1]
if test_lst == asc:
print('ascending')
elif test_lst == desc:
print('descending')
else:
print('mixed')
Leave a comment