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..83f9be6 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,7 @@ -## 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 | +| ------------- | ------------- | ------------- | +| Ners Ruslan | 8 | https://www.codewars.com/kata/heads-and-legs | +| ^ | 8 | https://www.codewars.com/kata/short-long-short | +| ^ | 7 | https://www.codewars.com/kata/triple-shiftian-numbers | +| ^ | 6 | https://www.codewars.com/kata/bouncing-balls/ | +| ^ | 5 | https://www.codewars.com/kata/product-of-consecutive-fib-numbers/python | diff --git a/main.js b/main.js index c4c03e6..8889c2e 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,14 @@ require("amd-loader"); -var msg = require('./tasks/template'); -msg.print("run!"); + +const kyu_8 = require('./tasks/8_kyu'); +console.log(kyu_8.animals(12,24)); +console.log(kyu_8.solution('get', 'beer')); + +const kyu_7 = require('./tasks/7_kyu'); +console.log(kyu_7.tripleShiftian([1,1,1],24)); + +const kyu_6 = require('./tasks/6_kyu'); +console.log(kyu_6.bouncingBall(12, 0.66, 2)); + +const kyu_5 = require('./tasks/5_kyu'); +console.log(kyu_5.productFibonacci(65)); diff --git a/tasks/5_kyu.js b/tasks/5_kyu.js index e69de29..586ad77 100644 --- a/tasks/5_kyu.js +++ b/tasks/5_kyu.js @@ -0,0 +1,14 @@ +define(function () { + return { + productFibonacci: prod => { + let a = 0, b = 1, c = 1; + while((a * b) !== prod) { + if(a * b > prod) return [a, b, false]; + c = a + b; + a = b; + b = c; + } + return [a, b, true] + } + }; +}); diff --git a/tasks/6_kyu.js b/tasks/6_kyu.js index e69de29..c3d1c94 100644 --- a/tasks/6_kyu.js +++ b/tasks/6_kyu.js @@ -0,0 +1,15 @@ +define(function () { + return { + bouncingBall: (h, bounce, window) => { + if(h > 0 && bounce > 0 && bounce < 1) { + let count = 0; + while(h > window) { + h *= bounce; + count += 2; + } + return count - 1; + } + return -1; + } + }; +}); diff --git a/tasks/7_kyu.js b/tasks/7_kyu.js index e69de29..bd6312e 100644 --- a/tasks/7_kyu.js +++ b/tasks/7_kyu.js @@ -0,0 +1,13 @@ +define(function () { + return { + tripleShiftian: (base,n) => { + if(n < 3) return base[n]; + else { + for(let i = 3; i <= n; i++) + base.push(4 * base[i - 1] - 5 * base[i - 2] + 3 * base[i - 3]); + + return base[n]; + } + } + }; +}); diff --git a/tasks/8_kyu.js b/tasks/8_kyu.js index e69de29..0bcb40b 100644 --- a/tasks/8_kyu.js +++ b/tasks/8_kyu.js @@ -0,0 +1,11 @@ +define(function () { + return { + animals: (heads, legs) => { + const cows = (legs - heads * 2) / 2 ; + const chickens = heads - cows; + if( cows > heads || (cows ^ 0) !== cows || chickens > heads || (chickens ^ 0) !== chickens ) return "No solutions"; + else return [chickens, cows]; + }, + solution: (a , b) => a.length > b.length ? b + a + b : a + b + a + }; +}); diff --git a/tasks/template.js b/tasks/template.js deleted file mode 100644 index 4d24ed8..0000000 --- a/tasks/template.js +++ /dev/null @@ -1,7 +0,0 @@ -define(function () { - return { - print: function(msg) { - console.log(msg); - } - }; -}); \ No newline at end of file