Skip to content

Commit dbab056

Browse files
committed
알고리즘 풀이 업데이트
1 parent 7b46827 commit dbab056

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.

3.가위바위보.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<html>
2+
<head>
3+
<meta charset="UTF-8" />
4+
<title>출력결과</title>
5+
</head>
6+
<body>
7+
<script>
8+
function solution(a, b) {
9+
let answer = "";
10+
11+
a.forEach((ele, index) => {
12+
if (a[index] === b[index]) {
13+
answer = answer + "D ";
14+
}
15+
if (a[index] === 1 && b[index] === 2) {
16+
answer = answer + "B ";
17+
}
18+
if (a[index] === 1 && b[index] === 3) {
19+
answer = answer + "A ";
20+
}
21+
if (a[index] === 2 && b[index] === 1) {
22+
answer = answer + "A ";
23+
}
24+
if (a[index] === 2 && b[index] === 3) {
25+
answer = answer + "B ";
26+
}
27+
if (a[index] === 3 && b[index] === 1) {
28+
answer = answer + "B ";
29+
}
30+
if (a[index] === 3 && b[index] === 2) {
31+
answer = answer + " A";
32+
}
33+
});
34+
35+
return answer;
36+
}
37+
38+
let a = [2, 3, 3, 1, 3];
39+
let b = [1, 1, 2, 2, 3];
40+
console.log(solution(a, b));
41+
</script>
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)