Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 52454a9

Browse files
solution add - 로또의-최고-순위와-최저-순위
1 parent 1a15697 commit 52454a9

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

‎level-1/로또의-최고-순위와-최저-순위.js‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,33 @@ function solution(lottos, win_nums) {
8080
if (min == 7) min = 6
8181
answer = [min, max]
8282
return answer;
83-
}
83+
}
84+
85+
//정답 5 - yongchanson
86+
function solution(lottos, win_nums) {
87+
//최고당첨개수 : maxPoint + basicPoint
88+
//최저당첨개수 : basicPoint
89+
90+
let basicPoint = 0;
91+
let maxPoint = 0;
92+
let answer = [];
93+
94+
lottos.forEach(function (lottos_item) {
95+
win_nums.forEach(function (win_nums_item) {
96+
if(lottos_item==win_nums_item) {
97+
basicPoint++;
98+
}
99+
})
100+
})
101+
102+
lottos.forEach(function (item) {
103+
if(item==0) {
104+
maxPoint++;
105+
}
106+
})
107+
108+
maxPoint+basicPoint >= 2 ? answer.push(7- maxPoint - basicPoint) : answer.push(6);
109+
basicPoint >= 2 ? answer.push(7- basicPoint) : answer.push(6);
110+
111+
return answer;
112+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /