Skip to content

Commit 69f7d84

Browse files
committed
Solve : Drawing Book
1 parent 8121215 commit 69f7d84

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

Easy/DrawingBook.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Solution 1
2+
function pageCount(n, p) {
3+
const book = [];
4+
const pages = Array.from({ length: n + 1 }, (_, index) => index);
5+
6+
for (let i = 0; i < pages.length; i += 2) {
7+
book.push(pages.slice(i, i + 2));
8+
}
9+
10+
const totalPageCount = book.length;
11+
const targetPageIndex = book.findIndex((page) => page.includes(p));
12+
13+
return Math.min(targetPageIndex, totalPageCount - targetPageIndex - 1);
14+
}

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@
7777

7878
### 2022년 02월
7979

80-
| 주차 | 난이도 | 문제 | JS 풀이 코드 |
81-
| :--------------------------: | :-------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
82-
| 1주차<br />(02.01. ~ 02.06.) | `Easy`<br />`Easy`<br />`Level 2`<br />`Easy`<br />`Easy` | [Halloween Sale](https://www.hackerrank.com/challenges/halloween-sale/problem?isFullScreen=true)<br />[Picking Numbers](https://www.hackerrank.com/challenges/picking-numbers/problem?isFullScreen=true)<br />[순위 검색](https://programmers.co.kr/learn/courses/30/lessons/72412)<br />[Viral Advertising](https://www.hackerrank.com/challenges/strange-advertising/problem?isFullScreen=true)<br />[Migratory Birds](https://www.hackerrank.com/challenges/migratory-birds/problem?isFullScreen=true) | [JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/HalloweenSale.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/PickingNumbers.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Level2/순위검색.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/ViralAdvertising.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/MigratoryBirds.js) |
83-
| 3주차<br />(02.07. ~ 02.13.) | - | - | - |
84-
| 4주차<br />(02.14. ~ 02.20.) | - | - | - |
85-
| 5주차<br />(02.21. ~ 02.27.) | - | - | - |
86-
| 5주차<br />(02.28.) | - | - | - |
80+
| 주차 | 난이도 | 문제 | JS 풀이 코드 |
81+
| :--------------------------: | :-------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
82+
| 1주차<br />(02.01. ~ 02.06.) | `Easy`<br />`Easy`<br />`Level 2`<br />`Easy`<br />`Easy`<br />`Easy` | [Halloween Sale](https://www.hackerrank.com/challenges/halloween-sale/problem?isFullScreen=true)<br />[Picking Numbers](https://www.hackerrank.com/challenges/picking-numbers/problem?isFullScreen=true)<br />[순위 검색](https://programmers.co.kr/learn/courses/30/lessons/72412)<br />[Viral Advertising](https://www.hackerrank.com/challenges/strange-advertising/problem?isFullScreen=true)<br />[Migratory Birds](https://www.hackerrank.com/challenges/migratory-birds/problem?isFullScreen=true)<br />[Drawing Book](https://www.hackerrank.com/challenges/drawing-book/problem?isFullScreen=true) | [JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/HalloweenSale.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/PickingNumbers.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Level2/순위검색.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/ViralAdvertising.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/MigratoryBirds.js)<br />[JS](https://github.com/JeongHwan-dev/programmers-solving-with-js/blob/master/Easy/DrawingBook.js) |
83+
| 3주차<br />(02.07. ~ 02.13.) | - | - | - |
84+
| 4주차<br />(02.14. ~ 02.20.) | - | - | - |
85+
| 5주차<br />(02.21. ~ 02.27.) | - | - | - |
86+
| 5주차<br />(02.28.) | - | - | - |
8787

8888
<!-- ### 2022년 00월
8989

0 commit comments

Comments
 (0)