Repository navigation
Expand file tree
/
Copy pathvalidate.js
More file actions
49 lines (39 loc) ยท 1.4 KB
/
Copy pathvalidate.js
File metadata and controls
49 lines (39 loc) ยท 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
switch(true){
case (process.argv.length < 4):
console.log(`node example/range 0 100 ๊ณผ ๊ฐ์ด ์ซ์๋ฒ์๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.`)
return
case (isNaN(process.argv[2])):
console.log(`์ฒซ๋ฒ์งธ ์ธ์๋ ์ซ์์ฌ์ผ ํฉ๋๋ค.`)
return
case (isNaN(process.argv[3])):
console.log(`๋๋ฒ์งธ ์ธ์๋ ์ซ์์ฌ์ผ ํฉ๋๋ค.`)
return
case (process.argv[2] > process.argv[3]):
console.log(`์ฒซ๋ฒ์งธ ์ธ์๋ ๋๋ฒ์งธ ์ธ์๋ณด๋ค ๊ฐ์ด ํด ์ ์์ต๋๋ค.`)
return
}
let stoppedPoint = null
let startPoint = process.argv[2]
let endPoint = process.argv[3]
/**
* ๋ฌด๊ถํ์ฝ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
*/
const mugunghwa = require('../mugunghwa.js')
// ํจ์์ฝ๋ ๋ก๋ฉ
mugunghwa.encode(1)
mugunghwa.decode(1)
console.time('๋ณํ์๋ชจ ์๊ฐ')
for(let i=startPoint;i<=endPoint;i++){
let encoded = mugunghwa.encode(i)
let decoded = mugunghwa.decode(encoded)
if(i%1000 == 0)console.log(`ํ์ฌ ${i}/${endPoint} ๊น์ง ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฌ๊ฐ ์ฑ๊ณตํ์ต๋๋ค`)
if(i != decoded){
stoppedPoint = i
break
}
}
if(stoppedPoint === null)
console.log(`${startPoint}~${endPoint} ๊น์ง์ ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฌ๊ฐ ์ฑ๊ณต์ ์ผ๋ก ๋๋ฌ์ต๋๋ค.`)
else
console.log(`${startPoint}~${endPoint} ๊น์ง์ ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฌ๊ฐ ์คํจํ์ต๋๋ค. ${stoppedPoint} ๋ฒ์งธ ๋ถ์ผ์น`)
console.timeEnd('๋ณํ์๋ชจ ์๊ฐ')