Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions jiyeeeah/[week1]Array/array_length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function solution(strlist) {
const answer = [];
for (const str of strlist) {
answer.push(str.length);
}
return answer;
}
9 changes: 9 additions & 0 deletions jiyeeeah/[week1]Array/divided_number_array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function solution(arr, divisor) {
const answer = [];
for (const val of arr) {
if (val % divisor === 0) answer.push(val);
}
if (answer.length <= 0) answer.push(-1);
answer.sort((a, b) => a - b);
return answer;
}
3 changes: 3 additions & 0 deletions jiyeeeah/[week1]Array/number_of_duplicate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function solution(array, n) {
return array.filter((value) => value === n).length;
}
18 changes: 18 additions & 0 deletions jiyeeeah/[week1]Array/procession_multiply.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function solution(arr1, arr2) {
const r1 = arr1.length;
const c1 = arr1[0].length;
const r2 = arr2.length;
const c2 = arr2[0].length;
// c1 === r2임

const answer = new Array(r1).fill(0).map(() => new Array(c2).fill(0));

for (let i = 0; i < r1; i++) {
for (let j = 0; j < c2; j++) {
for (let k = 0; k < c1; k++) {
answer[i][j] += arr1[i][k] * arr2[k][j];
}
}
}
return answer;
}
11 changes: 11 additions & 0 deletions jiyeeeah/[week1]Array/procession_sum.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map을 사용해서 좀 더 간결하게 풀 수 있어요!

function solution(arr1, arr2) {
    return arr1.map((row, i) => row.map((val, j) => val + arr2[i][j]));
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇네요 ㅎㅎ 좋은 의견 감사합니다! 👍 😄

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function solution(arr1, arr2) {
const Xn = arr1.length;
const Yn = arr1[0].length;
const answer = new Array(Xn).fill(0).map(() => new Array(Yn).fill(0));
for (let i = 0; i < Xn; i++) {
for (let j = 0; j < Yn; j++) {
answer[i][j] = arr1[i][j] + arr2[i][j];
}
}
return answer;
}
9 changes: 9 additions & 0 deletions jiyeeeah/[week1]Array/remove_min_number.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정렬은 안해도 괜찮을것 같아요!!

const minNum = arr.sort((a, b) => a - b)[0];
answer.splice(answer.indexOf(minNum), 1);

이거는
answer.splice(answer.indexOf(Math.min(...arr)), 1)
이걸로 처리할수 있습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오 그렇네요!! 감사합니다 👍

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function solution(arr) {
const answer = [...arr];

const minNum = arr.sort((a, b) => a - b)[0];
answer.splice(answer.indexOf(minNum), 1);
if (answer.length <= 0) answer.push(-1);

return answer;
}
11 changes: 11 additions & 0 deletions jiyeeeah/[week1]Array/rotate_array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function solution(numbers, direction) {
const answer = [...numbers];
if (direction === "right") {
const temp = answer.pop();
answer.unshift(temp);
} else if (direction === "left") {
const temp = answer.shift();
answer.push(temp);
}
return answer;
}
4 changes: 4 additions & 0 deletions jiyeeeah/[week1]Array/trim_array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function solution(numbers, num1, num2) {
const answer = numbers;
return answer.slice(num1, num2 + 1);
}
24 changes: 24 additions & 0 deletions jiyeeeah/[week1]Array/배열.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
> 이번에는 문제를 풀며 몰랐거나 까먹었다가 이제 다시 알게 된 부분들 위주로 정리해봤습니다.

## 2차원 배열 만들기

```js
const arr = new Array(5).fill(0).map(() => new Array(4));
```

### 📄 REFERENCE

https://joonfluence.tistory.com/508

## 행렬의 곱셈

```js
const r1 = arr1.length;
const c1 = arr1[0].length;
const r2 = arr2.length;
const c2 = arr2[0].length;
// 여기서 c1 === r2이다.

// 결과 배열은 r1 * c2이다.
const answer = new Array(r1).fill(0).map(() => new Array(c2).fill(0));
```
Loading