-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolve #137-luck-balance 문제풀이 및 문서추가 #138
base: master
Are you sure you want to change the base?
Conversation
return (a[1] > b[1]) ? 1 : -1; | ||
}); | ||
|
||
let numImportant = length - [...sorted].findIndex(x => x[1] === 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[...sorted]
를 사용하는 이유가 있나요 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findIndex를 쓰려고 사용했습니다
const loseImportant = [...sorted].slice(length - numImportant, length - numImportant + limit); | ||
const winImportant = [...sorted].slice(length - numImportant + limit); | ||
|
||
const sumLuck = (unImportant.reduce((sum, [luck]) => sum + luck, 0) || 0) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(sum, [luck]) => sum + luck
반복되는 부분은 함수로 빼는것이 좋을것 같습니다.
return (a[1] > b[1]) ? 1 : -1; | ||
}); | ||
|
||
let numImportant = length - [...sorted].findIndex(x => x[1] === 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numImportant 아래의 unImportant, loseImportant, winImportant 와 이름 형식이 같은데
아랫것들은 배열이고 numImportant 는 number 로 보입니다.
배열의 경우 s 복수형을 쓰는것이 좋을것 같습니다.
let numImportant = length - [...sorted].findIndex(x => x[1] === 1); | ||
numImportant = (numImportant > length) ? 0 : numImportant; | ||
|
||
const unImportant = [...sorted].slice(0, length - numImportant); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
length - numImportant 반복되서 사용되는 부분은 상수로 선언하는게 좋을것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
No description provided.