GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — npx standard --fix · Algorithms-Learn/JavaScript@856dc2f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Algorithms
    • EucledianGCD.js
    • KadaneAlgo.js
    • dynamic_programming
      • fibonacci.js
    • sieveOfEratosthenes.js
  • Ciphers
    • caesarsCipher.js
    • keyFinder.js
    • vigenereCipher.js
  • Conversions
    • DecimalToBinary.js
    • DecimalToHex.js
    • DecimalToOctal.js
  • Data Structures
    • Graph
      • Graph.js
    • Heap
      • MinPriorityQueue.js
    • Linked List
      • DoublyLinkedList.js
      • singlylinklist.js
    • Queue
      • Queue.js
    • Stack
      • Stack.js
    • Tree
      • Binary Search Tree.js
  • Hashes
    • SHA1.js
    • SHA256.js
  • Search
    • binarySearch.js
    • jumpSearch.js
    • linearSearch.js
  • Sorts
    • TopologicalSort.js
    • bogoSort.js
    • bucketSort.js
    • cocktailShakerSort.js
    • combSort.js
    • countingSort.js
    • cycleSort.js
    • flashSort.js
    • gnomeSort.js
    • heapSort.js
    • insertionSort.js
    • mergeSort.js
    • quickSort.js
    • radixSort.js
    • selectionSort.js
    • shellSort.js
    • wiggleSort.js
  • linear-algebra-javascript
    • src
      • la_lib.js
    • test
      • test.js
  • maths
    • DijkstraSmallestPath.js
    • abs.js
    • average_mean.js
    • factorial.js
    • find_lcm.js
    • graph.js

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Algorithms/EucledianGCD.js‎

Copy file name to clipboard
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
function euclideanGCDRecursive(first, second) {
2-
/*
1+
function euclideanGCDRecursive (first, second) {
2+
/*
33
Calculates GCD of two numbers using Euclidean Recursive Algorithm
44
:param first: First number
55
:param second: Second number
66
:return: GCD of the numbers
77
*/
8-
if (second === 0) {
9-
return first;
10-
} else {
11-
return euclideanGCDRecursive(second, (first % second));
12-
}
8+
if (second === 0) {
9+
return first
10+
} else {
11+
return euclideanGCDRecursive(second, (first % second))
12+
}
1313
}
1414

15-
function euclideanGCDIterative(first, second) {
16-
/*
15+
function euclideanGCDIterative (first, second) {
16+
/*
1717
Calculates GCD of two numbers using Euclidean Iterative Algorithm
1818
:param first: First number
1919
:param second: Second number
2020
:return: GCD of the numbers
2121
*/
22-
while (second !== 0) {
23-
let temp = second;
24-
second = first % second;
25-
first = temp;
26-
}
27-
return first;
22+
while (second !== 0) {
23+
const temp = second
24+
second = first % second
25+
first = temp
26+
}
27+
return first
2828
}
2929

