diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/1.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/1.js" new file mode 100644 index 00000000..5f6fed9b --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/1.js" @@ -0,0 +1,8 @@ +function solution(s) { + if (s.length !== 4 && s.length !== 6) + return false; + for (let i = 0; i < s.length; i++) { + if (isNaN(Number(s[i]))) return false; + } + return true; + } \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/2.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/2.js" new file mode 100644 index 00000000..2e34740f --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/2.js" @@ -0,0 +1,7 @@ +function solution(left, right) { + let answer = 0; + + for(let i = left; i <= right; i++){ + Math.sqrt(i) % 1 === 0 ? answer += i : answer -= i; + } return -answer +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/3.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/3.js" new file mode 100644 index 00000000..44698723 --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/3.js" @@ -0,0 +1,8 @@ +function solution(price, money, count) { + let total = 0; + + for(let i = 0; i <= count; i++){ + total += price * i + } + return total > money ? total - money : 0; +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/4.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/4.js" new file mode 100644 index 00000000..b3d708e3 --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/4.js" @@ -0,0 +1,10 @@ +function solution(arr1, arr2) { + let answer = []; + for(let i = 0; i < arr1.length; i++){ + answer[i] = []; + for(let j = 0; j < arr1[i].length; j++){ + answer[i].push(arr1[i][j] + arr2[i][j]) + } + } + return answer; +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/5.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/5.js" new file mode 100644 index 00000000..f8d779bb --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/5.js" @@ -0,0 +1,9 @@ +process.stdin.setEncoding('utf8'); +process.stdin.on('data', data => { + const n = data.split(" "); + const a = Number(n[0]), b = Number(n[1]); + // console.log(a); + // console.log(b); + const answer = ('*'.repeat(a)+`\n`).repeat(b) + console.log(answer) +}); \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/6.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/6.js" new file mode 100644 index 00000000..147a7241 --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week05/6.js" @@ -0,0 +1,10 @@ +function solution(n, m) { + let answer = []; + + const gcd = (n, m) => { + if( m === 0) return n + return gcd(m, n % m) + } + const lcm = (n, m) => n * m / gcd(n,m) + return [gcd(n,m), lcm(n,m)] +} \ No newline at end of file