Skip to content

Commit 321cba7

Browse files
author
Eric
committed
93차 2번 문제풀이(망)
1 parent e42b0f8 commit 321cba7

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

live9/test93/문제2/황장현.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const alphabetValues = {
2+
B: 1,
3+
C: 2,
4+
D: 3,
5+
E: 4,
6+
F: 5,
7+
G: 6,
8+
H: 7,
9+
I: 8,
10+
J: 9,
11+
K: 10,
12+
L: 11,
13+
M: 13,
14+
N: 12,
15+
O: 12,
16+
P: 11,
17+
Q: 10,
18+
R: 9,
19+
S: 8,
20+
T: 7,
21+
U: 6,
22+
V: 5,
23+
W: 4,
24+
X: 3,
25+
Y: 2,
26+
Z: 1,
27+
};
28+
29+
function solution(name) {
30+
let answer = 0;
31+
for (let i = 0; i < name.length; i++) {
32+
if (name[i] === 'A') {
33+
answer += -1;
34+
} else {
35+
answer += alphabetValues[name[i]];
36+
}
37+
}
38+
answer += name.length;
39+
return answer;
40+
}
41+
42+
// console.log(solution('JEROEN'));
43+
// console.log(solution('JAAAN'));
44+
// console.log(solution('JAAAKAN'));
45+
console.log(solution('AAABAAAAB'));

0 commit comments

Comments
 (0)