diff --git a/src/problem1.js b/src/problem1.js index 9a14f2c..3eeb061 100644 --- a/src/problem1.js +++ b/src/problem1.js @@ -1,6 +1,53 @@ function problem1(pobi, crong) { - var answer; - return answer; -} + let Add = 0; + let Mul = 1; + let pobi_max; + let crong_max; + + if(pobi[0]!==pobi[1]-1 || crong[0]!==crong[1]-1) + return -1; + + function name(arr){ + for (let i=0; i<2; i++ ){ + let Max = 0; + + let n=arr[i].toString(); + + for(let j of n){ + Add += Number(j); + Mul *= Number(j); + } + if(Add>Mul) + arr[i]=Add; + + else + arr[i]=Mul; + + Add = 0; + Mul = 1; + } + + if(arr[0]>arr[1]) + Max = arr[0]; + else + Max = arr[1]; + + return Max; + + } + + pobi_max = name(pobi); + crong_max = name(crong); + + if(pobi_max>crong_max) + return 1; + else if(crong_max>pobi_max) + return 2; + else if(crong_max==pobi_max) + return 0; + + +} + module.exports = problem1; diff --git a/src/problem2.js b/src/problem2.js index cebd07c..cba97a2 100644 --- a/src/problem2.js +++ b/src/problem2.js @@ -1,6 +1,29 @@ function problem2(cryptogram) { - var answer; - return answer; + + let arr = cryptogram.split(""); + var cnt; + + while(true){ + + let cnt = true; + + for(let i=0;i= 65 && ascii <= 90) { + arr[i] = String.fromCharCode(155 - ascii); + } else if (ascii >= 97 && ascii <= 122) { + arr[i] = String.fromCharCode(219 - ascii); + } +} + +let result = arr.join(''); +return result; + } module.exports = problem4; diff --git a/src/problem5.js b/src/problem5.js index 9368e87..1431094 100644 --- a/src/problem5.js +++ b/src/problem5.js @@ -1,6 +1,17 @@ function problem5(money) { - var answer; - return answer; + let arr = [50000, 10000, 5000, 1000, 500, 100, 50, 10, 1]; + let result = []; + + + + for(let i of arr){ + result.push(Math.floor(money/i)); + money = money % i; + + } + + return result; + } module.exports = problem5;