Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# idea
.idea

# Logs
logs
*.log
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
language: node_js

install:
- nvm install stable
- npm install -g eslint-cli
Expand Down
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 |
| ------------- | ------------- | ------------- |
| Max Voloskiy | 8 | https://www.codewars.com/kata/count-of-positives-slash-sum-of-negatives |
| | 8 | https://www.codewars.com/kata/convert-a-string-to-a-number |
| | 7 | https://www.codewars.com/kata/slamming-lockers |
| | 6 | https://www.codewars.com/kata/help-the-bookseller |
| | 5 | https://www.codewars.com/kata/perimeter-of-squares-in-a-rectangle |
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
var requirejs = require('tasks/5_kyu');
require("amd-loader");

let fifth = require('./tasks/5_kyu');
console.log(fifth.perimeter(10));

let sixth = require('./tasks/6_kyu');
console.log(sixth.stockList(["CBART 20", "CDXEF 50", "BKWRK 25", "BTSQZ 89", "DRTYM 60"], ["A", "B", "C", "W"]));

let seventh = require('./tasks/7_kyu');
console.log(seventh.lockerRun(9));

let eighth = require('./tasks/8_kyu');
console.log(eighth.stringToNumber("123"));
console.log(eighth.countPositivesSumNegatives([-1, -2, -3, 1, 2, 3]));

3 changes: 3 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require("amd-loader");
var msg = require('./tasks/template');
console.log(msg.print("run!"));
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"main": "index.js",
"dependencies": {
"amd-loader": "0.0.8",
"requirejs": "^2.3.6"
},
"devDependencies": {
Expand Down
19 changes: 19 additions & 0 deletions tasks/5_kyu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
define(function () {
return {
perimeter: (n) => {
const fibonacci = (n) => {
let init = 1;
let res = 1;

for (let i = 0; i <= n; i++) {
let temp = res;
res += init;
init = temp;
}
return res - 1;
};

return 4 * fibonacci(n);
}
};
});
24 changes: 24 additions & 0 deletions tasks/6_kyu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
define(function () {
return {
stockList: (listOfArt, listOfCat) => {
if (!listOfArt.length || !listOfCat.length) {
return '';
}

let books = {};
let result = [];

listOfArt.forEach((book) => {
let [title, num] = book.split(" ");
books[title[0]] = books[title[0]] ? (books[title[0]] += Number(num)) : Number(num);
});

listOfCat.forEach((letter) => {
let num = books[letter] || 0;
result.push(`(${letter} : ${num})`);
});

return result.join` - `;
}
}
});
11 changes: 11 additions & 0 deletions tasks/7_kyu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define(function () {
return {
lockerRun: (lockers) => {
let open = [];
for (let i = 1; i * i <= lockers; i++) {
open.push(i * i);
}
return open;
}
}
});
23 changes: 23 additions & 0 deletions tasks/8_kyu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
define(function () {
return {
countPositivesSumNegatives: (input) => {
let positive = 0;
let negative = 0;

if (input === [] || input === null || input < 1)
return [];

for (let i=0; i<input.length; i++){
if (input[i] > 0){
positive += 1;
} else {
negative += input[i]
}
}
return [positive, negative]
},
stringToNumber: (n) => {
return Number(n);
}
}
});
7 changes: 7 additions & 0 deletions tasks/template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
define(function () {
return {
print: function(msg) {
return msg;
}
};
});