From 43e7483701be01198b60d6283810a6a79d89424c Mon Sep 17 00:00:00 2001 From: Red Fox Date: Thu, 16 May 2019 14:08:08 +0300 Subject: [PATCH 1/2] added kuy tasks --- .eslintrc.js | 3 ++- README.md | 43 +++++++------------------------------------ index.js | 10 +++++++++- tasks/6_kyu.js | 14 ++++++++++++++ tasks/7_kyu.js | 17 +++++++++++++++++ tasks/8_kyu.js | 19 +++++++++++++++++++ tasks/template.js | 8 +------- 7 files changed, 69 insertions(+), 45 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index edadc67..d969a52 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": { diff --git a/README.md b/README.md index c6f66a5..f711aa5 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,8 @@ -## Welcome to GitHub Pages -You can use the [editor on GitHub](https://github.com/lv-411-nodejs/codeWarsTasks/edit/master/README.md) to maintain and preview the content for your website in Markdown files. - -Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. - -### Markdown - -Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for - -```markdown -Syntax highlighted code block - -# Header 1 -## Header 2 -### Header 3 - -- Bulleted -- List - -1. Numbered -2. List - -**Bold** and _Italic_ and `Code` text - -[Link](url) and ![Image](src) -``` - -For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/). - -### Jekyll Themes - -Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/lv-411-nodejs/codeWarsTasks/settings). The name of this theme is saved in the Jekyll `_config.yml` configuration file. - -### 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 | +| ------------- | ------------- | ------------- | +| Bohdan Pidluzhnyy | 8 | https://www.codewars.com/kata/find-numbers-which-are-divisible-by-given-number | +| ^ | 8 | https://www.codewars.com/kata/geometry-basics-circle-area-in-2d | +| ^ | 7 | https://www.codewars.com/kata/sum-of-the-first-nth-term-of-series | +| ^ | 6 | https://www.codewars.com/kata/build-a-pile-of-cubes | +| ^ | 5 | https://www.codewars.com/kata/which-x-for-that-sum | diff --git a/index.js b/index.js index 4835cad..eb1774b 100644 --- a/index.js +++ b/index.js @@ -1 +1,9 @@ -var requirejs = require('tasks/5_kyu'); \ No newline at end of file +//const level5 = require('tasks/5_kyu'); +const level6 = require('./tasks/6_kyu'); +const level7 = require('./tasks/7_kyu'); +const level8 = require('./tasks/8_kyu'); + +console.log(level6.findNb(2)); +console.log(level7.seriesSum(2)); +console.log(level8.circleArea({radius: 4})); +console.log(level8.divisibleBy([1,2,3,4,5,6], 2)); diff --git a/tasks/6_kyu.js b/tasks/6_kyu.js index e69de29..5ba48e2 100644 --- a/tasks/6_kyu.js +++ b/tasks/6_kyu.js @@ -0,0 +1,14 @@ + +define(function() { + return { + findNb: (m) => { + var x = 0; + while (m > 0) { + x += 1; + m = m - x ** 3; + } + + return m ? -1 : x; + } + } +}) diff --git a/tasks/7_kyu.js b/tasks/7_kyu.js index e69de29..53c477f 100644 --- a/tasks/7_kyu.js +++ b/tasks/7_kyu.js @@ -0,0 +1,17 @@ + +define(function() { + return { + seriesSum: (n) => { + if(n == 0 || !n) return "0.00"; + + let sum = 1, next = 4; + + for(let i = 1; i < n; i++) { + sum += 1 / next; + next += 3; + } + + return sum.toFixed(2).toString(); + } + } +}); diff --git a/tasks/8_kyu.js b/tasks/8_kyu.js index e69de29..8cab112 100644 --- a/tasks/8_kyu.js +++ b/tasks/8_kyu.js @@ -0,0 +1,19 @@ + +define(function() { + return { + divisibleBy: (numbers, divisor) => { + numbers = numbers || [0]; + divisor = divisor || 1; + + let divisible = []; + numbers.map((value) => { + if(value % divisor === 0) + divisible.push(value) + }) + + return divisible; + }, + + circleArea: (circle) => circle.radius**2 * Math.PI + } +}) diff --git a/tasks/template.js b/tasks/template.js index 4d24ed8..8b13789 100644 --- a/tasks/template.js +++ b/tasks/template.js @@ -1,7 +1 @@ -define(function () { - return { - print: function(msg) { - console.log(msg); - } - }; -}); \ No newline at end of file + From 85a9a1f5e99a688ddfc9d2d660f1a4ded7016f73 Mon Sep 17 00:00:00 2001 From: Red Fox Date: Tue, 4 Jun 2019 10:13:33 +0300 Subject: [PATCH 2/2] update redme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f711aa5..687b015 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,4 @@ | ^ | 8 | https://www.codewars.com/kata/geometry-basics-circle-area-in-2d | | ^ | 7 | https://www.codewars.com/kata/sum-of-the-first-nth-term-of-series | | ^ | 6 | https://www.codewars.com/kata/build-a-pile-of-cubes | -| ^ | 5 | https://www.codewars.com/kata/which-x-for-that-sum | +| ^ | 5 | https://www.codewars.com/kata/weight-for-weight |