Skip to content

Commit

Permalink
[프로그래머스 - Lv. 1] 2016년 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 16, 2024
2 parents a64f7df + bff8d37 commit ad6c6b9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bangdori/2016년.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
WEEKS = 7;

months = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
daysOfWeek = ["THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED"];

function solution(a, b) {
const numberOfDate = calculateNumberOfDate(a, b);
const answer = daysOfWeek[numberOfDate % WEEKS];

return answer;
}

function calculateNumberOfDate(month, day) {
return months.slice(0, month - 1).reduce((acc, curr) => acc + curr, day);
}

0 comments on commit ad6c6b9

Please sign in to comment.