File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed
Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ function solution ( hp ) {
2+ const general = 5 ;
3+ const soldier = 3 ;
4+ const worker = 1 ;
5+
6+ const generalCount = Math . floor ( hp / general ) ;
7+ const soldierCount = Math . floor ( ( hp % general ) / soldier ) ;
8+ const workerCount = ( ( hp % general ) % soldier ) / worker ;
9+
10+ return generalCount + soldierCount + workerCount ;
11+ }
Original file line number Diff line number Diff line change 1+ function solution ( price ) {
2+ if ( price >= 500000 ) {
3+ return Math . floor ( price * 0.8 ) ;
4+ } else if ( price >= 300000 ) {
5+ return Math . floor ( price * 0.9 ) ;
6+ } else if ( price >= 100000 ) {
7+ return Math . floor ( price * 0.95 ) ;
8+ } else {
9+ return price ;
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ function solution ( array ) {
2+ array . sort ( ( a , b ) => a - b ) ;
3+ const mid = Math . floor ( array . length / 2 ) ;
4+ return array [ mid ] ;
5+ }
Original file line number Diff line number Diff line change 1+ function solution ( n ) {
2+ const result = [ ] ;
3+ for ( let i = 1 ; i <= n ; i ++ ) {
4+ if ( i % 2 !== 0 ) result . push ( i ) ;
5+ }
6+ return result ;
7+ }
You can’t perform that action at this time.
0 commit comments