File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 77
77
78
78
### 2022년 02월
79
79
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.) | - | - | - |
87
87
88
88
<!-- ### 2022년 00월
89
89
You can’t perform that action at this time.
0 commit comments