File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ const input = require ( 'fs' )
2+ . readFileSync ( process . platform === 'linux' ? '/dev/stdin' : './input.txt' )
3+ . toString ( )
4+ . trim ( )
5+ . split ( '\n' )
6+ . map ( ( el ) => el . split ( ' ' ) . map ( Number ) ) ;
7+
8+ function solution ( input ) {
9+ const [ E , S , M ] = input [ 0 ] ;
10+ let year = 1 ;
11+
12+ while ( true ) {
13+ if (
14+ ( year - E ) % 15 === 0 &&
15+ ( year - S ) % 28 === 0 &&
16+ ( year - M ) % 19 === 0
17+ ) {
18+ return year ;
19+ }
20+ year ++ ;
21+ }
22+ }
23+
24+ console . log ( solution ( input ) ) ;
Original file line number Diff line number Diff line change 1+ const input = require ( 'fs' )
2+ . readFileSync ( process . platform === 'linux' ? '/dev/stdin' : './input.txt' )
3+ . toString ( )
4+ . trim ( )
5+ . split ( '\n' )
6+ . map ( ( el ) => el . split ( ' ' ) . map ( Number ) ) ;
7+
8+ function solution ( input ) {
9+ let [ N , KIM , IM ] = input [ 0 ] ;
10+ let answer = 0 ;
11+ while ( KIM !== IM ) {
12+ KIM = Math . ceil ( KIM / 2 ) ;
13+ IM = Math . ceil ( IM / 2 ) ;
14+ answer ++ ;
15+ }
16+ return answer ;
17+ }
18+
19+ console . log ( solution ( input ) ) ;
Original file line number Diff line number Diff line change 1+ function solution ( s ) {
2+ const words = s . split ( ' ' ) ;
3+
4+ for ( let i = 0 ; i < words . length ; i ++ ) {
5+ let lowerWord = words [ i ] . toLowerCase ( ) ;
6+ if ( / [ a - z ] / . test ( lowerWord [ 0 ] ) ) {
7+ lowerWord = lowerWord . replace ( / ^ [ a - z ] / , ( match ) => match . toUpperCase ( ) ) ;
8+ }
9+ words [ i ] = lowerWord ;
10+ }
11+ return words . join ( ' ' ) ;
12+ }
13+
14+ console . log ( solution ( '3people unFollowed me' ) ) ;
You can’t perform that action at this time.
0 commit comments