[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] 2016๋…„ /ํŒŒ์ด์ฌ /Python
Algorithm/Programmers

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] 2016๋…„ /ํŒŒ์ด์ฌ /Python

728x90
๋ฐ˜์‘ํ˜•

๐Ÿ’กsolutions )

โœ… ๋‹ฌ๋งˆ๋‹ค ๋ฉฐ์น ์ธ์ง€ ๋ฆฌ์ŠคํŠธ์— ๋„ฃ์–ด์ฃผ๊ธฐ

โœ… ์ „์ฒด ์ผ์ˆ˜๋ฅผ ํ•ฉ์‚ฐํ•˜๊ณ  7๋กœ ๋‚˜๋ˆˆ๋’ค -1 (๊ธˆ์š”์ผ์ด 1์ด๋‹ˆ๊นŒ)

 

๐ŸŽซcode )

def solution(a, b):
    month = [31,29,31,30,31,30,31,31,30,31,30,31]
    weekday = ["FRI","SAT","SUN","MON","TUE","WED","THU"]
    day = sum(month[:a-1]) + b if a > 1 else b
    answer = weekday[day % 7-1]
    return answer

 

๐Ÿ“Œ description )

๋ฌธ์ œ์ถœ์ฒ˜ : https://programmers.co.kr/learn/courses/30/lessons/12901?language=python3

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - 2016๋…„

2016๋…„ 1์›” 1์ผ์€ ๊ธˆ์š”์ผ์ž…๋‹ˆ๋‹ค. 2016๋…„ a์›” b์ผ์€ ๋ฌด์Šจ ์š”์ผ์ผ๊นŒ์š”? ๋‘ ์ˆ˜ a ,b๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ 2016๋…„ a์›” b์ผ์ด ๋ฌด์Šจ ์š”์ผ์ธ์ง€ ๋ฆฌํ„ดํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•˜์„ธ์š”. ์š”์ผ์˜ ์ด๋ฆ„์€ ์ผ์š”์ผ๋ถ€ํ„ฐ ํ† ์š”์ผ๊นŒ๏ฟฝ๏ฟฝ

programmers.co.kr

 

๋ฌธ์ œ ์„ค๋ช…

2016๋…„ 1์›” 1์ผ์€ ๊ธˆ์š”์ผ์ž…๋‹ˆ๋‹ค. 2016๋…„ a์›” b์ผ์€ ๋ฌด์Šจ ์š”์ผ์ผ๊นŒ์š”? ๋‘ ์ˆ˜ a ,b๋ฅผ ์ž…๋ ฅ๋ฐ›์•„ 2016๋…„ a์›” b์ผ์ด ๋ฌด์Šจ ์š”์ผ์ธ์ง€ ๋ฆฌํ„ดํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•˜์„ธ์š”. ์š”์ผ์˜ ์ด๋ฆ„์€ ์ผ์š”์ผ๋ถ€ํ„ฐ ํ† ์š”์ผ๊นŒ์ง€ ๊ฐ๊ฐ SUN,MON,TUE,WED,THU,FRI,SAT

์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด a=5, b=24๋ผ๋ฉด 5์›” 24์ผ์€ ํ™”์š”์ผ์ด๋ฏ€๋กœ ๋ฌธ์ž์—ด TUE๋ฅผ ๋ฐ˜ํ™˜ํ•˜์„ธ์š”.

์ œํ•œ ์กฐ๊ฑด

  • 2016๋…„์€ ์œค๋…„์ž…๋‹ˆ๋‹ค.
  • 2016๋…„ a์›” b์ผ์€ ์‹ค์ œ๋กœ ์žˆ๋Š” ๋‚ ์ž…๋‹ˆ๋‹ค. (13์›” 26์ผ์ด๋‚˜ 2์›” 45์ผ๊ฐ™์€ ๋‚ ์งœ๋Š” ์ฃผ์–ด์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค)

์ž…์ถœ๋ ฅ ์˜ˆ

ab                                                                      result
5 24
๋ฐ˜์‘ํ˜•