30-
function main() {
31-
let first = 20;
32-
let second = 30;
33-
console.log('Recursive GCD for %d and %d is %d', first, second, euclideanGCDRecursive(first, second));
34-
console.log('Iterative GCD for %d and %d is %d', first, second, euclideanGCDIterative(first, second));
30+
function main () {
31+
const first = 20
32+
const second = 30
33+
console.log('Recursive GCD for %d and %d is %d', first, second, euclideanGCDRecursive(first, second))
34+
console.log('Iterative GCD for %d and %d is %d', first, second, euclideanGCDIterative(first, second))
3535
}
3636

37-
main();
37+
main()
Collapse file

‎Algorithms/KadaneAlgo.js‎

Copy file name to clipboard
+17-17Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
function KadaneAlgo (array) {
2-
let cummulativeSum = 0
3-
let maxSum = 0
4-
for (var i = 0; i < array.length; i++) {
5-
cummulativeSum = cummulativeSum + array[i]
6-
if(cummulativeSum < 0 ) {
7-
cummulativeSum = 0
8-
}
9-
if (maxSum < cummulativeSum) {
10-
maxSum = cummulativeSum
11-
}
2+
let cummulativeSum = 0
3+
let maxSum = 0
4+
for (var i = 0; i < array.length; i++) {
5+
cummulativeSum = cummulativeSum + array[i]
6+
if (cummulativeSum < 0) {
7+
cummulativeSum = 0
128
}
13-
return maxSum
14-
// This function returns largest sum contigous sum in a array
9+
if (maxSum < cummulativeSum) {
10+
maxSum = cummulativeSum
11+
}
12+
}
13+
return maxSum
14+
// This function returns largest sum contigous sum in a array
1515
}
16-
function main() {
17-
var myArray = [1,2,3,4,-6]
18-
var result = KadaneAlgo(myArray)
19-
console.log(result)
16+
function main () {
17+
var myArray = [1, 2, 3, 4, -6]
18+
var result = KadaneAlgo(myArray)
19+
console.log(result)
2020
}
21-
main()
21+
main()
Collapse file

‎Algorithms/dynamic_programming/fibonacci.js‎

Copy file name to clipboardExpand all lines: Algorithms/dynamic_programming/fibonacci.js
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
// of the input value n, it is exponential in the size of n as
99
// a function of the number of input bits
1010

11-
function fib(n) {
12-
var table = [];
13-
table.push(1);
14-
table.push(1);
15-
for (var i = 2; i < n; ++i) {
16-
table.push(table[i - 1] + table[i - 2]);
17-
}
18-
console.log("Fibonacci #%d = %d", n, table[n - 1]);
11+
function fib (n) {
12+
var table = []
13+
table.push(1)
14+
table.push(1)
15+
for (var i = 2; i < n; ++i) {
16+
table.push(table[i - 1] + table[i - 2])
17+
}
18+
console.log('Fibonacci #%d = %d', n, table[n - 1])
1919
}
2020

21-
fib(1);
22-
fib(2);
23-
fib(200);
24-
fib(5);
25-
fib(10);
21+
fib(1)
22+
fib(2)
23+
fib(200)
24+
fib(5)
25+
fib(10)
Collapse file

‎Algorithms/sieveOfEratosthenes.js‎

Copy file name to clipboard
+21-21Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
function sieveOfEratosthenes(n) {
2-
/*
1+
function sieveOfEratosthenes (n) {
2+
/*
33
* Calculates prime numbers till a number n
44
* :param n: Number upto which to calculate primes
55
* :return: A boolean list contaning only primes
66
*/
7-
let primes = new Array(n + 1);
8-
primes.fill(true); // set all as true initially
9-
primes[0] = primes[1] = false; // Handling case for 0 and 1
10-
let sqrtn = Math.ceil(Math.sqrt(n));
11-
for (let i = 2; i <= sqrtn; i++) {
12-
if (primes[i]) {
13-
for (let j = 2 * i; j <= n; j += i) {
14-
primes[j] = false;
15-
}
16-
}
7+
const primes = new Array(n + 1)
8+
primes.fill(true) // set all as true initially
9+
primes[0] = primes[1] = false // Handling case for 0 and 1
10+
const sqrtn = Math.ceil(Math.sqrt(n))
11+
for (let i = 2; i <= sqrtn; i++) {
12+
if (primes[i]) {
13+
for (let j = 2 * i; j <= n; j += i) {
14+
primes[j] = false
15+
}
1716
}
18-
return primes;
17+
}
18+
return primes
1919
}
2020

21-
function main() {
22-
let n = 69; // number till where we wish to find primes
23-
let primes = sieveOfEratosthenes(n);
24-
for (let i = 2; i <= n; i++) {
25-
if (primes[i]) {
26-
console.log(i);
27-
}
21+
function main () {
22+
const n = 69 // number till where we wish to find primes
23+
const primes = sieveOfEratosthenes(n)
24+
for (let i = 2; i <= n; i++) {
25+
if (primes[i]) {
26+
console.log(i)
2827
}
28+
}
2929
}
3030

31-
main();
31+
main()
Collapse file

‎Ciphers/caesarsCipher.js‎

Copy file name to clipboardExpand all lines: Ciphers/caesarsCipher.js
+16-18Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,26 @@
1111
* @param {String} str - string to be decrypted
1212
* @return {String} decrypted string
1313
*/
14-
function rot13(str) {
15-
let response = [];
16-
let strLength = str.length;
14+
function rot13 (str) {
15+
const response = []
16+
const strLength = str.length
1717

18-
for (let i = 0; i < strLength; i++) {
19-
const char = str.charCodeAt(i);
20-
21-
if (char < 65 || (char > 90 && char < 97) || char > 122) {
22-
response.push(str.charAt(i));
23-
} else if ((char > 77 && char <= 90) || (char > 109 && char <= 122)) {
24-
response.push(String.fromCharCode(str.charCodeAt(i) - 13));
25-
} else {
26-
response.push(String.fromCharCode(str.charCodeAt(i) + 13));
27-
}
18+
for (let i = 0; i < strLength; i++) {
19+
const char = str.charCodeAt(i)
2820

21+
if (char < 65 || (char > 90 && char < 97) || char > 122) {
22+
response.push(str.charAt(i))
23+
} else if ((char > 77 && char <= 90) || (char > 109 && char <= 122)) {
24+
response.push(String.fromCharCode(str.charCodeAt(i) - 13))
25+
} else {
26+
response.push(String.fromCharCode(str.charCodeAt(i) + 13))
2927
}
30-
return response.join("");
28+
}
29+
return response.join('')
3130
}
3231

33-
3432
// Caesars Cipher Example
35-
const encryptedString = "Uryyb Jbeyq";
36-
const decryptedString = rot13(encryptedString);
33+
const encryptedString = 'Uryyb Jbeyq'
34+
const decryptedString = rot13(encryptedString)
3735

38-
console.log(decryptedString); // Hello World
36+
console.log(decryptedString) // Hello World

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.