File tree 3 files changed +30
-15
lines changed
3 files changed +30
-15
lines changed Original file line number Diff line number Diff line change 1
- 5 2
2
- 100 76 85 93 98
1
+ 5 2
2
+ 100 76 85 93 98
Original file line number Diff line number Diff line change 1
- let path = require ( 'path' ) ;
2
- let inputPath = path . join ( __dirname , '/dev/stdin' ) ; // __dirname์ ํ์ฌ ์คํฌ๋ฆฝํธ์ ๋๋ ํ ๋ฆฌ ์ ๋๊ฒฝ๋ก
3
- let input = require ( 'fs' ) . readFileSync ( inputPath ) . toString ( ) . trim ( ) . split ( '\r\n' ) ;
1
+ let path = require ( "path" ) ;
2
+ let inputPath = path . join ( __dirname , "/dev/stdin" ) ; // __dirname์ ํ์ฌ ์คํฌ๋ฆฝํธ์ ๋๋ ํ ๋ฆฌ ์ ๋๊ฒฝ๋ก
3
+ let input = require ( "fs" )
4
+ . readFileSync ( inputPath )
5
+ . toString ( )
6
+ . trim ( )
7
+ . split ( "\r\n" ) ;
4
8
//let input = require('fs').readFileSync('/dev/stdin').toString().trim().split('\n'); //๋ฐฑ์ค ์ ์ถ
5
- let arr = input . map ( el => el . split ( ' ' ) ) ;
6
- let N = arr [ 0 ] [ 0 ] - 1 ;
7
- let X = arr [ 0 ] [ 1 ] - 1 ;
8
- let score = arr [ 1 ] ;
9
- console . log ( N , X ) ;
10
- score . sort ( ( b , a ) => a - b ) ;
11
- console . log ( score [ X ] ) ;
9
+
10
+ // ์
๋ ฅ๋ ์ซ์๋ค์ ๊ณฑํ ๊ฒฐ๊ณผ ๊ณ์ฐ
11
+ let sum = 1 ;
12
+ input . forEach ( ( el ) => {
13
+ sum *= Number ( el ) ;
14
+ } ) ;
15
+
16
+ // ๊ฒฐ๊ณผ๋ฅผ ๋ฌธ์์ด๋ก ๋ณํํ์ฌ ๊ฐ ์๋ฆฟ์๋ฅผ ๋ฐฐ์ด๋ก ๋ถ๋ฆฌ
17
+ let array = String ( sum ) . split ( "" ) ;
18
+
19
+ // 0๋ถํฐ 9๊น์ง ์ซ์์ ๋น๋๋ฅผ ์ ์ฅํ ๋ฐฐ์ด
20
+ let result = new Array ( 10 ) . fill ( 0 ) ;
21
+
22
+ // ๊ฐ ์๋ฆฟ์๋ฅผ ์นด์ดํธ
23
+ array . forEach ( ( el ) => {
24
+ result [ Number ( el ) ] += 1 ;
25
+ } ) ;
26
+
27
+ // ๊ฒฐ๊ณผ ์ถ๋ ฅ
28
+ result . forEach ( ( el ) => console . log ( el ) ) ;
Original file line number Diff line number Diff line change 1
- const test = require ( './test/stack ' ) ;
1
+ const test = require ( './test/test ' ) ;
2
2
const boolean = require ( './test/boolean' ) ;
3
- const newArray_insert = require ( './test/newArray_insert' ) ;
4
- const newArray_push = require ( './test/newArray_push' ) ;
You canโt perform that action at this time.
0 commit comments