diff --git a/.eslintrc.js b/.eslintrc.js index edadc67..580e0ec 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/.gitignore b/.gitignore index 9972163..1fbc290 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,5 @@ typings/ # next.js build output .next + +.idea \ No newline at end of file diff --git a/README.md b/README.md index c6f66a5..a617241 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 | +| ------------- | ------------- | ------------- | +| Ostap Dutkevych | 8 |https://www.codewars.com/kata/holiday-viii-duty-free | +| | 8 | https://www.codewars.com/kata/simple-validation-of-a-username-with-regex | +| | 7 | https://www.codewars.com/kata/easy-line | +| | 6 | https://www.codewars.com/kata/floating-point-approximation-ii | +| | 5 | https://www.codewars.com/kata/first-variation-on-caesar-cipher | diff --git a/main.js b/main.js index c4c03e6..d34395d 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,18 @@ require("amd-loader"); -var msg = require('./tasks/template'); -msg.print("run!"); +// var msg = require('./tasks/template'); +// msg.print("run!"); + +var kuy_5 = require("./tasks/5_kyu"); +console.log(kuy_5.movingShift(1)); +console.log(kuy_5.demovingShift(1)); + +var kuy_6 = require("./tasks/6_kyu"); +console.log(kuy_6.interp(x => x, 0, 9.0, 4)); + +var kuy_7 = require("./tasks/7_kyu"); +console.log(kuy_7.easyLine(7)); + +var kuy_8 = require("./tasks/8_kyu"); +console.log(kuy_8.dutyFree(12, 50, 1000)); + +console.log(kuy_8.validateUsr('asdad')); \ No newline at end of file diff --git a/tasks/.idea/misc.xml b/tasks/.idea/misc.xml new file mode 100644 index 0000000..28a804d --- /dev/null +++ b/tasks/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/tasks/.idea/modules.xml b/tasks/.idea/modules.xml new file mode 100644 index 0000000..14a22b9 --- /dev/null +++ b/tasks/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tasks/.idea/tasks.iml b/tasks/.idea/tasks.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/tasks/.idea/tasks.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/tasks/.idea/vcs.xml b/tasks/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/tasks/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tasks/.idea/workspace.xml b/tasks/.idea/workspace.xml new file mode 100644 index 0000000..316b5d6 --- /dev/null +++ b/tasks/.idea/workspace.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1558017472157 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tasks/5_kyu.js b/tasks/5_kyu.js index e69de29..54b92a0 100644 --- a/tasks/5_kyu.js +++ b/tasks/5_kyu.js @@ -0,0 +1,61 @@ + + + +var abcLowerCase ='abcdefghijklmnopqrstuvwxyz'.split(''); +var abcUpperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); + +define(function () { + return { + movingShift: function (shift) { + let s = "I should have known that you would have a perfect answer for me!!!"; + + let abcLowerCase ='abcdefghijklmnopqrstuvwxyz'.split(''); + let abcUpperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); + + let arr = s.split('').map(function(v){ + + if (shift >= 26){ shift = shift - 26;} + let key = abcLowerCase.indexOf(v.toLowerCase()) + shift; + if (key >= 26){ key = key - 26;} + + if (abcLowerCase.indexOf(v) >= 0){ v = abcLowerCase[key];} + if (abcUpperCase.indexOf(v) >= 0){ v = abcUpperCase[key];} + + shift = shift + 1; + return v; + + + }).join(''); + + let splitArr = []; + + for (let i = 0 ; i < 5 ; i++){ + splitArr.push(arr.slice(i * Math.ceil(s.length / 5), (i+1) * Math.ceil(s.length / 5))); + } + return splitArr; + }, + + demovingShift: function (shift) { + let arr = ["J vltasl rlhr ", "zdfog odxr ypw", " atasl rlhr p ", "gwkzzyq zntyhv", " lvz wp!!!"]; + return arr.join('').split('').map(function(v){ + + if (shift >= 26){ shift = shift - 26;} + + let key = abcLowerCase.indexOf(v.toLowerCase()) - shift; + if (key < 0){ key = key + 26;} + + + if (abcLowerCase.indexOf(v) >= 0){ v = abcLowerCase[key];} + if (abcUpperCase.indexOf(v) >= 0){ v = abcUpperCase[key];} + + shift = shift + 1; + return v; + + + }).join(''); + } + } +}); + + + diff --git a/tasks/6_kyu.js b/tasks/6_kyu.js index e69de29..7e549b1 100644 --- a/tasks/6_kyu.js +++ b/tasks/6_kyu.js @@ -0,0 +1,16 @@ +define(function () { + return { + interp: function (f, l, u, n) { + let arr = []; + let d = (u - l) / n; + for(let i =0;i < n;i++){ + arr.push(Math.floor(f(l)* 100)/100); + l = d + l; + + } + return arr; + } + } +}); + + diff --git a/tasks/7_kyu.js b/tasks/7_kyu.js index e69de29..c6e810c 100644 --- a/tasks/7_kyu.js +++ b/tasks/7_kyu.js @@ -0,0 +1,14 @@ +define(function () { + return { + easyLine:function easyLine(n) { + let sum = 1; + for (let i = 1; i <= n; i++){ + sum = sum * (n + i) / i; + } + return Math.round(Math.log(sum)); + } + + } + +}); + diff --git a/tasks/8_kyu.js b/tasks/8_kyu.js index e69de29..0f7990f 100644 --- a/tasks/8_kyu.js +++ b/tasks/8_kyu.js @@ -0,0 +1,17 @@ +define(function () { + return{ + dutyFree: function(normPrice, discount, hol){ + let saving = normPrice * discount / 100; + return Math.floor(hol / saving); + }, + validateUsr: function(username) { + return /^[0-9a-z_]{4,16}$/.test(username) + } + } + + +}); + + + + diff --git a/tasks/template.js b/tasks/template.js index 4d24ed8..683e4e8 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