diff --git a/.eslintrc.js b/.eslintrc.js index edadc67..fe152c8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,8 @@ module.exports = { "env": { "browser": true, - "es6": true + "es6": true, + "amd": true }, "extends": "eslint:recommended", "globals": { @@ -13,5 +14,6 @@ module.exports = { "sourceType": "module" }, "rules": { + } }; \ No newline at end of file diff --git a/README.md b/README.md index c6f66a5..b521fef 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,11 @@ Your Pages site will use the layout and styles from the Jekyll theme you have se ### Support or Contact Having trouble with Pages? Check out our [documentation](https://help.github.com/categories/github-pages-basics/) or [contact support](https://github.com/contact) and we’ll help you sort it out. + +| Name & Surname | kyu | Link | +| ------------- | ------------- | ------------- | +| Nadiia Chorna | 8 |https://www.codewars.com/kata/my-head-is-at-the-wrong-end | +| | 8 | https://www.codewars.com/kata/to-square-root-or-not-to-square-root | +| | 7 | https://www.codewars.com/kata/recursive-replication | +| | 6 | https://www.codewars.com/kata/ranking-nba-teams | +| | 5 | https://www.codewars.com/kata/number-of-trailing-zeros-of-n | diff --git a/main.js b/main.js index c4c03e6..2e91fe7 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,15 @@ require("amd-loader"); -var msg = require('./tasks/template'); -msg.print("run!"); +//var msg = require('./tasks/template'); +//msg.print("run!"); + +var kyu8 = require('./tasks/8_kyu'); +console.log(kyu8.fixTheMeerkat(['tail', 'body', 'head'])); +console.log(kyu8.squareOrSquareRoot([4, 3, 9, 7, 2, 1])); + +var kyu7 = require('./tasks/7_kyu'); +console.log(kyu7.replicate(3, 5)); + +//var kyu6=require('./tasks/6_kyu'); + +var kyu5 = require('./tasks/5_kyu'); +console.log(kyu5.zeros(6)); \ No newline at end of file diff --git a/package.json b/package.json index 085b793..a75234d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "codewarstasks", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "main.js", "dependencies": { "amd-loader": "0.0.8", "requirejs": "^2.3.6" diff --git a/tasks/5_kyu.js b/tasks/5_kyu.js index e69de29..fe31cad 100644 --- a/tasks/5_kyu.js +++ b/tasks/5_kyu.js @@ -0,0 +1,13 @@ +define(function() { + return { + zeros: function(n) { + var i = 1; + var result = 0; + while (n / Math.pow(5, i) > 1) { + result += Math.floor(n / Math.pow(5, i)); + i++; + } + return result; + } + } +}); diff --git a/tasks/6_kyu.js b/tasks/6_kyu.js index e69de29..bf423be 100644 --- a/tasks/6_kyu.js +++ b/tasks/6_kyu.js @@ -0,0 +1,30 @@ +define(function() { + return { + nba_cup: function(report, teamName) { + var w = 0; + var d = 0; + var l = 0; + var score = 0; + var conceded = 0; + let reg = new RegExp('\\b' + teamName + '\\b', 'ig'); + let games = report.split(',').filter((item) => { + return item.match(reg); + }).map((item) => { + return item.trim().split(/\s*(\d+\.?\d*\b)\s*/).slice(0, -1); + }); + if (games.length < 1) { + return `${teamName}:This team didn't play!` + } + let sortgames = games.map((arr) => { + return arr.indexOf(teamName) == 0 ? arr : arr = [arr[2], arr[3], arr[0], arr[1]]; + }); + sortgames.forEach((game) => { + +game[1] > +game[3] ? w += 1 : (+game[1] < +game[3] ? l += 1 : d += 1) + score += +game[1]; + conceded += +game[3]; + + }); + return `${teamName}:W=${w};D=${d};L=${l};Scored=${score};Conceded=${conceded};Points=${w*3+d}`; + } + } +}); diff --git a/tasks/7_kyu.js b/tasks/7_kyu.js index e69de29..b859e63 100644 --- a/tasks/7_kyu.js +++ b/tasks/7_kyu.js @@ -0,0 +1,7 @@ +define(function() { + return { + replicate: function replicate(times, number) { + return times > 0 ? [number].concat(replicate(times - 1, number)) : []; + } + } +}); diff --git a/tasks/8_kyu.js b/tasks/8_kyu.js index e69de29..2308517 100644 --- a/tasks/8_kyu.js +++ b/tasks/8_kyu.js @@ -0,0 +1,12 @@ +define(function() { + return { + squareOrSquareRoot: function(arr) { + return arr.map((el) => { + return Number.isInteger(Math.sqrt(el)) ? Math.sqrt(el) : Math.pow(el, 2); + }) + }, + fixTheMeerkat: function(arr) { + return arr.reverse(); + } + } +}); diff --git a/tasks/template.js b/tasks/template.js index 4d24ed8..40ea3dc 100644 --- a/tasks/template.js +++ b/tasks/template.js @@ -1,7 +1,7 @@ -define(function () { - return { - print: function(msg) { - console.log(msg); - } - }; -}); \ No newline at end of file +// define(function() { +// return { +// print: function(msg) { +// // console.log(msg); +// } +// }; +// }); \ No newline at end of file