Skip to content

Commit ccd8e8b

Browse files
BurhanHAlexDvorakwinsonrichms10398AkarshSatija
authored
Fetching last changes (#1)
* added DecimalToHex * added luhn's checksum algorithm * deleted checksums * Update keyFinder.js modified used the suitable identifier for the variables * Update keyFinder.js 1. modified the identifiers and used the suitable identifiers for the variables 2. leave the loop when a key is match and found to increase the speed of searching in this stage of development 3. return the key number if founded, return 0 if found nothing * Update keyFinder.js a sub-function is used to assist the keyfinder to find the key * Update keyFinder.js Finally, there are several changes in the function keyFinder(str) that make it works well * Update keyFinder.js Add some key words to the wordbank to increase the chance of the matching. * fixed and added test cases * fixed alert * Add wiggle sort * adding Graph data structure * Added SHA-1 and SHA-256 hashing algorithms (TheAlgorithms#83) * Added SHA-1 and SHA-256 hashing algorithms * Fixed typos in comments * Removed redundant unsigned integer casting * Added Jump Search to readme.md * Added JumpSearch algorithm * Update jumpSearch.js * Added Semicolon to Avoid Auto Semicolon Insertion This fixes a [recommendation on lgtm](https://lgtm.com/projects/g/TheAlgorithms/Javascript/snapshot/9fe2ca0492e0813c5e5486498c6b53a00c4a61e3/files/Sorts/bucketSort.js?sort=name&dir=ASC&mode=heatmap) * Fixed Whitespace, Operators, and Quotes to Comply with JSLint I modified the whitespace in the files and changed single quotes to double quotes. I also changed some `==` and `!=` operators to `===` and `!==` to comply with JSLint. * Create find_lcm.js - Created find_lcm.js - Created maths folder * Create average_mean.js * Create factorial.js This program calculates and displays the factorial for a user-input number. * Create abs.js This script calculates absolute value. * Made "use strict" Global * Made "use strict" Global & Made JSLint Happy * Kadane Algo is added * Issue fixed * GitHub Action to test Javascript * Update nodejs.yml * cd linear-algebra-javascript * Create update_directory_md.yml * updating DIRECTORY.md * update_directory_md.yml: Remove GH Actions workaround * Graph Theory * Delete Graphs * Graph * Dijkstra Smallest Path * DijkstraSmallestPath after fixing some errors. * Topological Sort directed graphs * correcting name of file * updating DIRECTORY.md * doublylinkedlist * add-doublylinkedlist * add-doublylinkedlist * change in Directory.md * updating DIRECTORY.md * update (#1) * Graph Theory * Delete Graphs * Graph * Dijkstra Smallest Path * DijkstraSmallestPath after fixing some errors. * Topological Sort directed graphs * correcting name of file * updating DIRECTORY.md * doublylinkedlist * add-doublylinkedlist * add-doublylinkedlist * change in Directory.md * updating DIRECTORY.md Co-authored-by: Nur69 <[email protected]> Co-authored-by: Stepfen Shawn <[email protected]> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: hmizz <[email protected]> * Contributing guidelines * npx standard --fix * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Update CONTRIBUTING.md Co-authored-by: Christian Clauss <[email protected]> * Add standard to our testing Run in allow failures mode until the non-compliant files are fixed. * npx standard || true * Update README.md * Fixing non compliant files (Ciphers, Conversions and Data Structures) * Update nodejs.yml * Data Structures/Graph * sorts/ * fix broken link * search/ * search/ (TheAlgorithms#143) * factorial.js: Standardjs fixes Related to TheAlgorithms#139 * /* global alert, prompt */ * find_lcm.js: Standardjs fixes * abs.js: abs_val() --> absVal() for standardjs (TheAlgorithms#144) * find_lcm.js: Standardjs fixes (TheAlgorithms#146) * Update factorial.js * SHA256.js: Standardjs fixes * factorial.js: /* global prompt */ * Update nodejs.yml * DijkstraSmallestPath.js: Standardjs fixes (TheAlgorithms#147) * Fixed typo in CONTRIBUTING.md file (TheAlgorithms#148) * Fixed typo in CONTRIBUTING.md file * Update CONTRIBUTING.md Co-authored-by: vinayak <[email protected]> * math/ * sort/ * Add Pascal's triangle. (TheAlgorithms#149) * Add Pascal's triangle. * Update pascalTriangle.js * Update pascalTriangle.js Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * Javascript/linear-algebra-javascript * Update nodejs.yml * Update nodejs.yml * Update nodejs.yml * Trailing space ;-) * Update README.md * adding an implementation of a queue using 2 stacks (TheAlgorithms#137) * adding an implementation of a queue using 2 stacks * Update QueueUsing2Stacks.js Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * Create palindrome algorithm (TheAlgorithms#134) * Create palindrome algorithm * Update Palindrome.js Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * Create pull_request_template.md (TheAlgorithms#153) * Create pull_request_template.md * Update pull_request_template.md * Update pull_request_template.md * Update pull_request_template.md * Update pull_request_template.md * Update README.md * Update CONTRIBUTING.md * added hcf finding algorithm (TheAlgorithms#104) * added hcf finding algorith * Update and rename find_hcf.js to FindHcf.js Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * Create Fibonacci.js (TheAlgorithms#133) * Create Fibonacci.js * Update Fibonacci.js Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * Javascript/Math: editing file name * updating DIRECTORY.md * Update nodejs.yml * Update README.md * editing file names * updating DIRECTORY.md * Quick Select Search (TheAlgorithms#131) * HeapSort algorithm * Create QuickSelect.js * Algorithm to reverse a string. * Update ReverseString.js * Update Heapsort.js * Update QuickSelect.js Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * Update README.md * Max heap implementation (TheAlgorithms#157) * Added MaxHeap implementation * Added MaxHeap implementation * Added MaxHeap implementation * Added MaxHeap implementation * Delete package-lock.json * Delete .gitignore * updating DIRECTORY.md * Renaming files according to naming convention (TheAlgorithms#158) * updating DIRECTORY.md * Fibonacci without recursion added (TheAlgorithms#159) * changes made * Update Fibonacci.js * fib Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * format files * updating DIRECTORY.md * Add good_filepaths function in workflow script * updating DIRECTORY.md * Add md_prefix and print_path functions * Add reverse words (TheAlgorithms#162) * add reverse words * Update ReverseWords.js * Update ReverseWords.js Co-authored-by: vinayak <[email protected]> * updating DIRECTORY.md * Add build_directory_md * GitHub Action nodejs.yml upgrade to Node.js 14 (TheAlgorithms#165) * JavaScript, not Javascript (TheAlgorithms#166) * Rename script.js to UpdateDirectory.js * updating DIRECTORY.md * run: node UpdateDirectory.js * run: node .github/workflows/UpdateDirectory.js * updating DIRECTORY.md * BogoSort.js: Simplify Array.isSorted() and add doctests As discussed at TheAlgorithms#164 (comment) Also related to add doctests as discussed in TheAlgorithms#142 * node -e "doctest('Sorts/BogoSort.js', {})" * doctest --module Sorts Sorts/BogoSort.js * Update nodejs.yml * Update nodejs.yml * npx doctest Sorts/BogoSort.js || true * node_modules/doctest Sorts/BogoSort.js || true * npx doctest Sorts/BogoSort.js * updating DIRECTORY.md * Ensure that build fail on bad test * updating DIRECTORY.md * Ready for review * Add doctest to BucketSort.js * updating DIRECTORY.md * Update nodejs.yml * updating DIRECTORY.md * npx doctest Sorts/BogoSort.js Sorts/BucketSort.js * updating DIRECTORY.md * updating DIRECTORY.md * Add Graph BFS algorithm (TheAlgorithms#169) * Add Graph BFS algorithm * updating DIRECTORY.md * Fix failing tests * updating DIRECTORY.md * Fix further failing tests Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> * updating DIRECTORY.md * Re-orgainze files and folders in the repository (TheAlgorithms#172) * Re-orgainze files and folders in the repository * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Alex Brown <[email protected]> Co-authored-by: Wan Cheuk Lun <[email protected]> Co-authored-by: Mohit Sharma <[email protected]> Co-authored-by: Akarsh <[email protected]> Co-authored-by: naor <[email protected]> Co-authored-by: Anup Kumar Panwar <[email protected]> Co-authored-by: Ravi Patel <[email protected]> Co-authored-by: mavroian <[email protected]> Co-authored-by: Libin Yang <[email protected]> Co-authored-by: PatOnTheBack <[email protected]> Co-authored-by: lakshyabatman <[email protected]> Co-authored-by: Christian Clauss <[email protected]> Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: Nur69 <[email protected]> Co-authored-by: Stepfen Shawn <[email protected]> Co-authored-by: hmizz <[email protected]> Co-authored-by: vinayak <[email protected]> Co-authored-by: Juliano Nunes <[email protected]> Co-authored-by: Muhammad Awais <[email protected]> Co-authored-by: Nour B <[email protected]> Co-authored-by: hmizz <[email protected]> Co-authored-by: Novojit Saha <[email protected]> Co-authored-by: Samarth Jain <[email protected]> Co-authored-by: Satzyakiz <[email protected]> Co-authored-by: Sahil Bansal <[email protected]> Co-authored-by: Abhi Ramani <[email protected]> Co-authored-by: John Law <[email protected]>
1 parent 9cabd46 commit ccd8e8b

File tree

95 files changed

+4211
-2593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+4211
-2593
lines changed

.github/pull_request_template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Welcome to JavaScript community
2+
3+
### **Describe your change:**
4+
5+
* [ ] Add an algorithm?
6+
* [ ] Fix a bug or typo in an existing algorithm?
7+
* [ ] Documentation change?
8+
9+
10+
### **Checklist:**
11+
* [ ] I have read [CONTRIBUTING.md](https://github.com/TheAlgorithms/Javascript/blob/master/CONTRIBUTING.md).
12+
* [ ] This pull request is all my own work -- I have not plagiarized.
13+
* [ ] I know that pull requests will not be merged if they fail the automated tests.
14+
* [ ] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
15+
* [ ] All new JavaScript files are placed inside an existing directory.
16+
* [ ] All filenames should use the UpperCamelCase (PascalCase) style. There should be no spaces in filenames.
17+
**Example:**`UserProfile.js` is allowed but `userprofile.js`,`Userprofile.js`,`user-Profile.js`,`userProfile.js` are not
18+
* [ ] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
19+
* [ ] If this pull request resolves one or more open issues then the commit message contains `Fixes: #{$ISSUE_NO}`.

.github/workflows/UpdateDirectory.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
// requiring path and fs modules
2+
const path = require('path');
3+
const fs = require('fs');
4+
5+
let URL_BASE = "https://github.com/TheAlgorithms/Javascript/blob/master";
6+
let g_output = [];
7+
8+
let filepaths = [];
9+
function good_filepaths(top_dir = ".") {
10+
fs.readdir(top_dir, function(err, list) {
11+
if (err) {
12+
console.log(err);
13+
return;
14+
}
15+
list.forEach(function(file) {
16+
let path = top_dir + "/" + file;
17+
if (!file.startsWith(".")) {
18+
fs.stat(path, function(err, stat) {
19+
if (stat && stat.isDirectory()) {
20+
good_filepaths(path);
21+
} else {
22+
if (file.toLowerCase().endsWith(".js")) {
23+
filepaths.push(path.slice(2));
24+
}
25+
}
26+
});
27+
}
28+
});
29+
})
30+
}
31+
32+
function md_prefix(i) {
33+
if (i) {
34+
let res = ' '.repeat(i);
35+
return res + "*";
36+
} else {
37+
return "\n##"
38+
}
39+
}
40+
41+
function print_path(old_path, new_path) {
42+
let old_parts = old_path.split(path.sep);
43+
let new_parts = new_path.split(path.sep);
44+
for (let i = 0; i < new_parts.length; ++i) {
45+
let new_part = new_parts[i];
46+
if (i + 1 > old_parts.len || old_parts[i] != new_part) {
47+
if (new_part) {
48+
g_output.push(`${md_prefix(i)} ${new_part.replace('_', ' ')}`);
49+
}
50+
}
51+
}
52+
return new_path;
53+
}
54+
55+
function build_directory_md(top_dir = ".") {
56+
old_path = "";
57+
filepaths.sort(function(a, b) {
58+
if (a.toLowerCase() < b.toLowerCase()) return -1;
59+
if (a.toLowerCase() > b.toLowerCase()) return 1;
60+
return 0;
61+
});
62+
for (let filepath of filepaths) {
63+
file = filepath.split(path.sep);
64+
if (file.length == 1) {
65+
filepath = "";
66+
filename = file[0];
67+
} else {
68+
let total = file.length;
69+
filename = file[total - 1];
70+
filepath = file.splice(0, total - 1).join(path.sep);
71+
}
72+
if (filepath != old_path) {
73+
old_path = print_path(old_path, filepath);
74+
}
75+
let indent = 0;
76+
for (let i = 0; i < filepath.length; ++i) {
77+
if (filepath[i] == path.sep) {
78+
++indent;
79+
}
80+
}
81+
if (filepath) {
82+
++indent;
83+
}
84+
let urls = [URL_BASE, filepath, filename];
85+
let url = urls.join("/").replace(" ", "%20");
86+
// remove extension from filename
87+
filename = filename.split(".")[0];
88+
g_output.push(`${md_prefix(indent)} [${filename}](${url})`);
89+
}
90+
g_output = g_output.join('\n');
91+
return g_output;
92+
}
93+
94+
good_filepaths();
95+
setTimeout(() => {
96+
// once the filepaths have been computed
97+
build_directory_md();
98+
// console.log(filepaths);
99+
}, 1000);
100+
setTimeout(() => {
101+
// once the g_output has been constructed, write to the file
102+
fs.writeFile('DIRECTORY.md', g_output + '\n', (err) => {
103+
if (err) {
104+
console.log(err);
105+
}
106+
})
107+
// console.log(g_output);
108+
}, 1000);

.github/workflows/nodejs.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Node CI
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
node-version: [14.x]
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Use Node.js ${{ matrix.node-version }}
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: ${{ matrix.node-version }}
15+
- name: npm install, build, and test
16+
run: |
17+
npm install doctest standard --save-dev
18+
npx doctest Sorts/BogoSort.js Sorts/BucketSort.js
19+
npx standard
20+
cd Linear-Algebra
21+
npm ci
22+
npm run build --if-present
23+
npm test
24+
env:
25+
CI: true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push
2+
name: update_directory_md
3+
on: [push]
4+
jobs:
5+
update_directory_md:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@master
9+
- uses: actions/setup-node@v1
10+
- run: |
11+
node .github/workflows/UpdateDirectory.js
12+
cat DIRECTORY.md
13+
git config --global user.name github-actions
14+
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
15+
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
16+
git add DIRECTORY.md
17+
git commit -am "updating DIRECTORY.md" || true
18+
git push --force origin HEAD:$GITHUB_REF || true

Algorithms/EucledianGCD.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

Algorithms/dynamic_programming/fibonacci.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

Algorithms/sieveOfEratosthenes.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Contributing guidelines
2+
3+
## Before contributing
4+
5+
Welcome to [TheAlgorithms/Javascript](https://github.com/TheAlgorithms/Javascript)! Before sending your pull requests, make sure that you **read the whole guidelines**. If you have any doubt on the contributing guide, please feel free to [state it clearly in an issue](https://github.com/TheAlgorithms/Javascript/issues/new)
6+
7+
## Contributing
8+
9+
### Contributor
10+
11+
We are very happy that you consider implementing algorithms and data structures for others! This repository is referenced and used by learners from around the globe. Being one of our contributors, you agree and confirm that:
12+
13+
- You did your work - plagiarism is not allowed.
14+
- Any plagiarized work will not be merged.
15+
- Your work will be distributed under [GNU License](LICENSE) once your pull request is merged
16+
- Your submitted work must fulfill our styles and standards
17+
18+
**New implementation** is welcome! For example, new solutions to a problem, different representations of a graph data structure or algorithm designs with different complexity.
19+
20+
**Improving comments** and **writing proper tests** are also highly welcome.
21+
22+
### Contribution
23+
24+
We appreciate any contribution, from fixing grammar mistakes to implementing complex algorithms. Please read this section if you are contributing to your work.
25+
26+
27+
If you submit a pull request that resolves an open issue, please help us to keep our issue list small by adding `fixes: #{$ISSUE_NO}` to your commit message. GitHub will use this tag to auto-close the issue if your PR is merged.
28+
29+
#### What is an Algorithm?
30+
31+
An Algorithm is one or more functions (or classes) that:
32+
* take one or more inputs,
33+
* perform some internal calculations or data manipulations,
34+
* return one or more outputs,
35+
* have minimal side effects.
36+
37+
Algorithms should be packaged in a way that would make it easy for readers to put them into larger programs.
38+
39+
Algorithms should:
40+
* have intuitive class and function names that make their purpose clear to readers
41+
* use JavaScript naming conventions and intuitive variable names to ease comprehension
42+
* be flexible to take different input values
43+
* raise JavaScript exceptions (RangeError, etc.) on erroneous input values
44+
45+
Algorithms in this repo should not be how-to examples for existing JavaScript packages. Instead, they should perform internal calculations or manipulations to convert input values into different output values. Those calculations or manipulations can use data types, classes, or functions of existing JavaScript packages but each algorithm in this repo should add unique value.
46+
47+
#### File Naming Convention
48+
- filenames should use the UpperCamelCase (PascalCase) style.
49+
- There should be no spaces in filenames.
50+
**Example:**`UserProfile.js` is allowed but `userprofile.js`,`Userprofile.js`,`user-Profile.js`,`userProfile.js` are not
51+
52+
#### Coding Style
53+
54+
To maximize the readability and correctness of our code, we require that new submissions follow [JavaScript Standard Style](https://standardjs.com/)
55+
- Command to install JavaScript Standard Style
56+
```
57+
$ npm install standard --save-dev
58+
```
59+
- Usage
60+
```
61+
$ standard MyFile.js // if that fails, try: npx standard MyFile.js
62+
```
63+
64+
- Use camelCase for with leading character lowercase for identifier names (variables and functions)
65+
- Names start with a letter
66+
- follow code indentation
67+
- Always use 2 spaces for indentation of code blocks
68+
```
69+
function sumOfArray (arrayOfNumbers) {
70+
let sum = 0
71+
for (let i = 0; i < arrayOfNumbers.length; i++) {
72+
sum += arrayOfNumbers[i]
73+
}
74+
return (sum)
75+
}
76+
77+
```
78+
- Avoid using global variables and avoid '=='
79+
- Please use 'let' over 'var'
80+
- Please use 'console.log()'
81+
- We strongly recommend the use of ECMAScript 6
82+
- Avoid importing external libraries for basic algorithms. Only use those libraries for complicated algorithms.
83+
84+
85+
86+
- Most importantly,
87+
- **Be consistent in the use of these guidelines when submitting.**
88+
- Happy coding!
89+
90+
Writer [@itsvinayak](https://github.com/itsvinayak), May 2020.

0 commit comments

Comments
 (0)