Skip to content
Open
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
"env": {
"browser": true,
"es6": true
"es6": true,
"amd":true
},
"extends": "eslint:recommended",
"globals": {
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ typings/

# next.js build output
.next

.idea
44 changes: 7 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 |
19 changes: 17 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -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'));
6 changes: 6 additions & 0 deletions tasks/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tasks/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tasks/.idea/tasks.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions tasks/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions tasks/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions tasks/5_kyu.js
Original file line number Diff line number Diff line change
@@ -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('');
}
}
});



16 changes: 16 additions & 0 deletions tasks/6_kyu.js
Original file line number Diff line number Diff line change
@@ -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;
}
}
});


14 changes: 14 additions & 0 deletions tasks/7_kyu.js
Original file line number Diff line number Diff line change
@@ -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));
}

}

});

17 changes: 17 additions & 0 deletions tasks/8_kyu.js
Original file line number Diff line number Diff line change
@@ -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)
}
}


});




14 changes: 7 additions & 7 deletions tasks/template.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function () {
return {
print: function(msg) {
console.log(msg);
}
};
});
// define(function () {
// return {
// print: function(msg) {
// console.log(msg);
// }
// };
// });