Skip to content

Commit

Permalink
#12 24.03.08 > 테이블 해시 함수
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Mar 8, 2024
1 parent af9a2fb commit cdadfb5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/programmers/Lv_2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
| 85 | [요격 시스템](./system.js) | 23.11.15 | X | [23.12.07](./replay/system.js) |
| 86 | [미로 탈출](./miro.js) | 23.12.08 | X |
| 87 | [우박수열 정적분](./math.js) | 23.12.14 | X | [23.12.18](./replay/math.js) |
| 88 | [더 맵게](./spicy.js) | 23.12.22 | X |[24.03.07](./replay/spicy.js)
| 88 | [더 맵게](./spicy.js) | 23.12.22 | X | [24.03.07](./replay/spicy.js) |
| 89 | [이모티콘 할인 행사](./emoji.js) | 23.12.31 | X |
| 90 | [숫자 블록](./numsBlock.js) | 24.01.01 | X |
| 91 | [택배 배달과 수거하기](./deliveryPick.js) | 24.01.02 | X |
Expand All @@ -102,3 +102,4 @@
| 98 | [당구 연습](./billiard.js) | 24.01.26 | X |
| 99 | [순위 검색](./search.js) | 24.01.27 | X |
| 100 | [혼자서 하는 틱택토](./alone.js) | 24.02.07 | X |
| 101 | [테이블 해시 함수](./tableHash.js) | 24.03.08 | X |
18 changes: 18 additions & 0 deletions src/programmers/Lv_2/tableHash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function solution(data, col, row_begin, row_end) {
var answer = "";
data.sort((a, b) => {
if (a[col - 1] !== b[col - 1]) {
return a[col - 1] - b[col - 1];
}
if (a[0] !== b[0]) {
return b[0] - a[0];
}
});

for (let i = row_begin - 1; i <= row_end - 1; i++) {
const res = data[i].reduce((acc, val) => acc + (val % (i + 1)), 0);
answer = answer !== "" ? answer ^ res : answer;
}

return answer;
}

0 comments on commit cdadfb5

Please sign in to comment.