From 13b7c244790a2da99fbd91f01bfe321d84bd02fb Mon Sep 17 00:00:00 2001 From: tehliang Date: Mon, 25 Jul 2022 11:39:32 +0800 Subject: [PATCH 01/64] Added Composite Number --- Maths/IsCompositeNumber.js | 30 ++++++++++++++++++++++++++++ Maths/test/IsCompositeNumber.test.js | 15 ++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Maths/IsCompositeNumber.js create mode 100644 Maths/test/IsCompositeNumber.test.js diff --git a/Maths/IsCompositeNumber.js b/Maths/IsCompositeNumber.js new file mode 100644 index 0000000000..ee420d66e3 --- /dev/null +++ b/Maths/IsCompositeNumber.js @@ -0,0 +1,30 @@ +/* + * Composite number: https://en.wikipedia.org/wiki/Composite_number + * function isCompositeNumber + * Check if a given number is a composite number or not? + * isCompositeNumber(6) // returns true + * isCompositeNumber(577) // returns false + * isCompositeNumber(2024) // returns true + * A composite number is a positive integer that is not prime. In other words, it has a positive divisor other than one or itself. + * First few composite numbers are 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, ……… + * Every integer greater than one is either a prime number or a composite number. + * The number one is a unit – it is neither prime nor composite. + */ + +function isCompositeNumber (number) { + let i = 1 + let count = 0 + while (number >= i) { + if (number % i === 0) { + count++ + } + i++ + } + if (count > 2) { + return true + } else { + return false + } +} + +export { isCompositeNumber } diff --git a/Maths/test/IsCompositeNumber.test.js b/Maths/test/IsCompositeNumber.test.js new file mode 100644 index 0000000000..1122d44651 --- /dev/null +++ b/Maths/test/IsCompositeNumber.test.js @@ -0,0 +1,15 @@ +import { isCompositeNumber } from '../IsCompositeNumber' + +describe('Testing isCompositeNumber function', () => { + it('should return true if the number is composite number', () => { + expect(isCompositeNumber(6)).toBe(true) + }) + + it('should return false if the number is not composite number', () => { + expect(isCompositeNumber(577)).toBe(false) + }) + + it('should return true if the number is composite number', () => { + expect(isCompositeNumber(2024)).toBe(true) + }) +}) From 4d12b5161a49ab16bb79a54cace25618cd679924 Mon Sep 17 00:00:00 2001 From: tehliang Date: Tue, 26 Jul 2022 20:50:57 +0800 Subject: [PATCH 02/64] Updated isCompositeNumber Updated isCompositeNumber with a different approach --- Maths/IsCompositeNumber.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Maths/IsCompositeNumber.js b/Maths/IsCompositeNumber.js index ee420d66e3..82110f2109 100644 --- a/Maths/IsCompositeNumber.js +++ b/Maths/IsCompositeNumber.js @@ -9,22 +9,22 @@ * First few composite numbers are 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, ……… * Every integer greater than one is either a prime number or a composite number. * The number one is a unit – it is neither prime nor composite. + * Reference: https://www.geeksforgeeks.org/composite-number/ */ function isCompositeNumber (number) { - let i = 1 - let count = 0 - while (number >= i) { - if (number % i === 0) { - count++ - } - i++ - } - if (count > 2) { - return true - } else { - return false + // Condition that can immediate skip: + // Corner cases + if (number <= 1) return false + if (number <= 3) return false + // middle five numbers in below loop + if (number % 2 === 0 || number % 3 === 0) return true + + for (let i = 5; i * i <= number; i = i + 6) { + if (number % i === 0 || number % (i + 2) === 0) { return true } } + + return false } export { isCompositeNumber } From ccc7ff70016f80424c0a00aa018259d07755be74 Mon Sep 17 00:00:00 2001 From: tehliang Date: Tue, 26 Jul 2022 20:59:59 +0800 Subject: [PATCH 03/64] Updated IsCompositeNumber 2 Update some comment --- Maths/IsCompositeNumber.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Maths/IsCompositeNumber.js b/Maths/IsCompositeNumber.js index 82110f2109..19328006ee 100644 --- a/Maths/IsCompositeNumber.js +++ b/Maths/IsCompositeNumber.js @@ -13,11 +13,11 @@ */ function isCompositeNumber (number) { - // Condition that can immediate skip: + // Conditions that can immediate skip: // Corner cases if (number <= 1) return false if (number <= 3) return false - // middle five numbers in below loop + // Middle five numbers in below loop if (number % 2 === 0 || number % 3 === 0) return true for (let i = 5; i * i <= number; i = i + 6) { From 9672cb58cb4e7216edb31b818e9c9d0d42db22ec Mon Sep 17 00:00:00 2001 From: tehliang Date: Tue, 26 Jul 2022 21:02:02 +0800 Subject: [PATCH 04/64] Updated IsCompositeNumber.js Updated comments again --- Maths/IsCompositeNumber.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Maths/IsCompositeNumber.js b/Maths/IsCompositeNumber.js index 19328006ee..df9da75e5d 100644 --- a/Maths/IsCompositeNumber.js +++ b/Maths/IsCompositeNumber.js @@ -13,7 +13,7 @@ */ function isCompositeNumber (number) { - // Conditions that can immediate skip: + // Conditions that can immediate gain result: // Corner cases if (number <= 1) return false if (number <= 3) return false From 32343b44829f00ba94a9070730dc7ae94113f30b Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 11:59:55 +0800 Subject: [PATCH 05/64] Create codecov.yml --- .github/workflows/codecov.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 0000000000..80056b0d32 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,18 @@ +name: Workflow for Codecov javascript +on: [push, pull_request] +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up Node 18 + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install dependencies + run: npm install + - name: Run tests and collect coverage + run: npm run test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 From 3db3879b7ae88c21b54316c605fc2aa7a955f8ae Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 19 Aug 2022 04:00:21 +0000 Subject: [PATCH 06/64] Updated Documentation in README.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index dccfbb7c9a..f2d0bf4fab 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -170,6 +170,7 @@ * [IsEven](Maths/IsEven.js) * [IsOdd](Maths/IsOdd.js) * [IsPronic](Maths/IsPronic.js) + * [JugglerSequence](Maths/JugglerSequence.js) * [LeapYear](Maths/LeapYear.js) * [LinearSieve](Maths/LinearSieve.js) * [LucasSeries](Maths/LucasSeries.js) From fbde08eb447e44bf87399b14e486fdc84c2fbed5 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:08:17 +0800 Subject: [PATCH 07/64] Delete CheckAnagram.js --- String/CheckAnagram.js | 76 ------------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 String/CheckAnagram.js diff --git a/String/CheckAnagram.js b/String/CheckAnagram.js deleted file mode 100644 index 1fc5854298..0000000000 --- a/String/CheckAnagram.js +++ /dev/null @@ -1,76 +0,0 @@ -// An [Anagram](https://en.wikipedia.org/wiki/Anagram) is a string that is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Anagram check is not case-sensitive; -/** - * @function checkAnagramRegex - * @param {string} str1 - * @param {string} str2 - * @returns {boolean} - * @description - check anagram with the help of Regex - * @example - checkAnagramRegex('node', 'deno') => true - * @example - checkAnagramRegex('Eleven plus two', 'Twelve plus one') => true - */ -const checkAnagramRegex = (str1, str2) => { - // check that inputs are strings. - if (typeof str1 !== 'string' || typeof str2 !== 'string') { - throw new TypeError('Both arguments should be strings.') - } - - // If both strings have not same lengths then they can not be anagram. - if (str1.length !== str2.length) { - return false - } - - /** - * str1 converted to an array and traverse each letter of str1 by reduce method - * reduce method return string which is empty or not. - * if it returns empty string '' -> falsy, with Logical !(NOT) Operator, it's will be converted to boolean and return true else false - */ - return ![...str1].reduce( - (str2Acc, cur) => str2Acc.replace(new RegExp(cur, 'i'), ''), // remove the similar letter from str2Acc in case-insensitive - str2 - ) -} - -/** - * @function checkAnagramMap - * @description - check anagram via using HashMap - * @param {string} str1 - * @param {string} str2 - * @returns {boolean} - * @example - checkAnagramMap('node', 'deno') => true - * @example - checkAnagramMap('Eleven plus two', 'Twelve plus one') => true - */ -const checkAnagramMap = (str1, str2) => { - // check that inputs are strings. - if (typeof str1 !== 'string' || typeof str2 !== 'string') { - throw new TypeError('Both arguments should be strings.') - } - - // If both strings have not same lengths then they can not be anagram. - if (str1.length !== str2.length) { - return false - } - - const str1List = Array.from(str1.toUpperCase()) // str1 to array - - // get the occurrences of str1 characters by using HashMap - const str1Occurs = str1List.reduce( - (map, char) => map.set(char, map.get(char) + 1 || 1), - new Map() - ) - - for (const char of str2.toUpperCase()) { - // if char has not exist to the map it's return false - if (!str1Occurs.has(char)) { - return false - } - - let getCharCount = str1Occurs.get(char) - str1Occurs.set(char, --getCharCount) - - getCharCount === 0 && str1Occurs.delete(char) - } - - return true -} - -export { checkAnagramRegex, checkAnagramMap } From baf9d4b57249d6f161fce422bada92182cf5cb67 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:08:27 +0800 Subject: [PATCH 08/64] Delete CheckAnagram.test.js --- String/test/CheckAnagram.test.js | 181 ------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 String/test/CheckAnagram.test.js diff --git a/String/test/CheckAnagram.test.js b/String/test/CheckAnagram.test.js deleted file mode 100644 index 44adc196bc..0000000000 --- a/String/test/CheckAnagram.test.js +++ /dev/null @@ -1,181 +0,0 @@ -import { checkAnagramMap, checkAnagramRegex } from '../CheckAnagram' - -describe('Testing checkAnagramRegex', () => { - it.each` - inputOne | inputTwo - ${123456} | ${'abcd'} - ${[1, 2, 3, 4, 5, 6]} | ${'abcd'} - ${{ test: 'test' }} | ${'abcd'} - ${'abcd'} | ${123456} - ${'abcd'} | ${[1, 2, 3, 4, 5, 6]} - ${'abcd'} | ${{ test: 'test' }} - `( - 'expects to throw the type Error given values $inputOne and $inputTwo', - ({ inputOne, inputTwo }) => { - expect( - () => checkAnagramRegex(inputOne, inputTwo) - ).toThrowError() - } - ) - - it('expects to return false if the arguments have different lengths', () => { - const SUT = checkAnagramRegex('abs', 'abds') - expect(SUT).toBe(false) - }) - - it('expects to return false if the arguments are not anagrams', () => { - const SUT = checkAnagramRegex('abcs', 'abds') - expect(SUT).toBe(false) - }) - - it('expects to return true if the arguments are anagrams', () => { - const SUT = checkAnagramRegex('abcd', 'bcad') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments of length 1 and are the same letter', () => { - const SUT = checkAnagramRegex('a', 'a') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments of are both empty strings', () => { - const SUT = checkAnagramRegex('', '') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams with an odd length', () => { - const SUT = checkAnagramRegex('abcde', 'edcab') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams with an even length', () => { - const SUT = checkAnagramRegex('abcdef', 'fedcab') - expect(SUT).toBe(true) - }) - - it('expects to return false if either argument is an empty string while the other is not', () => { - const SUT = checkAnagramRegex('', 'edcab') - expect(SUT).toBe(false) - const SUT2 = checkAnagramRegex('edcab', '') - expect(SUT2).toBe(false) - }) - - it('expects to return true if the arguments contain the same letters but have unequal case', () => { - const SUT = checkAnagramRegex('ABDCE', 'abcde') - expect(SUT).toBe(true) - const SUT2 = checkAnagramRegex('AbCdE', 'aBCdE') - expect(SUT2).toBe(true) - const SUT3 = checkAnagramRegex('Eleven plus two', 'Twelve plus one') - expect(SUT3).toBe(true) - }) - - it('expects to return true if the arguments are anagrams and contain number characters', () => { - const SUT = checkAnagramRegex('a1b2', '12ba') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams and contain space characters', () => { - const SUT = checkAnagramRegex('a1 b2', '1 2ba') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams and contain punctuation characters', () => { - const SUT = checkAnagramRegex('a!1b@2', '1@2ba!') - expect(SUT).toBe(true) - }) - - it('expects to return false if the arguments contain the same letters but contain a different amount of space characters', () => { - const SUT = checkAnagramRegex('ea cb', 'e cba') - expect(SUT).toBe(false) - }) -}) - -describe('Testing checkAnagramMap', () => { - it.each` - inputOne | inputTwo - ${123456} | ${'abcd'} - ${[1, 2, 3, 4, 5, 6]} | ${'abcd'} - ${{ test: 'test' }} | ${'abcd'} - ${'abcd'} | ${123456} - ${'abcd'} | ${[1, 2, 3, 4, 5, 6]} - ${'abcd'} | ${{ test: 'test' }} - `( - 'expects to throw the type Error given values $inputOne and $inputTwo', - ({ inputOne, inputTwo }) => { - expect( - () => checkAnagramMap(inputOne, inputTwo) - ).toThrowError() - } - ) - - it('expects to return false if the arguments have different lengths', () => { - const SUT = checkAnagramMap('abs', 'abds') - expect(SUT).toBe(false) - }) - - it('expects to return false if the arguments are not anagrams', () => { - const SUT = checkAnagramMap('abcs', 'abds') - expect(SUT).toBe(false) - }) - - it('expects to return true if the arguments are anagrams', () => { - const SUT = checkAnagramMap('abcd', 'bcad') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments of length 1 and are the same letter', () => { - const SUT = checkAnagramMap('a', 'a') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments of are both empty strings', () => { - const SUT = checkAnagramMap('', '') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams with an odd length', () => { - const SUT = checkAnagramMap('abcde', 'edcab') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams with an even length', () => { - const SUT = checkAnagramMap('abcdef', 'fedcab') - expect(SUT).toBe(true) - }) - - it('expects to return false if either argument is an empty string while the other is not', () => { - const SUT = checkAnagramMap('', 'edcab') - expect(SUT).toBe(false) - const SUT2 = checkAnagramMap('edcab', '') - expect(SUT2).toBe(false) - }) - - it('expects to return true if the arguments contain the same letters but have unequal case', () => { - const SUT = checkAnagramMap('ABDCE', 'abcde') - expect(SUT).toBe(true) - const SUT2 = checkAnagramMap('AbCdE', 'aBCdE') - expect(SUT2).toBe(true) - const SUT3 = checkAnagramMap('Eleven plus two', 'Twelve plus one') - expect(SUT3).toBe(true) - }) - - it('expects to return true if the arguments are anagrams and contain number characters', () => { - const SUT = checkAnagramMap('a1b2', '12ba') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams and contain space characters', () => { - const SUT = checkAnagramMap('a1 b2', '1 2ba') - expect(SUT).toBe(true) - }) - - it('expects to return true if the arguments are anagrams and contain punctuation characters', () => { - const SUT = checkAnagramMap('a!1b@2', '1@2ba!') - expect(SUT).toBe(true) - }) - - it('expects to return false if the arguments contain the same letters but contain a different amount of space characters', () => { - const SUT = checkAnagramMap('ea cb', 'e cba') - expect(SUT).toBe(false) - }) -}) From 95cad0166caf23ce32b62c3be7222b061f57f1f8 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:08:44 +0800 Subject: [PATCH 09/64] Delete Pow.js --- Maths/Pow.js | 62 ---------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 Maths/Pow.js diff --git a/Maths/Pow.js b/Maths/Pow.js deleted file mode 100644 index 44ce31e8ac..0000000000 --- a/Maths/Pow.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @function powLinear - * @description - The powLinear function is a power function with Linear O(n) complexity - * @param {number} base - * @param {number} exponent - * @returns {number} - * @example - powLinear(2, 2) => 4 --> 2 * 2 - * @example - powLinear(3, 3) => 27 --> 3 * 3 * 3 - */ -const powLinear = (base, exponent) => { - if (exponent < 0) { - base = 1 / base - exponent = -exponent - } - - let result = 1 - - while (exponent--) { // Break the execution while the exponent will 0 - result *= base - } - - return result -} - -/** - * @function powFaster - * @description - The powFaster function is a power function with O(logN) complexity - * @param {number} base - * @param {number} exponent - * @returns {number} - * @example - powFaster(2, 2) => 4 --> 2 * 2 - * @example - powFaster(3, 3) => 27 --> 3 * 3 * 3 - */ -const powFaster = (base, exponent) => { - if (exponent < 2) { // explanation below - 1 - return base && ([1, base][exponent] || powFaster(1 / base, -exponent)) - } - - if (exponent & 1) { // if the existing exponent is odd - return base * powFaster(base * base, exponent >> 1) // explanation below - 2 - } - - return powFaster(base * base, exponent / 2) -} - -/** - * 1 - Magic of short circuit evaluation (&&, ||) - * if the base is 0 then it returns 0 cause 0 is falsy - * if the base is not 0 then it's must be truthy. after that, it will be executed the right portion of the && (AND) operator - * Now it checks the exponent by the help array index, is it 0 or 1. - * if the exponent is not 0 or 1 it's definitely less than 0, and a negative number is not a valid index number so it returns "undefined" - * if the expression is undefined mean -> falsy, the || (OR) operator evaluates the right portion that is a recursive function. - */ - -/** - * 2 - Play with right shift bitwise operator (>>) - * right shift with any odd numbers it returns the floor number instead of float. - * E.g. if the number is 5, after right shifting with 1 it's will give us 2, not 2.5 - * cause the right shift formula is --> x >> y = |x| / 2^y - */ - -export { powLinear, powFaster } From 4034c0566a3f280f5b772a5fe073cdfb978db56e Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:08:59 +0800 Subject: [PATCH 10/64] Delete Pow.test.js --- Maths/test/Pow.test.js | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 Maths/test/Pow.test.js diff --git a/Maths/test/Pow.test.js b/Maths/test/Pow.test.js deleted file mode 100644 index 9ffb64e52d..0000000000 --- a/Maths/test/Pow.test.js +++ /dev/null @@ -1,41 +0,0 @@ -import { powLinear, powFaster } from '../Pow' - -describe('Testing powLinear function', () => { - it('should return 1 for numbers with exponent 0', () => { - expect(powLinear(2, 0)).toBe(1) - }) - - it('should return 0.5 for numbers with exponent -1', () => { - expect(powLinear(2, -1)).toBe(0.5) - }) - - it('should return 0 for numbers with base 0', () => { - expect(powLinear(0, 23)).toBe(0) - }) - - it('should return the base to the exponent power', () => { - expect(powLinear(24, 4)).toBe(331776) - }) -}) - -describe('Testing powFaster function', () => { - it('should return 1 for numbers with exponent 0', () => { - expect(powFaster(2, 0)).toBe(1) - }) - - it('should return 0.5 for numbers with exponent -1', () => { - expect(powFaster(2, -1)).toBe(0.5) - }) - - it('should return 0 for numbers with base 0', () => { - expect(powFaster(0, 23)).toBe(0) - }) - - it('should return the base to the exponent power', () => { - expect(powFaster(24, 4)).toBe(331776) - }) - - it('should return the result in O(lonN) complexity', () => { - expect(powFaster(2, 64)).toBe(18446744073709552000) // execution time Math.log2(64) -> 6 - }) -}) From 739ae862748e0ec15ffb26b8c391227e18d2f259 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:09:11 +0800 Subject: [PATCH 11/64] Delete PiApproximationMonteCarlo.test.js --- Maths/test/PiApproximationMonteCarlo.test.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 Maths/test/PiApproximationMonteCarlo.test.js diff --git a/Maths/test/PiApproximationMonteCarlo.test.js b/Maths/test/PiApproximationMonteCarlo.test.js deleted file mode 100644 index 9727aa5788..0000000000 --- a/Maths/test/PiApproximationMonteCarlo.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import { piEstimation } from '../PiApproximationMonteCarlo' - -describe('PiApproximationMonteCarlo', () => { - it('should be between the range of 2 to 4', () => { - const pi = piEstimation() - const piRange = pi >= 2 && pi <= 4 - expect(piRange).toBeTruthy() - }) -}) From 1fec7b4871cf9610a49526ff0c316c573ce964bf Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:09:34 +0800 Subject: [PATCH 12/64] Delete PiApproximationMonteCarlo.js --- Maths/PiApproximationMonteCarlo.js | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 Maths/PiApproximationMonteCarlo.js diff --git a/Maths/PiApproximationMonteCarlo.js b/Maths/PiApproximationMonteCarlo.js deleted file mode 100644 index 08849b5475..0000000000 --- a/Maths/PiApproximationMonteCarlo.js +++ /dev/null @@ -1,21 +0,0 @@ -// Wikipedia: https://en.wikipedia.org/wiki/Monte_Carlo_method -// Video Explanation: https://www.youtube.com/watch?v=ELetCV_wX_c - -const piEstimation = (iterations = 100000) => { - let circleCounter = 0 - - for (let i = 0; i < iterations; i++) { - // generating random points and checking if it lies within a circle of radius 1 - const x = Math.random() - const y = Math.random() - const radius = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) - - if (radius < 1) circleCounter += 1 - } - - // fomula for pi = (ratio of number inside circle and total iteration) x 4 - const pi = (circleCounter / iterations) * 4 - return pi -} - -export { piEstimation } From 925c5e9411328f72f19aa7ecac9a986e763e4678 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 19 Aug 2022 04:09:56 +0000 Subject: [PATCH 13/64] Updated Documentation in README.md --- DIRECTORY.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index f2d0bf4fab..3aefc962a8 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -187,9 +187,7 @@ * [PerfectNumber](Maths/PerfectNumber.js) * [PerfectSquare](Maths/PerfectSquare.js) * [PermutationAndCombination](Maths/PermutationAndCombination.js) - * [PiApproximationMonteCarlo](Maths/PiApproximationMonteCarlo.js) * [Polynomial](Maths/Polynomial.js) - * [Pow](Maths/Pow.js) * [PowLogarithmic](Maths/PowLogarithmic.js) * [PrimeCheck](Maths/PrimeCheck.js) * [PrimeFactors](Maths/PrimeFactors.js) @@ -285,7 +283,6 @@ * [AlphaNumericPalindrome](String/AlphaNumericPalindrome.js) * [AlternativeStringArrange](String/AlternativeStringArrange.js) * [BoyerMoore](String/BoyerMoore.js) - * [CheckAnagram](String/CheckAnagram.js) * [CheckCamelCase](String/CheckCamelCase.js) * [CheckExceeding](String/CheckExceeding.js) * [CheckFlatCase](String/CheckFlatCase.js) From d222af2c837e381642f17a00f0fc17416f3a8aeb Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:19:18 +0800 Subject: [PATCH 14/64] Create dependabot.yml --- .github/dependabot.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..4872c5afd2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 From 26fc815198b5cd9965b4254c71f8e5aae4d86bb5 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:28:06 +0800 Subject: [PATCH 15/64] Delete dependabot.yml --- .github/dependabot.yml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 4872c5afd2..0000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2 -updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 From 26fd2f64eae8c3c05be579dea33b5e7cb4d8c8a7 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:29:18 +0800 Subject: [PATCH 16/64] Create JavascriptAlgoCL.yml --- .github/workflows/JavascriptAlgoCL.yml | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/JavascriptAlgoCL.yml diff --git a/.github/workflows/JavascriptAlgoCL.yml b/.github/workflows/JavascriptAlgoCL.yml new file mode 100644 index 0000000000..3efdca660f --- /dev/null +++ b/.github/workflows/JavascriptAlgoCL.yml @@ -0,0 +1,36 @@ +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions + +name: Javascript Algorithm CI + +on: [push, pull_request] + +permissions: write-all + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v2 + + - name: npm install, build, and test + run: | + npm install doctest + npm install standard --save-dev + npx doctest **/*.js || true # TODO: Add all doctests + npx standard + npm ci + npm run build --if-present + + env: + CI: true + + - name: Run the tests + run: npm test -- --coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 From 3af430680c0768f7d93fb51915efb29be6c0d07d Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:29:44 +0800 Subject: [PATCH 17/64] Create codacy-analysis.yaml --- .github/workflows/codacy-analysis.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/codacy-analysis.yaml diff --git a/.github/workflows/codacy-analysis.yaml b/.github/workflows/codacy-analysis.yaml new file mode 100644 index 0000000000..9c7d5fe5a1 --- /dev/null +++ b/.github/workflows/codacy-analysis.yaml @@ -0,0 +1,14 @@ +name: Codacy Analysis CLI + +on: [push, pull_request] + +jobs: + codacy-analysis-cli: + name: Codacy Analysis CLI + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@main + + - name: Run Codacy Analysis CLI + uses: codacy/codacy-analysis-cli-action@master From 4d804a3944846118e2e1b231e861d79a32f1872b Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:42:43 +0800 Subject: [PATCH 18/64] Update JavascriptAlgoCL.yml --- .github/workflows/JavascriptAlgoCL.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/JavascriptAlgoCL.yml b/.github/workflows/JavascriptAlgoCL.yml index 3efdca660f..e67ff5bf56 100644 --- a/.github/workflows/JavascriptAlgoCL.yml +++ b/.github/workflows/JavascriptAlgoCL.yml @@ -33,4 +33,4 @@ jobs: run: npm test -- --coverage - name: Upload coverage to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3.1.0 From 77d67b31ba492896642166fe52fa58000d2215df Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 12:46:17 +0800 Subject: [PATCH 19/64] Delete codecov.yml --- .github/workflows/codecov.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index 80056b0d32..0000000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Workflow for Codecov javascript -on: [push, pull_request] -jobs: - run: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Set up Node 18 - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm install - - name: Run tests and collect coverage - run: npm run test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 From 453ceea33fd52058537ffeb2aef0e7eac0e3ceea Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 13:04:38 +0800 Subject: [PATCH 20/64] Delete AlphaNumericPalindrome.js --- String/AlphaNumericPalindrome.js | 35 -------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 String/AlphaNumericPalindrome.js diff --git a/String/AlphaNumericPalindrome.js b/String/AlphaNumericPalindrome.js deleted file mode 100644 index f3de94b642..0000000000 --- a/String/AlphaNumericPalindrome.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @function alphaNumericPalindrome - * @description alphaNumericPalindrome should return true if the string has alphanumeric characters that are palindrome irrespective of special characters and the letter case. - * @param {string} str the string to check - * @returns {boolean} - * @see [Palindrome](https://en.wikipedia.org/wiki/Palindrome) - * @example - * The function alphaNumericPalindrome() receives a string with varying formats - * like "racecar", "RaceCar", and "race CAR" - * The string can also have special characters - * like "2A3*3a2", "2A3 3a2", and "2_A3*3#A2" - * - * But the catch is, we have to check only if the alphanumeric characters - * are palindrome i.e remove spaces, symbols, punctuations etc - * and the case of the characters doesn't matter - */ -const alphaNumericPalindrome = (str) => { - if (typeof str !== 'string') { - throw new TypeError('Argument should be string') - } - - // removing all the special characters and turning everything to lowercase - const newStr = str.replace(/[^a-z0-9]+/ig, '').toLowerCase() - const midIndex = newStr.length >> 1 // x >> y = floor(x / 2^y) - - for (let i = 0; i < midIndex; i++) { - if (newStr.at(i) !== newStr.at(~i)) { // ~n = -(n + 1) - return false - } - } - - return true -} - -export default alphaNumericPalindrome From f31b3f0c9b271291bbb86ea4fc54c03b98d1d1b7 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 13:04:46 +0800 Subject: [PATCH 21/64] Delete AlphaNumericPalindrome.test.js --- String/test/AlphaNumericPalindrome.test.js | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 String/test/AlphaNumericPalindrome.test.js diff --git a/String/test/AlphaNumericPalindrome.test.js b/String/test/AlphaNumericPalindrome.test.js deleted file mode 100644 index ab7373b53b..0000000000 --- a/String/test/AlphaNumericPalindrome.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import alphaNumericPalindrome from '../AlphaNumericPalindrome' - -describe('Testing the alpha numeric palindrome', () => { - // should return true if the given string has alphanumeric characters that are palindrome irrespective of case and symbols - it('Testing with valid alphabetic palindrome', () => { - expect(alphaNumericPalindrome('eye')).toBe(true) - expect(alphaNumericPalindrome('Madam')).toBe(true) - expect(alphaNumericPalindrome('race CAR')).toBe(true) - expect(alphaNumericPalindrome('A man, a plan, a canal. Panama')).toBe(true) - }) - - it('Testing with number and symbol', () => { - expect(alphaNumericPalindrome('0_0 (: /-:) 0-0')).toBe(true) - expect(alphaNumericPalindrome('03_|53411435|_30')).toBe(true) - }) - - it('Testing with alphabets and symbols', () => { - expect(alphaNumericPalindrome('five|_/|evif')).toBe(true) - expect(alphaNumericPalindrome('five|_/|four')).toBe(false) - }) -}) From d2bca6db1bad34dcb9cef04f4dfe5f2aa0dbf06f Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 19 Aug 2022 05:05:11 +0000 Subject: [PATCH 22/64] Updated Documentation in README.md --- DIRECTORY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 3aefc962a8..e2a0ed81d7 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -280,7 +280,6 @@ * [TimSort](Sorts/TimSort.js) * [TopologicalSort](Sorts/TopologicalSort.js) * **String** - * [AlphaNumericPalindrome](String/AlphaNumericPalindrome.js) * [AlternativeStringArrange](String/AlternativeStringArrange.js) * [BoyerMoore](String/BoyerMoore.js) * [CheckCamelCase](String/CheckCamelCase.js) From 8b0243794d7dc1ca9620e29d81c9f848eb009138 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 22:17:01 +0800 Subject: [PATCH 23/64] Delete CollatzSequence.js --- Maths/CollatzSequence.js | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 Maths/CollatzSequence.js diff --git a/Maths/CollatzSequence.js b/Maths/CollatzSequence.js deleted file mode 100644 index d8ead61cc2..0000000000 --- a/Maths/CollatzSequence.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @function collatz - * @description Applies the Collatz Sequence on a specified number. - * The Collatz Sequence states that every natural number will always fall in a 1, 2, 4 loop when iterated under the following function: - * If the number is even, divide by 2, and if its odd, multiply it by 3 and add 1. - * - * @parama {Integer} n The number to apply the Collatz Sequence to. - * - * @return An array of steps and the final result.. - * - * @see [Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) - * - * @example collatz(1) = { result: 1, steps: [] } - * @example collatz(5) = { result: 1, steps: [16, 8, 4, 2, 1] } -*/ -export function collatz (n) { - const steps = [] - - while (n !== 1) { - if (n % 2 === 0) { - n = n / 2 - } else { - n = 3 * n + 1 - } - - steps.push(n) - } - - return { result: n, steps: steps } -} From 70380054ddbfe60292261e85c48b701396424192 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 22:17:12 +0800 Subject: [PATCH 24/64] Delete CollatzSequence.test.js --- Maths/test/CollatzSequence.test.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 Maths/test/CollatzSequence.test.js diff --git a/Maths/test/CollatzSequence.test.js b/Maths/test/CollatzSequence.test.js deleted file mode 100644 index f837bd90d7..0000000000 --- a/Maths/test/CollatzSequence.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import { collatz } from '../CollatzSequence' - -describe('The Collatz Sequence', () => { - it('Should be 1', () => { - expect(collatz(1)).toStrictEqual({ result: 1, steps: [] }) - expect(collatz(5)).toStrictEqual({ result: 1, steps: [16, 8, 4, 2, 1] }) - }) -}) From c33c260866112bd634a8d51798b4cd30712721de Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 22:19:35 +0800 Subject: [PATCH 25/64] Delete JugglerSequence.js --- Maths/JugglerSequence.js | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 Maths/JugglerSequence.js diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js deleted file mode 100644 index 96a2a35150..0000000000 --- a/Maths/JugglerSequence.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence - * function jugglerSequence - * Juggler Sequence is a series of integer number in which the first term starts with a positive integer number n - * and the remaining terms are generated from the immediate previous term using the recurrence relation - * Produce Juggler Sequence using number n as the first term of the sequence and store in an array - * Reference: https://www.geeksforgeeks.org/juggler-sequence/ - * jugglerSequence(3) // returns [3, 5, 11, 36, 6, 2, 1 ] - * jugglerSequence(9) // returns [9, 27, 140, 11, 36, 6, 2, 1] - * jugglerSequence(15) // returns [15, 58, 7, 18, 4, 2, 1] - */ - -function jugglerSequence (n) { - const sequence = [] - sequence.push(n) - // Calculate terms until last term is not 1 - while (n !== 1) { - n = Math.floor(n ** ((n % 2) + 0.5)) - sequence.push(n) - } - return sequence -} - -export { jugglerSequence } From 613710ccae36d000ba46d58a489e60f78675ebd2 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 19 Aug 2022 22:19:47 +0800 Subject: [PATCH 26/64] Delete JugglerSequence.test.js --- Maths/test/JugglerSequence.test.js | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 Maths/test/JugglerSequence.test.js diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js deleted file mode 100644 index 392047a95b..0000000000 --- a/Maths/test/JugglerSequence.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { jugglerSequence } from '../JugglerSequence' - -describe('Testing jugglerSequence function', () => { - it('should return [3, 5, 11, 36, 6, 2, 1 ] if the number is 3', () => { - expect(jugglerSequence(3)).toEqual( - expect.arrayContaining([3, 5, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [9, 27, 140, 11, 36, 6, 2, 1] if the number is 9', () => { - expect(jugglerSequence(9)).toEqual( - expect.arrayContaining([9, 27, 140, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { - expect(jugglerSequence(15)).toEqual( - expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) - ) - }) -}) From 8134ca1a909ea3d8b3881353705dc0dffb555b2a Mon Sep 17 00:00:00 2001 From: tehliang Date: Mon, 22 Aug 2022 13:57:48 +0800 Subject: [PATCH 27/64] Delete LeapYear.js --- Maths/LeapYear.js | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 Maths/LeapYear.js diff --git a/Maths/LeapYear.js b/Maths/LeapYear.js deleted file mode 100644 index bddcea7afc..0000000000 --- a/Maths/LeapYear.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * isLeapYear :: Number -> Boolean - * - * Check if a year is a leap year or not. A leap year is a year which has 366 days. - * For the extra +1 day the February month contains 29 days instead of 28 days. - * - * The logic behind the leap year is- - * 1. If the year is divisible by 400 then it is a leap year. - * 2. If it is not divisible by 400 but divisible by 100 then it is not a leap year. - * 3. If the year is not divisible by both 400 and 100 but divisible by 4 then a leap year. - * 4. Other cases except the describing ones are not a leap year. - * - * @param {number} year - * @returns {boolean} true if this is a leap year, false otherwise. - */ -export const isLeapYear = (year) => { - if (year % 400 === 0) return true - if (year % 100 === 0) return false - if (year % 4 === 0) return true - - return false -} From 74d136b748ec80a638f96c88a9b046659f0545a7 Mon Sep 17 00:00:00 2001 From: tehliang Date: Mon, 22 Aug 2022 13:58:01 +0800 Subject: [PATCH 28/64] Delete LeapYear.test.js --- Maths/test/LeapYear.test.js | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 Maths/test/LeapYear.test.js diff --git a/Maths/test/LeapYear.test.js b/Maths/test/LeapYear.test.js deleted file mode 100644 index c30786c0e1..0000000000 --- a/Maths/test/LeapYear.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import { isLeapYear } from '../LeapYear' - -describe('Leap Year', () => { - it('Should return true on the year 2000', () => { - expect(isLeapYear(2000)).toBe(true) - }) - it('Should return false on the year 2001', () => { - expect(isLeapYear(2001)).toBe(false) - }) - it('Should return false on the year 2002', () => { - expect(isLeapYear(2002)).toBe(false) - }) - it('Should return false on the year 2003', () => { - expect(isLeapYear(2003)).toBe(false) - }) - it('Should return false on the year 2004', () => { - expect(isLeapYear(2004)).toBe(true) - }) - it('Should return false on the year 1900', () => { - expect(isLeapYear(1900)).toBe(false) - }) -}) From 2456cea00fe7c11854d0327469ae7147cd33fa55 Mon Sep 17 00:00:00 2001 From: cwh0430 Date: Mon, 22 Aug 2022 22:52:01 +0800 Subject: [PATCH 29/64] Added PythagoreanTheorem.js --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d7cb0da2ee..d3f4600666 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "babel-jest": "^26.3.0", "globby": "^12.0.2", "husky": "^7.0.4", - "jest": "^26.4.2", + "jest": "^26.6.3", "standard": "^16.0.4" }, "engines": { diff --git a/package.json b/package.json index 8ba035922c..f7865aebec 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "babel-jest": "^26.3.0", "globby": "^12.0.2", "husky": "^7.0.4", - "jest": "^26.4.2", + "jest": "^26.6.3", "standard": "^16.0.4" }, "engines": { From fb08dd35e2bb4802432bf84d4e1179c3e9399c96 Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 26 Aug 2022 09:59:16 +0800 Subject: [PATCH 30/64] Delete UpdateDirectory.mjs --- .github/workflows/UpdateDirectory.mjs | 71 --------------------------- 1 file changed, 71 deletions(-) delete mode 100644 .github/workflows/UpdateDirectory.mjs diff --git a/.github/workflows/UpdateDirectory.mjs b/.github/workflows/UpdateDirectory.mjs deleted file mode 100644 index 0136f4bae4..0000000000 --- a/.github/workflows/UpdateDirectory.mjs +++ /dev/null @@ -1,71 +0,0 @@ -import path from 'path' -import fs from 'fs' -import { globby } from 'globby' - -function pathPrefix (i) { - const res = ' '.repeat(i) - return res + '*' -} - -function printPath (oldPath, newPath, output) { - const oldParts = oldPath.split(path.sep) - const newParts = newPath.split(path.sep) - - for (let i = 0; i < newParts.length; ++i) { - const newPart = newParts[i] - if (i + 1 > oldParts.length || oldParts[i] !== newPart) { - if (newPart) { - output.push(`${pathPrefix(i)} **${newPart.replace('_', ' ')}**`) - } - } - } - - return newPath -} - -function pathsToMarkdown (filePaths) { - const output = [] - - let oldPath = '' - filePaths.sort(function (a, b) { - if (a.toLowerCase() < b.toLowerCase()) return -1 - if (a.toLowerCase() > b.toLowerCase()) return 1 - return 0 - }) - - for (let filepath of filePaths) { - let filename = path.basename(filepath) - filepath = path.dirname(filepath) - - if (filepath !== oldPath) { - oldPath = printPath(oldPath, filepath, output) - } - - let indent = filepath.split(path.sep).length - - // prepare the markdown-esque prefix to the file's line - const prefix = pathPrefix(indent) - - // remove extension from filename - const name = path.basename(filename, ".js") - const url = path.join(filepath, filename) - - output.push(`${prefix} [${name}](${url})`) - } - - return output.join('\n') -} - -// get paths of all .js files - excluding node_modules, the .github folder, tests and config stuff -globby([ - '**/*.js', - '!(node_modules|.github)/**/*', - "!**/test/**/*", - '!**/*.test.js', - '!**/*.manual-test.js', - '!babel.config.js' -]) - // create markdown content - .then(pathsToMarkdown) - // write markdown to file - .then(markdown => fs.writeFileSync('DIRECTORY.md', markdown + '\n', { encoding: 'utf8' })) From 7cb07555a20dffab51213af6e91c5ea3b0ff6bcf Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 26 Aug 2022 09:59:32 +0800 Subject: [PATCH 31/64] Delete UpdateDirectory.yml --- .github/workflows/UpdateDirectory.yml | 37 --------------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/UpdateDirectory.yml diff --git a/.github/workflows/UpdateDirectory.yml b/.github/workflows/UpdateDirectory.yml deleted file mode 100644 index d5202b2d21..0000000000 --- a/.github/workflows/UpdateDirectory.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This GitHub Action updates the DIRECTORY.md file (if needed) when doing a git push -name: Update Directory - -on: - push: - branches-ignore: - "master" - -jobs: - updateDirectory: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: "14" - cache: npm - - - name: 📦 Install dependencies - run: npm ci - - - name: 🗄️ Create Directory from JS files - run: node .github/workflows/UpdateDirectory.mjs - - - name: Configure Github Action - run: | - git config --global user.name github-actions - git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' - - - name: 🤓 Commit & push new Directory (if needed) - run: | - if [[ `git status --porcelain` ]]; then - git commit -am "Updated Documentation in README.md" - git push - else - echo "NO CHANGES DETECTED" - fi From 4e36956be62379bc0e4e94e54e16cab1ae3a1a2d Mon Sep 17 00:00:00 2001 From: tehliang Date: Fri, 26 Aug 2022 16:13:23 +0800 Subject: [PATCH 32/64] Delete codacy-analysis.yaml --- .github/workflows/codacy-analysis.yaml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 .github/workflows/codacy-analysis.yaml diff --git a/.github/workflows/codacy-analysis.yaml b/.github/workflows/codacy-analysis.yaml deleted file mode 100644 index 9c7d5fe5a1..0000000000 --- a/.github/workflows/codacy-analysis.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: Codacy Analysis CLI - -on: [push, pull_request] - -jobs: - codacy-analysis-cli: - name: Codacy Analysis CLI - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@main - - - name: Run Codacy Analysis CLI - uses: codacy/codacy-analysis-cli-action@master From e6a269bcaabe455be1e64c5b324d3e4bc0d74347 Mon Sep 17 00:00:00 2001 From: cwh0430 <108912628+cwh0430@users.noreply.github.com> Date: Fri, 26 Aug 2022 17:50:09 +0800 Subject: [PATCH 33/64] Update package-lock.json --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index d3f4600666..d7cb0da2ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "babel-jest": "^26.3.0", "globby": "^12.0.2", "husky": "^7.0.4", - "jest": "^26.6.3", + "jest": "^26.4.2", "standard": "^16.0.4" }, "engines": { From 44201ce7c166239ddba24ed79e9eebe9bfd9de5f Mon Sep 17 00:00:00 2001 From: cwh0430 <108912628+cwh0430@users.noreply.github.com> Date: Fri, 26 Aug 2022 17:53:18 +0800 Subject: [PATCH 34/64] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f7865aebec..8ba035922c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "babel-jest": "^26.3.0", "globby": "^12.0.2", "husky": "^7.0.4", - "jest": "^26.6.3", + "jest": "^26.4.2", "standard": "^16.0.4" }, "engines": { From 21655f29ac877cb0be8280b0d5674a9490af4043 Mon Sep 17 00:00:00 2001 From: cwh0430 <108912628+cwh0430@users.noreply.github.com> Date: Fri, 26 Aug 2022 18:14:53 +0800 Subject: [PATCH 35/64] Added PythagoreanTheorem.js --- Maths/PythagoreanTheorem.js | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Maths/PythagoreanTheorem.js diff --git a/Maths/PythagoreanTheorem.js b/Maths/PythagoreanTheorem.js new file mode 100644 index 0000000000..0a6752ec31 --- /dev/null +++ b/Maths/PythagoreanTheorem.js @@ -0,0 +1,39 @@ +/** + * @function calcHypotenuse + * @description Calculate the hypothenuse of a triangle. + * @param {Integer} base - Integer + * @param {Integer} adjacent - Integer + * @return {Integer} - hypotenuse + * @see [calcHypotenuse](https://en.wikipedia.org/wiki/Pythagorean_theorem) + * @example calcHypotenuse(6,8) = 10 + */ +const calcHypotenuse = (base, adjacent) => { + const hypotenuse = Math.sqrt(base ** 2 + adjacent ** 2) + return hypotenuse +} + +/** + * @function calcOtherSides + * @description Calculate the other sides of a triangle. + * @param {Integer} side1 - Integer + * @param {Integer} side2 - Integer + * @return {Integer} - sides + * @see [calcOtherSides](https://en.wikipedia.org/wiki/Pythagorean_theorem) + * @example calcOtherSides(6,10) = 8 + */ +const calcOtherSides = (side1, side2) => { + if (side1 > side2) { + const side = Math.sqrt(side1 ** 2 - side2 ** 2) + return side + } else if (side2 > side1) { + const side = Math.sqrt(side2 ** 2 - side1 ** 2) + return side + } + + return 'Both sides cannot be the same value' +} + +export { + calcHypotenuse, + calcOtherSides +} From 8126a423a1ef9c6e41bc4db382a2d4864127aa5f Mon Sep 17 00:00:00 2001 From: cwh0430 <108912628+cwh0430@users.noreply.github.com> Date: Fri, 26 Aug 2022 18:17:33 +0800 Subject: [PATCH 36/64] Added PythagoreanTheorem.test.js --- Maths/test/PythagoreanTheorem.test.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Maths/test/PythagoreanTheorem.test.js diff --git a/Maths/test/PythagoreanTheorem.test.js b/Maths/test/PythagoreanTheorem.test.js new file mode 100644 index 0000000000..4607b5a3b3 --- /dev/null +++ b/Maths/test/PythagoreanTheorem.test.js @@ -0,0 +1,23 @@ +import * as py from '../PythagoreanTheorem' + +describe('Testing calcHypotenuse calculations', () => { + it('with natural number', () => { + const result = py.calcHypotenuse(6, 8) + expect(result).toBe(10) + }) +}) + +describe('Testing calcOtherSides calculations', () => { + it('with side1 bigger than side2', () => { + const result = py.calcOtherSides(6, 10) + expect(result).toBe(8) + }) + it('with side2 bigger than side1', () => { + const result = py.calcOtherSides(10, 6) + expect(result).toBe(8) + }) + it('with side1 equals side2', () => { + const result = py.calcOtherSides(10, 10) + expect(result).toBe('Both sides cannot be the same value') + }) +}) From 51b3c9f68da3c1cdfa01a281f87e151d6873185e Mon Sep 17 00:00:00 2001 From: NJL0608 Date: Fri, 26 Aug 2022 22:15:46 +0800 Subject: [PATCH 37/64] test01 --- Cache/LFUCache.js | 242 ++++++++++++++++++------------------ Maths/LeapYear.js | 22 ++++ Maths/test/LeapYear.test.js | 22 ++++ 3 files changed, 165 insertions(+), 121 deletions(-) create mode 100644 Maths/LeapYear.js create mode 100644 Maths/test/LeapYear.test.js diff --git a/Cache/LFUCache.js b/Cache/LFUCache.js index 9bb08f6879..c7ed906177 100644 --- a/Cache/LFUCache.js +++ b/Cache/LFUCache.js @@ -45,121 +45,121 @@ class FrequencyMap extends Map { } class LFUCache { - #capacity - #frequencyMap + #capacity + #frequencyMap - /** + /** * @param {number} capacity - The range of LFUCache * @returns {LFUCache} - sealed */ - constructor (capacity) { - this.#capacity = capacity - this.#frequencyMap = new FrequencyMap() - this.misses = 0 - this.hits = 0 - this.cache = new Map() - - return Object.seal(this) - } + constructor (capacity) { + this.#capacity = capacity + this.#frequencyMap = new FrequencyMap() + this.misses = 0 + this.hits = 0 + this.cache = new Map() + + return Object.seal(this) + } - /** + /** * Get the capacity of the LFUCache * @returns {number} */ - get capacity () { - return this.#capacity - } + get capacity () { + return this.#capacity + } - /** + /** * Get the current size of LFUCache * @returns {number} */ - get size () { - return this.cache.size - } + get size () { + return this.cache.size + } - /** + /** * Set the capacity of the LFUCache if you decrease the capacity its removed CacheNodes following the LFU - least frequency used */ - set capacity (newCapacity) { - if (this.#capacity > newCapacity) { - let diff = this.#capacity - newCapacity // get the decrement number of capacity + set capacity (newCapacity) { + if (this.#capacity > newCapacity) { + let diff = this.#capacity - newCapacity // get the decrement number of capacity - while (diff--) { - this.#removeCacheNode() - } - - this.cache.size === 0 && this.#frequencyMap.clear() + while (diff--) { + this.#removeCacheNode() } - this.#capacity = newCapacity + this.cache.size === 0 && this.#frequencyMap.clear() } - get info () { - return Object.freeze({ - misses: this.misses, - hits: this.hits, - capacity: this.capacity, - currentSize: this.size, - leastFrequency: this.leastFrequency - }) - } + this.#capacity = newCapacity + } - get leastFrequency () { - const freqCacheIterator = this.#frequencyMap.keys() - let leastFrequency = freqCacheIterator.next().value || null + get info () { + return Object.freeze({ + misses: this.misses, + hits: this.hits, + capacity: this.capacity, + currentSize: this.size, + leastFrequency: this.leastFrequency + }) + } - // select the non-empty frequency Set - while (this.#frequencyMap.get(leastFrequency)?.size === 0) { - leastFrequency = freqCacheIterator.next().value - } + get leastFrequency () { + const freqCacheIterator = this.#frequencyMap.keys() + let leastFrequency = freqCacheIterator.next().value || null - return leastFrequency + // select the non-empty frequency Set + while (this.#frequencyMap.get(leastFrequency)?.size === 0) { + leastFrequency = freqCacheIterator.next().value } - #removeCacheNode () { - const leastFreqSet = this.#frequencyMap.get(this.leastFrequency) - // Select the least recently used node from the least Frequency set - const LFUNode = leastFreqSet.values().next().value + return leastFrequency + } - leastFreqSet.delete(LFUNode) - this.cache.delete(LFUNode.key) - } + #removeCacheNode () { + const leastFreqSet = this.#frequencyMap.get(this.leastFrequency) + // Select the least recently used node from the least Frequency set + const LFUNode = leastFreqSet.values().next().value + + leastFreqSet.delete(LFUNode) + this.cache.delete(LFUNode.key) + } - /** + /** * if key exist then return true otherwise false * @param {any} key * @returns {boolean} */ - has (key) { - key = String(key) // converted to string + has (key) { + key = String(key) // converted to string - return this.cache.has(key) - } + return this.cache.has(key) + } - /** + /** * @method get * @description - This method return the value of key & refresh the frequencyMap by the oldNode * @param {string} key * @returns {any} */ - get (key) { - key = String(key) // converted to string + get (key) { + key = String(key) // converted to string - if (this.cache.has(key)) { - const oldNode = this.cache.get(key) - this.#frequencyMap.refresh(oldNode) + if (this.cache.has(key)) { + const oldNode = this.cache.get(key) + this.#frequencyMap.refresh(oldNode) - this.hits++ + this.hits++ - return oldNode.value - } - - this.misses++ - return null + return oldNode.value } - /** + this.misses++ + return null + } + + /** * @method set * @description - This method stored the value by key & add frequency if it doesn't exist * @param {string} key @@ -167,88 +167,88 @@ class LFUCache { * @param {number} frequency * @returns {LFUCache} */ - set (key, value, frequency = 1) { - key = String(key) // converted to string + set (key, value, frequency = 1) { + key = String(key) // converted to string - if (this.#capacity === 0) { - throw new RangeError('LFUCache ERROR: The Capacity is 0') - } + if (this.#capacity === 0) { + throw new RangeError('LFUCache ERROR: The Capacity is 0') + } - if (this.cache.has(key)) { - const node = this.cache.get(key) - node.value = value + if (this.cache.has(key)) { + const node = this.cache.get(key) + node.value = value - this.#frequencyMap.refresh(node) + this.#frequencyMap.refresh(node) - return this - } + return this + } - // if the cache size is full, then it's delete the Least Frequency Used node - if (this.#capacity === this.cache.size) { - this.#removeCacheNode() - } + // if the cache size is full, then it's delete the Least Frequency Used node + if (this.#capacity === this.cache.size) { + this.#removeCacheNode() + } - const newNode = new CacheNode(key, value, frequency) + const newNode = new CacheNode(key, value, frequency) - this.cache.set(key, newNode) - this.#frequencyMap.insert(newNode) + this.cache.set(key, newNode) + this.#frequencyMap.insert(newNode) - return this - } + return this + } - /** + /** * @method parse * @description - This method receive a valid LFUCache JSON & run JSON.prase() method and merge with existing LFUCache * @param {JSON} json * @returns {LFUCache} - merged */ - parse (json) { - const { misses, hits, cache } = JSON.parse(json) + parse (json) { + const { misses, hits, cache } = JSON.parse(json) - this.misses += misses ?? 0 - this.hits += hits ?? 0 + this.misses += misses ?? 0 + this.hits += hits ?? 0 - for (const key in cache) { - const { value, frequency } = cache[key] - this.set(key, value, frequency) - } - - return this + for (const key in cache) { + const { value, frequency } = cache[key] + this.set(key, value, frequency) } - /** + return this + } + + /** * @method clear * @description - This method cleared the whole LFUCache * @returns {LFUCache} */ - clear () { - this.cache.clear() - this.#frequencyMap.clear() + clear () { + this.cache.clear() + this.#frequencyMap.clear() - return this - } + return this + } - /** + /** * @method toString * @description - This method generate a JSON format of LFUCache & return it. * @param {number} indent * @returns {string} - JSON */ - toString (indent) { - const replacer = (_, value) => { - if (value instanceof Set) { - return [...value] - } - - if (value instanceof Map) { - return Object.fromEntries(value) - } + toString (indent) { + const replacer = (_, value) => { + if (value instanceof Set) { + return [...value] + } - return value + if (value instanceof Map) { + return Object.fromEntries(value) } - return JSON.stringify(this, replacer, indent) + return value } + + return JSON.stringify(this, replacer, indent) + } } export default LFUCache diff --git a/Maths/LeapYear.js b/Maths/LeapYear.js new file mode 100644 index 0000000000..bddcea7afc --- /dev/null +++ b/Maths/LeapYear.js @@ -0,0 +1,22 @@ +/** + * isLeapYear :: Number -> Boolean + * + * Check if a year is a leap year or not. A leap year is a year which has 366 days. + * For the extra +1 day the February month contains 29 days instead of 28 days. + * + * The logic behind the leap year is- + * 1. If the year is divisible by 400 then it is a leap year. + * 2. If it is not divisible by 400 but divisible by 100 then it is not a leap year. + * 3. If the year is not divisible by both 400 and 100 but divisible by 4 then a leap year. + * 4. Other cases except the describing ones are not a leap year. + * + * @param {number} year + * @returns {boolean} true if this is a leap year, false otherwise. + */ +export const isLeapYear = (year) => { + if (year % 400 === 0) return true + if (year % 100 === 0) return false + if (year % 4 === 0) return true + + return false +} diff --git a/Maths/test/LeapYear.test.js b/Maths/test/LeapYear.test.js new file mode 100644 index 0000000000..c30786c0e1 --- /dev/null +++ b/Maths/test/LeapYear.test.js @@ -0,0 +1,22 @@ +import { isLeapYear } from '../LeapYear' + +describe('Leap Year', () => { + it('Should return true on the year 2000', () => { + expect(isLeapYear(2000)).toBe(true) + }) + it('Should return false on the year 2001', () => { + expect(isLeapYear(2001)).toBe(false) + }) + it('Should return false on the year 2002', () => { + expect(isLeapYear(2002)).toBe(false) + }) + it('Should return false on the year 2003', () => { + expect(isLeapYear(2003)).toBe(false) + }) + it('Should return false on the year 2004', () => { + expect(isLeapYear(2004)).toBe(true) + }) + it('Should return false on the year 1900', () => { + expect(isLeapYear(1900)).toBe(false) + }) +}) From 4384739eddba2b6b6eec19dff1f4456247062c49 Mon Sep 17 00:00:00 2001 From: NJL0608 <108563587+NJL0608@users.noreply.github.com> Date: Fri, 26 Aug 2022 23:56:31 +0800 Subject: [PATCH 38/64] Update LFUCache.js --- Cache/LFUCache.js | 242 +++++++++++++++++++++++----------------------- 1 file changed, 121 insertions(+), 121 deletions(-) diff --git a/Cache/LFUCache.js b/Cache/LFUCache.js index c7ed906177..9bb08f6879 100644 --- a/Cache/LFUCache.js +++ b/Cache/LFUCache.js @@ -45,121 +45,121 @@ class FrequencyMap extends Map { } class LFUCache { - #capacity - #frequencyMap + #capacity + #frequencyMap - /** + /** * @param {number} capacity - The range of LFUCache * @returns {LFUCache} - sealed */ - constructor (capacity) { - this.#capacity = capacity - this.#frequencyMap = new FrequencyMap() - this.misses = 0 - this.hits = 0 - this.cache = new Map() - - return Object.seal(this) - } + constructor (capacity) { + this.#capacity = capacity + this.#frequencyMap = new FrequencyMap() + this.misses = 0 + this.hits = 0 + this.cache = new Map() + + return Object.seal(this) + } - /** + /** * Get the capacity of the LFUCache * @returns {number} */ - get capacity () { - return this.#capacity - } + get capacity () { + return this.#capacity + } - /** + /** * Get the current size of LFUCache * @returns {number} */ - get size () { - return this.cache.size - } + get size () { + return this.cache.size + } - /** + /** * Set the capacity of the LFUCache if you decrease the capacity its removed CacheNodes following the LFU - least frequency used */ - set capacity (newCapacity) { - if (this.#capacity > newCapacity) { - let diff = this.#capacity - newCapacity // get the decrement number of capacity + set capacity (newCapacity) { + if (this.#capacity > newCapacity) { + let diff = this.#capacity - newCapacity // get the decrement number of capacity - while (diff--) { - this.#removeCacheNode() + while (diff--) { + this.#removeCacheNode() + } + + this.cache.size === 0 && this.#frequencyMap.clear() } - this.cache.size === 0 && this.#frequencyMap.clear() + this.#capacity = newCapacity } - this.#capacity = newCapacity - } + get info () { + return Object.freeze({ + misses: this.misses, + hits: this.hits, + capacity: this.capacity, + currentSize: this.size, + leastFrequency: this.leastFrequency + }) + } - get info () { - return Object.freeze({ - misses: this.misses, - hits: this.hits, - capacity: this.capacity, - currentSize: this.size, - leastFrequency: this.leastFrequency - }) - } + get leastFrequency () { + const freqCacheIterator = this.#frequencyMap.keys() + let leastFrequency = freqCacheIterator.next().value || null - get leastFrequency () { - const freqCacheIterator = this.#frequencyMap.keys() - let leastFrequency = freqCacheIterator.next().value || null + // select the non-empty frequency Set + while (this.#frequencyMap.get(leastFrequency)?.size === 0) { + leastFrequency = freqCacheIterator.next().value + } - // select the non-empty frequency Set - while (this.#frequencyMap.get(leastFrequency)?.size === 0) { - leastFrequency = freqCacheIterator.next().value + return leastFrequency } - return leastFrequency - } + #removeCacheNode () { + const leastFreqSet = this.#frequencyMap.get(this.leastFrequency) + // Select the least recently used node from the least Frequency set + const LFUNode = leastFreqSet.values().next().value - #removeCacheNode () { - const leastFreqSet = this.#frequencyMap.get(this.leastFrequency) - // Select the least recently used node from the least Frequency set - const LFUNode = leastFreqSet.values().next().value - - leastFreqSet.delete(LFUNode) - this.cache.delete(LFUNode.key) - } + leastFreqSet.delete(LFUNode) + this.cache.delete(LFUNode.key) + } - /** + /** * if key exist then return true otherwise false * @param {any} key * @returns {boolean} */ - has (key) { - key = String(key) // converted to string + has (key) { + key = String(key) // converted to string - return this.cache.has(key) - } + return this.cache.has(key) + } - /** + /** * @method get * @description - This method return the value of key & refresh the frequencyMap by the oldNode * @param {string} key * @returns {any} */ - get (key) { - key = String(key) // converted to string + get (key) { + key = String(key) // converted to string - if (this.cache.has(key)) { - const oldNode = this.cache.get(key) - this.#frequencyMap.refresh(oldNode) + if (this.cache.has(key)) { + const oldNode = this.cache.get(key) + this.#frequencyMap.refresh(oldNode) - this.hits++ + this.hits++ - return oldNode.value - } + return oldNode.value + } - this.misses++ - return null - } + this.misses++ + return null + } - /** + /** * @method set * @description - This method stored the value by key & add frequency if it doesn't exist * @param {string} key @@ -167,88 +167,88 @@ class LFUCache { * @param {number} frequency * @returns {LFUCache} */ - set (key, value, frequency = 1) { - key = String(key) // converted to string + set (key, value, frequency = 1) { + key = String(key) // converted to string - if (this.#capacity === 0) { - throw new RangeError('LFUCache ERROR: The Capacity is 0') - } + if (this.#capacity === 0) { + throw new RangeError('LFUCache ERROR: The Capacity is 0') + } - if (this.cache.has(key)) { - const node = this.cache.get(key) - node.value = value + if (this.cache.has(key)) { + const node = this.cache.get(key) + node.value = value - this.#frequencyMap.refresh(node) + this.#frequencyMap.refresh(node) - return this - } + return this + } - // if the cache size is full, then it's delete the Least Frequency Used node - if (this.#capacity === this.cache.size) { - this.#removeCacheNode() - } + // if the cache size is full, then it's delete the Least Frequency Used node + if (this.#capacity === this.cache.size) { + this.#removeCacheNode() + } - const newNode = new CacheNode(key, value, frequency) + const newNode = new CacheNode(key, value, frequency) - this.cache.set(key, newNode) - this.#frequencyMap.insert(newNode) + this.cache.set(key, newNode) + this.#frequencyMap.insert(newNode) - return this - } + return this + } - /** + /** * @method parse * @description - This method receive a valid LFUCache JSON & run JSON.prase() method and merge with existing LFUCache * @param {JSON} json * @returns {LFUCache} - merged */ - parse (json) { - const { misses, hits, cache } = JSON.parse(json) + parse (json) { + const { misses, hits, cache } = JSON.parse(json) - this.misses += misses ?? 0 - this.hits += hits ?? 0 + this.misses += misses ?? 0 + this.hits += hits ?? 0 - for (const key in cache) { - const { value, frequency } = cache[key] - this.set(key, value, frequency) - } + for (const key in cache) { + const { value, frequency } = cache[key] + this.set(key, value, frequency) + } - return this - } + return this + } - /** + /** * @method clear * @description - This method cleared the whole LFUCache * @returns {LFUCache} */ - clear () { - this.cache.clear() - this.#frequencyMap.clear() + clear () { + this.cache.clear() + this.#frequencyMap.clear() - return this - } + return this + } - /** + /** * @method toString * @description - This method generate a JSON format of LFUCache & return it. * @param {number} indent * @returns {string} - JSON */ - toString (indent) { - const replacer = (_, value) => { - if (value instanceof Set) { - return [...value] - } + toString (indent) { + const replacer = (_, value) => { + if (value instanceof Set) { + return [...value] + } - if (value instanceof Map) { - return Object.fromEntries(value) + if (value instanceof Map) { + return Object.fromEntries(value) + } + + return value } - return value + return JSON.stringify(this, replacer, indent) } - - return JSON.stringify(this, replacer, indent) - } } export default LFUCache From cfb47dca3db32940342929d1455de22445c14893 Mon Sep 17 00:00:00 2001 From: Zhi Han <95157839+zzzhihan@users.noreply.github.com> Date: Sat, 27 Aug 2022 00:29:21 +0800 Subject: [PATCH 39/64] Add Triangle Perimeter --- Maths/FindTrianglePerimeter.js | 9 +++++++++ Maths/test/FindTrianglePerimeter.test.js | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 Maths/FindTrianglePerimeter.js create mode 100644 Maths/test/FindTrianglePerimeter.test.js diff --git a/Maths/FindTrianglePerimeter.js b/Maths/FindTrianglePerimeter.js new file mode 100644 index 0000000000..b4590d594a --- /dev/null +++ b/Maths/FindTrianglePerimeter.js @@ -0,0 +1,9 @@ +/* +* A polygon with three edges and three vertices is called a triangle. It is one of the fundamental geometric shapes. +* The total length of a triangle's sides makes up the perimeter. +* Algorithm to find the perimeter of a triangle +*/ +function findTrianglePerimeter (x, y, z) { + return x + y + z +} +export { findTrianglePerimeter } \ No newline at end of file diff --git a/Maths/test/FindTrianglePerimeter.test.js b/Maths/test/FindTrianglePerimeter.test.js new file mode 100644 index 0000000000..05400dbdcc --- /dev/null +++ b/Maths/test/FindTrianglePerimeter.test.js @@ -0,0 +1,19 @@ +import { findTrianglePerimeter } from '../FindTrianglePerimeter' + +describe('findTrianglePerimeter', () => { + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(5, 6, 4)).toBe(15) + }) + + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(2, 6, 5)).toBe(13) + }) + + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(7, 2, 6)).toBe(15) + }) + + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(6, 3, 8)).toBe(17) + }) +}) \ No newline at end of file From 092b48cced8e191c663dcdd2184300bac4a990f3 Mon Sep 17 00:00:00 2001 From: Zhi Han <95157839+zzzhihan@users.noreply.github.com> Date: Sat, 27 Aug 2022 13:50:04 +0800 Subject: [PATCH 40/64] Add Triangle Perimeter --- Maths/FindTrianglePerimeter.js | 2 +- Maths/test/FindTrianglePerimeter.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Maths/FindTrianglePerimeter.js b/Maths/FindTrianglePerimeter.js index b4590d594a..b64c7efdfb 100644 --- a/Maths/FindTrianglePerimeter.js +++ b/Maths/FindTrianglePerimeter.js @@ -6,4 +6,4 @@ function findTrianglePerimeter (x, y, z) { return x + y + z } -export { findTrianglePerimeter } \ No newline at end of file +export { findTrianglePerimeter } diff --git a/Maths/test/FindTrianglePerimeter.test.js b/Maths/test/FindTrianglePerimeter.test.js index 05400dbdcc..928776bb94 100644 --- a/Maths/test/FindTrianglePerimeter.test.js +++ b/Maths/test/FindTrianglePerimeter.test.js @@ -16,4 +16,4 @@ describe('findTrianglePerimeter', () => { it('should return the perimeter of a triangle', () => { expect(findTrianglePerimeter(6, 3, 8)).toBe(17) }) -}) \ No newline at end of file +}) From d198306f742e49a9de35c996e0fd5f955f186325 Mon Sep 17 00:00:00 2001 From: tehliang Date: Sun, 28 Aug 2022 17:35:41 +0800 Subject: [PATCH 41/64] Updated 2 CI --- .github/workflows/{JavascriptAlgoCL.yml => Codecov CI.yml} | 0 .github/workflows/{Ci.yml => Spelling, style and tests CI.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{JavascriptAlgoCL.yml => Codecov CI.yml} (100%) rename .github/workflows/{Ci.yml => Spelling, style and tests CI.yml} (100%) diff --git a/.github/workflows/JavascriptAlgoCL.yml b/.github/workflows/Codecov CI.yml similarity index 100% rename from .github/workflows/JavascriptAlgoCL.yml rename to .github/workflows/Codecov CI.yml diff --git a/.github/workflows/Ci.yml b/.github/workflows/Spelling, style and tests CI.yml similarity index 100% rename from .github/workflows/Ci.yml rename to .github/workflows/Spelling, style and tests CI.yml From 3f08be87ea336f1ae76ace65b50df6ebde3d50d0 Mon Sep 17 00:00:00 2001 From: tehliang Date: Sun, 28 Aug 2022 17:37:59 +0800 Subject: [PATCH 42/64] Update name for JavaScript Algorithm CI --- .github/workflows/Codecov CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Codecov CI.yml b/.github/workflows/Codecov CI.yml index e67ff5bf56..a61360c4de 100644 --- a/.github/workflows/Codecov CI.yml +++ b/.github/workflows/Codecov CI.yml @@ -1,7 +1,7 @@ # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions -name: Javascript Algorithm CI +name: Codecov CI on: [push, pull_request] From 563ba113e73534ef62add625d35e4b6b19f84ec5 Mon Sep 17 00:00:00 2001 From: tehliang Date: Sun, 28 Aug 2022 17:53:27 +0800 Subject: [PATCH 43/64] Added JugglerSequence --- Maths/JugglerSequence.js | 25 +++++++++++++++++++++++++ Maths/test/JugglerSequence.test.js | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Maths/JugglerSequence.js create mode 100644 Maths/test/JugglerSequence.test.js diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js new file mode 100644 index 0000000000..680f018a67 --- /dev/null +++ b/Maths/JugglerSequence.js @@ -0,0 +1,25 @@ +/* + * Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence + * function jugglerSequence + * Juggler Sequence is a series of integer number in which the first term starts with a positive integer number n + * and the remaining terms are generated from the immediate previous term using the recurrence relation + * Produce Juggler Sequence using number n as the first term of the sequence and store in an array + * Reference: https://www.geeksforgeeks.org/juggler-sequence/ + * jugglerSequence(3) // returns [3, 5, 11, 36, 6, 2, 1 ] + * jugglerSequence(9) // returns [9, 27, 140, 11, 36, 6, 2, 1] + * jugglerSequence(15) // returns [15, 58, 7, 18, 4, 2, 1] + */ + +function jugglerSequence (n) { + const sequence = [] + sequence.push(n) + // Calculate terms until last term is not 1 + while (n !== 1) { + n = Math.floor(n ** ((n % 2) + 0.5)) + sequence.push(n) + } + return sequence +} + +export { jugglerSequence } + diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js new file mode 100644 index 0000000000..219307839a --- /dev/null +++ b/Maths/test/JugglerSequence.test.js @@ -0,0 +1,21 @@ +import { jugglerSequence } from '../JugglerSequence' + +describe('Testing jugglerSequence function', () => { + it('should return [3, 5, 11, 36, 6, 2, 1 ] if the number is 3', () => { + expect(jugglerSequence(3)).toEqual( + expect.arrayContaining([3, 5, 11, 36, 6, 2, 1]) + ) + }) + + it('should return [9, 27, 140, 11, 36, 6, 2, 1] if the number is 9', () => { + expect(jugglerSequence(9)).toEqual( + expect.arrayContaining([9, 27, 140, 11, 36, 6, 2, 1]) + ) + }) + + it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { + expect(jugglerSequence(15)).toEqual( + expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) + ) + }) +}) \ No newline at end of file From 90f3e519dcad5a55293e6968a03ca3e63046c6d9 Mon Sep 17 00:00:00 2001 From: tehliang Date: Sun, 28 Aug 2022 18:02:54 +0800 Subject: [PATCH 44/64] Fixed JavaScript Errors --- Maths/JugglerSequence.js | 1 - Maths/test/JugglerSequence.test.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js index 680f018a67..96a2a35150 100644 --- a/Maths/JugglerSequence.js +++ b/Maths/JugglerSequence.js @@ -22,4 +22,3 @@ function jugglerSequence (n) { } export { jugglerSequence } - diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js index 219307839a..b6dc313b8c 100644 --- a/Maths/test/JugglerSequence.test.js +++ b/Maths/test/JugglerSequence.test.js @@ -15,7 +15,7 @@ describe('Testing jugglerSequence function', () => { it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { expect(jugglerSequence(15)).toEqual( - expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) + expect.arrayContaining([15, 58, 7, 18, 4, 2, 0]) ) }) -}) \ No newline at end of file +}) From 7ea9c1b08012ec14655926888533f3c2b6ae9dd4 Mon Sep 17 00:00:00 2001 From: tehliang Date: Sun, 28 Aug 2022 18:09:14 +0800 Subject: [PATCH 45/64] Update the test script --- Maths/test/JugglerSequence.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js index b6dc313b8c..392047a95b 100644 --- a/Maths/test/JugglerSequence.test.js +++ b/Maths/test/JugglerSequence.test.js @@ -15,7 +15,7 @@ describe('Testing jugglerSequence function', () => { it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { expect(jugglerSequence(15)).toEqual( - expect.arrayContaining([15, 58, 7, 18, 4, 2, 0]) + expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) ) }) }) From 4e0314f3e1e653d00a6c58b3d72e04e12569ee74 Mon Sep 17 00:00:00 2001 From: Chingye97 Date: Mon, 29 Aug 2022 02:12:01 +0800 Subject: [PATCH 46/64] addCollatSequence --- Maths/CollatzSequence.js | 30 ++++++++++++++++++++++++++++++ Maths/test/CollatzSequence.test.js | 8 ++++++++ 2 files changed, 38 insertions(+) create mode 100644 Maths/CollatzSequence.js create mode 100644 Maths/test/CollatzSequence.test.js diff --git a/Maths/CollatzSequence.js b/Maths/CollatzSequence.js new file mode 100644 index 0000000000..66fcc78e1a --- /dev/null +++ b/Maths/CollatzSequence.js @@ -0,0 +1,30 @@ +/** + * @function collatz + * @description Applies the Collatz Sequence on a specified number. + * The Collatz Sequence states that every natural number will always fall in a 1, 2, 4 loop when iterated under the following function: + * If the number is even, divide by 2, and if its odd, multiply it by 3 and add 1. + * + * @parama {Integer} n The number to apply the Collatz Sequence to. + * + * @return An array of steps and the final result.. + * + * @see [Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) + * + * @example collatz(1) = { result: 1, steps: [] } + * @example collatz(5) = { result: 1, steps: [16, 8, 4, 2, 1] } +*/ +export function collatz (n) { + const steps = [] + + while (n !== 1) { + if (n % 2 === 0) { + n = n / 2 + } else { + n = 3 * n + 1 + } + + steps.push(n) + } + + return { result: n, steps: steps } +} \ No newline at end of file diff --git a/Maths/test/CollatzSequence.test.js b/Maths/test/CollatzSequence.test.js new file mode 100644 index 0000000000..67aeb0c509 --- /dev/null +++ b/Maths/test/CollatzSequence.test.js @@ -0,0 +1,8 @@ +import { collatz } from '../CollatzSequence' + +describe('The Collatz Sequence', () => { + it('Should be 1', () => { + expect(collatz(1)).toStrictEqual({ result: 1, steps: [] }) + expect(collatz(5)).toStrictEqual({ result: 1, steps: [16, 8, 4, 2, 1] }) + }) +}) \ No newline at end of file From b0ccd99ffe431d0743e62e4490413a43703957fa Mon Sep 17 00:00:00 2001 From: Chingye97 Date: Mon, 29 Aug 2022 12:39:35 +0800 Subject: [PATCH 47/64] add Collatz Sequence --- Maths/CollatzSequence.js | 5 ++--- Maths/test/CollatzSequence.test.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Maths/CollatzSequence.js b/Maths/CollatzSequence.js index 66fcc78e1a..29fda8a8e1 100644 --- a/Maths/CollatzSequence.js +++ b/Maths/CollatzSequence.js @@ -8,14 +8,13 @@ * * @return An array of steps and the final result.. * - * @see [Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) + * @see (Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) * * @example collatz(1) = { result: 1, steps: [] } * @example collatz(5) = { result: 1, steps: [16, 8, 4, 2, 1] } */ export function collatz (n) { const steps = [] - while (n !== 1) { if (n % 2 === 0) { n = n / 2 @@ -27,4 +26,4 @@ export function collatz (n) { } return { result: n, steps: steps } -} \ No newline at end of file +} diff --git a/Maths/test/CollatzSequence.test.js b/Maths/test/CollatzSequence.test.js index 67aeb0c509..f837bd90d7 100644 --- a/Maths/test/CollatzSequence.test.js +++ b/Maths/test/CollatzSequence.test.js @@ -5,4 +5,4 @@ describe('The Collatz Sequence', () => { expect(collatz(1)).toStrictEqual({ result: 1, steps: [] }) expect(collatz(5)).toStrictEqual({ result: 1, steps: [16, 8, 4, 2, 1] }) }) -}) \ No newline at end of file +}) From 6d997cac98aca3446e360b3bd3f1dd423368416a Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 12:47:59 +0800 Subject: [PATCH 48/64] Revert "Add LeapYear.js" --- Maths/LeapYear.js | 22 ---------------------- Maths/test/LeapYear.test.js | 22 ---------------------- 2 files changed, 44 deletions(-) delete mode 100644 Maths/LeapYear.js delete mode 100644 Maths/test/LeapYear.test.js diff --git a/Maths/LeapYear.js b/Maths/LeapYear.js deleted file mode 100644 index bddcea7afc..0000000000 --- a/Maths/LeapYear.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * isLeapYear :: Number -> Boolean - * - * Check if a year is a leap year or not. A leap year is a year which has 366 days. - * For the extra +1 day the February month contains 29 days instead of 28 days. - * - * The logic behind the leap year is- - * 1. If the year is divisible by 400 then it is a leap year. - * 2. If it is not divisible by 400 but divisible by 100 then it is not a leap year. - * 3. If the year is not divisible by both 400 and 100 but divisible by 4 then a leap year. - * 4. Other cases except the describing ones are not a leap year. - * - * @param {number} year - * @returns {boolean} true if this is a leap year, false otherwise. - */ -export const isLeapYear = (year) => { - if (year % 400 === 0) return true - if (year % 100 === 0) return false - if (year % 4 === 0) return true - - return false -} diff --git a/Maths/test/LeapYear.test.js b/Maths/test/LeapYear.test.js deleted file mode 100644 index c30786c0e1..0000000000 --- a/Maths/test/LeapYear.test.js +++ /dev/null @@ -1,22 +0,0 @@ -import { isLeapYear } from '../LeapYear' - -describe('Leap Year', () => { - it('Should return true on the year 2000', () => { - expect(isLeapYear(2000)).toBe(true) - }) - it('Should return false on the year 2001', () => { - expect(isLeapYear(2001)).toBe(false) - }) - it('Should return false on the year 2002', () => { - expect(isLeapYear(2002)).toBe(false) - }) - it('Should return false on the year 2003', () => { - expect(isLeapYear(2003)).toBe(false) - }) - it('Should return false on the year 2004', () => { - expect(isLeapYear(2004)).toBe(true) - }) - it('Should return false on the year 1900', () => { - expect(isLeapYear(1900)).toBe(false) - }) -}) From c2c701f0e1f1a7f88a1e1581c2664e54d19829f1 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 12:49:23 +0800 Subject: [PATCH 49/64] Revert "Added PythagoreanTheorem.js" --- Maths/PythagoreanTheorem.js | 39 --------------------------- Maths/test/PythagoreanTheorem.test.js | 23 ---------------- 2 files changed, 62 deletions(-) delete mode 100644 Maths/PythagoreanTheorem.js delete mode 100644 Maths/test/PythagoreanTheorem.test.js diff --git a/Maths/PythagoreanTheorem.js b/Maths/PythagoreanTheorem.js deleted file mode 100644 index 0a6752ec31..0000000000 --- a/Maths/PythagoreanTheorem.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @function calcHypotenuse - * @description Calculate the hypothenuse of a triangle. - * @param {Integer} base - Integer - * @param {Integer} adjacent - Integer - * @return {Integer} - hypotenuse - * @see [calcHypotenuse](https://en.wikipedia.org/wiki/Pythagorean_theorem) - * @example calcHypotenuse(6,8) = 10 - */ -const calcHypotenuse = (base, adjacent) => { - const hypotenuse = Math.sqrt(base ** 2 + adjacent ** 2) - return hypotenuse -} - -/** - * @function calcOtherSides - * @description Calculate the other sides of a triangle. - * @param {Integer} side1 - Integer - * @param {Integer} side2 - Integer - * @return {Integer} - sides - * @see [calcOtherSides](https://en.wikipedia.org/wiki/Pythagorean_theorem) - * @example calcOtherSides(6,10) = 8 - */ -const calcOtherSides = (side1, side2) => { - if (side1 > side2) { - const side = Math.sqrt(side1 ** 2 - side2 ** 2) - return side - } else if (side2 > side1) { - const side = Math.sqrt(side2 ** 2 - side1 ** 2) - return side - } - - return 'Both sides cannot be the same value' -} - -export { - calcHypotenuse, - calcOtherSides -} diff --git a/Maths/test/PythagoreanTheorem.test.js b/Maths/test/PythagoreanTheorem.test.js deleted file mode 100644 index 4607b5a3b3..0000000000 --- a/Maths/test/PythagoreanTheorem.test.js +++ /dev/null @@ -1,23 +0,0 @@ -import * as py from '../PythagoreanTheorem' - -describe('Testing calcHypotenuse calculations', () => { - it('with natural number', () => { - const result = py.calcHypotenuse(6, 8) - expect(result).toBe(10) - }) -}) - -describe('Testing calcOtherSides calculations', () => { - it('with side1 bigger than side2', () => { - const result = py.calcOtherSides(6, 10) - expect(result).toBe(8) - }) - it('with side2 bigger than side1', () => { - const result = py.calcOtherSides(10, 6) - expect(result).toBe(8) - }) - it('with side1 equals side2', () => { - const result = py.calcOtherSides(10, 10) - expect(result).toBe('Both sides cannot be the same value') - }) -}) From 4ad68ae80d573c3522bac949b7e1c8c1afb37c15 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:03:27 +0800 Subject: [PATCH 50/64] Revert "Added JugglerSequence" --- Maths/JugglerSequence.js | 24 ------------------------ Maths/test/JugglerSequence.test.js | 21 --------------------- 2 files changed, 45 deletions(-) delete mode 100644 Maths/JugglerSequence.js delete mode 100644 Maths/test/JugglerSequence.test.js diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js deleted file mode 100644 index 96a2a35150..0000000000 --- a/Maths/JugglerSequence.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence - * function jugglerSequence - * Juggler Sequence is a series of integer number in which the first term starts with a positive integer number n - * and the remaining terms are generated from the immediate previous term using the recurrence relation - * Produce Juggler Sequence using number n as the first term of the sequence and store in an array - * Reference: https://www.geeksforgeeks.org/juggler-sequence/ - * jugglerSequence(3) // returns [3, 5, 11, 36, 6, 2, 1 ] - * jugglerSequence(9) // returns [9, 27, 140, 11, 36, 6, 2, 1] - * jugglerSequence(15) // returns [15, 58, 7, 18, 4, 2, 1] - */ - -function jugglerSequence (n) { - const sequence = [] - sequence.push(n) - // Calculate terms until last term is not 1 - while (n !== 1) { - n = Math.floor(n ** ((n % 2) + 0.5)) - sequence.push(n) - } - return sequence -} - -export { jugglerSequence } diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js deleted file mode 100644 index 392047a95b..0000000000 --- a/Maths/test/JugglerSequence.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { jugglerSequence } from '../JugglerSequence' - -describe('Testing jugglerSequence function', () => { - it('should return [3, 5, 11, 36, 6, 2, 1 ] if the number is 3', () => { - expect(jugglerSequence(3)).toEqual( - expect.arrayContaining([3, 5, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [9, 27, 140, 11, 36, 6, 2, 1] if the number is 9', () => { - expect(jugglerSequence(9)).toEqual( - expect.arrayContaining([9, 27, 140, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { - expect(jugglerSequence(15)).toEqual( - expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) - ) - }) -}) From 2c6e545c176695e86e2df562666faf2ed3e32aed Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:07:03 +0800 Subject: [PATCH 51/64] Revert "Revert "Added JugglerSequence"" --- Maths/JugglerSequence.js | 24 ++++++++++++++++++++++++ Maths/test/JugglerSequence.test.js | 21 +++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Maths/JugglerSequence.js create mode 100644 Maths/test/JugglerSequence.test.js diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js new file mode 100644 index 0000000000..96a2a35150 --- /dev/null +++ b/Maths/JugglerSequence.js @@ -0,0 +1,24 @@ +/* + * Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence + * function jugglerSequence + * Juggler Sequence is a series of integer number in which the first term starts with a positive integer number n + * and the remaining terms are generated from the immediate previous term using the recurrence relation + * Produce Juggler Sequence using number n as the first term of the sequence and store in an array + * Reference: https://www.geeksforgeeks.org/juggler-sequence/ + * jugglerSequence(3) // returns [3, 5, 11, 36, 6, 2, 1 ] + * jugglerSequence(9) // returns [9, 27, 140, 11, 36, 6, 2, 1] + * jugglerSequence(15) // returns [15, 58, 7, 18, 4, 2, 1] + */ + +function jugglerSequence (n) { + const sequence = [] + sequence.push(n) + // Calculate terms until last term is not 1 + while (n !== 1) { + n = Math.floor(n ** ((n % 2) + 0.5)) + sequence.push(n) + } + return sequence +} + +export { jugglerSequence } diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js new file mode 100644 index 0000000000..392047a95b --- /dev/null +++ b/Maths/test/JugglerSequence.test.js @@ -0,0 +1,21 @@ +import { jugglerSequence } from '../JugglerSequence' + +describe('Testing jugglerSequence function', () => { + it('should return [3, 5, 11, 36, 6, 2, 1 ] if the number is 3', () => { + expect(jugglerSequence(3)).toEqual( + expect.arrayContaining([3, 5, 11, 36, 6, 2, 1]) + ) + }) + + it('should return [9, 27, 140, 11, 36, 6, 2, 1] if the number is 9', () => { + expect(jugglerSequence(9)).toEqual( + expect.arrayContaining([9, 27, 140, 11, 36, 6, 2, 1]) + ) + }) + + it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { + expect(jugglerSequence(15)).toEqual( + expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) + ) + }) +}) From f6d29f647ceabc5a131e216249b10a7146cb1c72 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:13:14 +0800 Subject: [PATCH 52/64] Revert "Add triangle perimeter" --- Maths/FindTrianglePerimeter.js | 9 --------- Maths/test/FindTrianglePerimeter.test.js | 19 ------------------- 2 files changed, 28 deletions(-) delete mode 100644 Maths/FindTrianglePerimeter.js delete mode 100644 Maths/test/FindTrianglePerimeter.test.js diff --git a/Maths/FindTrianglePerimeter.js b/Maths/FindTrianglePerimeter.js deleted file mode 100644 index b64c7efdfb..0000000000 --- a/Maths/FindTrianglePerimeter.js +++ /dev/null @@ -1,9 +0,0 @@ -/* -* A polygon with three edges and three vertices is called a triangle. It is one of the fundamental geometric shapes. -* The total length of a triangle's sides makes up the perimeter. -* Algorithm to find the perimeter of a triangle -*/ -function findTrianglePerimeter (x, y, z) { - return x + y + z -} -export { findTrianglePerimeter } diff --git a/Maths/test/FindTrianglePerimeter.test.js b/Maths/test/FindTrianglePerimeter.test.js deleted file mode 100644 index 928776bb94..0000000000 --- a/Maths/test/FindTrianglePerimeter.test.js +++ /dev/null @@ -1,19 +0,0 @@ -import { findTrianglePerimeter } from '../FindTrianglePerimeter' - -describe('findTrianglePerimeter', () => { - it('should return the perimeter of a triangle', () => { - expect(findTrianglePerimeter(5, 6, 4)).toBe(15) - }) - - it('should return the perimeter of a triangle', () => { - expect(findTrianglePerimeter(2, 6, 5)).toBe(13) - }) - - it('should return the perimeter of a triangle', () => { - expect(findTrianglePerimeter(7, 2, 6)).toBe(15) - }) - - it('should return the perimeter of a triangle', () => { - expect(findTrianglePerimeter(6, 3, 8)).toBe(17) - }) -}) From 52f5b3160298bfc8933475b514a31af253b0d67c Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:13:50 +0800 Subject: [PATCH 53/64] Revert "Revert "Revert "Added JugglerSequence""" --- Maths/JugglerSequence.js | 24 ------------------------ Maths/test/JugglerSequence.test.js | 21 --------------------- 2 files changed, 45 deletions(-) delete mode 100644 Maths/JugglerSequence.js delete mode 100644 Maths/test/JugglerSequence.test.js diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js deleted file mode 100644 index 96a2a35150..0000000000 --- a/Maths/JugglerSequence.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence - * function jugglerSequence - * Juggler Sequence is a series of integer number in which the first term starts with a positive integer number n - * and the remaining terms are generated from the immediate previous term using the recurrence relation - * Produce Juggler Sequence using number n as the first term of the sequence and store in an array - * Reference: https://www.geeksforgeeks.org/juggler-sequence/ - * jugglerSequence(3) // returns [3, 5, 11, 36, 6, 2, 1 ] - * jugglerSequence(9) // returns [9, 27, 140, 11, 36, 6, 2, 1] - * jugglerSequence(15) // returns [15, 58, 7, 18, 4, 2, 1] - */ - -function jugglerSequence (n) { - const sequence = [] - sequence.push(n) - // Calculate terms until last term is not 1 - while (n !== 1) { - n = Math.floor(n ** ((n % 2) + 0.5)) - sequence.push(n) - } - return sequence -} - -export { jugglerSequence } diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js deleted file mode 100644 index 392047a95b..0000000000 --- a/Maths/test/JugglerSequence.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { jugglerSequence } from '../JugglerSequence' - -describe('Testing jugglerSequence function', () => { - it('should return [3, 5, 11, 36, 6, 2, 1 ] if the number is 3', () => { - expect(jugglerSequence(3)).toEqual( - expect.arrayContaining([3, 5, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [9, 27, 140, 11, 36, 6, 2, 1] if the number is 9', () => { - expect(jugglerSequence(9)).toEqual( - expect.arrayContaining([9, 27, 140, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { - expect(jugglerSequence(15)).toEqual( - expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) - ) - }) -}) From e02935aa9e9f46abda003a84b3152fd397b63e62 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:14:15 +0800 Subject: [PATCH 54/64] Revert "AddCollatSequence" --- Maths/CollatzSequence.js | 29 ----------------------------- Maths/test/CollatzSequence.test.js | 8 -------- 2 files changed, 37 deletions(-) delete mode 100644 Maths/CollatzSequence.js delete mode 100644 Maths/test/CollatzSequence.test.js diff --git a/Maths/CollatzSequence.js b/Maths/CollatzSequence.js deleted file mode 100644 index 29fda8a8e1..0000000000 --- a/Maths/CollatzSequence.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @function collatz - * @description Applies the Collatz Sequence on a specified number. - * The Collatz Sequence states that every natural number will always fall in a 1, 2, 4 loop when iterated under the following function: - * If the number is even, divide by 2, and if its odd, multiply it by 3 and add 1. - * - * @parama {Integer} n The number to apply the Collatz Sequence to. - * - * @return An array of steps and the final result.. - * - * @see (Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) - * - * @example collatz(1) = { result: 1, steps: [] } - * @example collatz(5) = { result: 1, steps: [16, 8, 4, 2, 1] } -*/ -export function collatz (n) { - const steps = [] - while (n !== 1) { - if (n % 2 === 0) { - n = n / 2 - } else { - n = 3 * n + 1 - } - - steps.push(n) - } - - return { result: n, steps: steps } -} diff --git a/Maths/test/CollatzSequence.test.js b/Maths/test/CollatzSequence.test.js deleted file mode 100644 index f837bd90d7..0000000000 --- a/Maths/test/CollatzSequence.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import { collatz } from '../CollatzSequence' - -describe('The Collatz Sequence', () => { - it('Should be 1', () => { - expect(collatz(1)).toStrictEqual({ result: 1, steps: [] }) - expect(collatz(5)).toStrictEqual({ result: 1, steps: [16, 8, 4, 2, 1] }) - }) -}) From 01b55e15c44e4feb038cd9c68f5a79d7dd3d2d83 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:23:57 +0800 Subject: [PATCH 55/64] Revert "Revert "Added PythagoreanTheorem.js"" --- Maths/PythagoreanTheorem.js | 39 +++++++++++++++++++++++++++ Maths/test/PythagoreanTheorem.test.js | 23 ++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 Maths/PythagoreanTheorem.js create mode 100644 Maths/test/PythagoreanTheorem.test.js diff --git a/Maths/PythagoreanTheorem.js b/Maths/PythagoreanTheorem.js new file mode 100644 index 0000000000..0a6752ec31 --- /dev/null +++ b/Maths/PythagoreanTheorem.js @@ -0,0 +1,39 @@ +/** + * @function calcHypotenuse + * @description Calculate the hypothenuse of a triangle. + * @param {Integer} base - Integer + * @param {Integer} adjacent - Integer + * @return {Integer} - hypotenuse + * @see [calcHypotenuse](https://en.wikipedia.org/wiki/Pythagorean_theorem) + * @example calcHypotenuse(6,8) = 10 + */ +const calcHypotenuse = (base, adjacent) => { + const hypotenuse = Math.sqrt(base ** 2 + adjacent ** 2) + return hypotenuse +} + +/** + * @function calcOtherSides + * @description Calculate the other sides of a triangle. + * @param {Integer} side1 - Integer + * @param {Integer} side2 - Integer + * @return {Integer} - sides + * @see [calcOtherSides](https://en.wikipedia.org/wiki/Pythagorean_theorem) + * @example calcOtherSides(6,10) = 8 + */ +const calcOtherSides = (side1, side2) => { + if (side1 > side2) { + const side = Math.sqrt(side1 ** 2 - side2 ** 2) + return side + } else if (side2 > side1) { + const side = Math.sqrt(side2 ** 2 - side1 ** 2) + return side + } + + return 'Both sides cannot be the same value' +} + +export { + calcHypotenuse, + calcOtherSides +} diff --git a/Maths/test/PythagoreanTheorem.test.js b/Maths/test/PythagoreanTheorem.test.js new file mode 100644 index 0000000000..4607b5a3b3 --- /dev/null +++ b/Maths/test/PythagoreanTheorem.test.js @@ -0,0 +1,23 @@ +import * as py from '../PythagoreanTheorem' + +describe('Testing calcHypotenuse calculations', () => { + it('with natural number', () => { + const result = py.calcHypotenuse(6, 8) + expect(result).toBe(10) + }) +}) + +describe('Testing calcOtherSides calculations', () => { + it('with side1 bigger than side2', () => { + const result = py.calcOtherSides(6, 10) + expect(result).toBe(8) + }) + it('with side2 bigger than side1', () => { + const result = py.calcOtherSides(10, 6) + expect(result).toBe(8) + }) + it('with side1 equals side2', () => { + const result = py.calcOtherSides(10, 10) + expect(result).toBe('Both sides cannot be the same value') + }) +}) From 77cfdbc34145c6177731953296d2aacc569093de Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:24:08 +0800 Subject: [PATCH 56/64] Revert "Revert "Add LeapYear.js"" --- Maths/LeapYear.js | 22 ++++++++++++++++++++++ Maths/test/LeapYear.test.js | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 Maths/LeapYear.js create mode 100644 Maths/test/LeapYear.test.js diff --git a/Maths/LeapYear.js b/Maths/LeapYear.js new file mode 100644 index 0000000000..bddcea7afc --- /dev/null +++ b/Maths/LeapYear.js @@ -0,0 +1,22 @@ +/** + * isLeapYear :: Number -> Boolean + * + * Check if a year is a leap year or not. A leap year is a year which has 366 days. + * For the extra +1 day the February month contains 29 days instead of 28 days. + * + * The logic behind the leap year is- + * 1. If the year is divisible by 400 then it is a leap year. + * 2. If it is not divisible by 400 but divisible by 100 then it is not a leap year. + * 3. If the year is not divisible by both 400 and 100 but divisible by 4 then a leap year. + * 4. Other cases except the describing ones are not a leap year. + * + * @param {number} year + * @returns {boolean} true if this is a leap year, false otherwise. + */ +export const isLeapYear = (year) => { + if (year % 400 === 0) return true + if (year % 100 === 0) return false + if (year % 4 === 0) return true + + return false +} diff --git a/Maths/test/LeapYear.test.js b/Maths/test/LeapYear.test.js new file mode 100644 index 0000000000..c30786c0e1 --- /dev/null +++ b/Maths/test/LeapYear.test.js @@ -0,0 +1,22 @@ +import { isLeapYear } from '../LeapYear' + +describe('Leap Year', () => { + it('Should return true on the year 2000', () => { + expect(isLeapYear(2000)).toBe(true) + }) + it('Should return false on the year 2001', () => { + expect(isLeapYear(2001)).toBe(false) + }) + it('Should return false on the year 2002', () => { + expect(isLeapYear(2002)).toBe(false) + }) + it('Should return false on the year 2003', () => { + expect(isLeapYear(2003)).toBe(false) + }) + it('Should return false on the year 2004', () => { + expect(isLeapYear(2004)).toBe(true) + }) + it('Should return false on the year 1900', () => { + expect(isLeapYear(1900)).toBe(false) + }) +}) From eb520bf55f0b1d0bc5fea50e9855a497659da24a Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:24:14 +0800 Subject: [PATCH 57/64] Revert "Revert "Add triangle perimeter"" --- Maths/FindTrianglePerimeter.js | 9 +++++++++ Maths/test/FindTrianglePerimeter.test.js | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 Maths/FindTrianglePerimeter.js create mode 100644 Maths/test/FindTrianglePerimeter.test.js diff --git a/Maths/FindTrianglePerimeter.js b/Maths/FindTrianglePerimeter.js new file mode 100644 index 0000000000..b64c7efdfb --- /dev/null +++ b/Maths/FindTrianglePerimeter.js @@ -0,0 +1,9 @@ +/* +* A polygon with three edges and three vertices is called a triangle. It is one of the fundamental geometric shapes. +* The total length of a triangle's sides makes up the perimeter. +* Algorithm to find the perimeter of a triangle +*/ +function findTrianglePerimeter (x, y, z) { + return x + y + z +} +export { findTrianglePerimeter } diff --git a/Maths/test/FindTrianglePerimeter.test.js b/Maths/test/FindTrianglePerimeter.test.js new file mode 100644 index 0000000000..928776bb94 --- /dev/null +++ b/Maths/test/FindTrianglePerimeter.test.js @@ -0,0 +1,19 @@ +import { findTrianglePerimeter } from '../FindTrianglePerimeter' + +describe('findTrianglePerimeter', () => { + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(5, 6, 4)).toBe(15) + }) + + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(2, 6, 5)).toBe(13) + }) + + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(7, 2, 6)).toBe(15) + }) + + it('should return the perimeter of a triangle', () => { + expect(findTrianglePerimeter(6, 3, 8)).toBe(17) + }) +}) From b752b514eac523bd01e509b35dfa6271be2443f0 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:24:22 +0800 Subject: [PATCH 58/64] Revert "Revert "Revert "Revert "Added JugglerSequence"""" --- Maths/JugglerSequence.js | 24 ++++++++++++++++++++++++ Maths/test/JugglerSequence.test.js | 21 +++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Maths/JugglerSequence.js create mode 100644 Maths/test/JugglerSequence.test.js diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js new file mode 100644 index 0000000000..96a2a35150 --- /dev/null +++ b/Maths/JugglerSequence.js @@ -0,0 +1,24 @@ +/* + * Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence + * function jugglerSequence + * Juggler Sequence is a series of integer number in which the first term starts with a positive integer number n + * and the remaining terms are generated from the immediate previous term using the recurrence relation + * Produce Juggler Sequence using number n as the first term of the sequence and store in an array + * Reference: https://www.geeksforgeeks.org/juggler-sequence/ + * jugglerSequence(3) // returns [3, 5, 11, 36, 6, 2, 1 ] + * jugglerSequence(9) // returns [9, 27, 140, 11, 36, 6, 2, 1] + * jugglerSequence(15) // returns [15, 58, 7, 18, 4, 2, 1] + */ + +function jugglerSequence (n) { + const sequence = [] + sequence.push(n) + // Calculate terms until last term is not 1 + while (n !== 1) { + n = Math.floor(n ** ((n % 2) + 0.5)) + sequence.push(n) + } + return sequence +} + +export { jugglerSequence } diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js new file mode 100644 index 0000000000..392047a95b --- /dev/null +++ b/Maths/test/JugglerSequence.test.js @@ -0,0 +1,21 @@ +import { jugglerSequence } from '../JugglerSequence' + +describe('Testing jugglerSequence function', () => { + it('should return [3, 5, 11, 36, 6, 2, 1 ] if the number is 3', () => { + expect(jugglerSequence(3)).toEqual( + expect.arrayContaining([3, 5, 11, 36, 6, 2, 1]) + ) + }) + + it('should return [9, 27, 140, 11, 36, 6, 2, 1] if the number is 9', () => { + expect(jugglerSequence(9)).toEqual( + expect.arrayContaining([9, 27, 140, 11, 36, 6, 2, 1]) + ) + }) + + it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { + expect(jugglerSequence(15)).toEqual( + expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) + ) + }) +}) From bad79934448e255355487b90e5c0ded960f32556 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 13:24:29 +0800 Subject: [PATCH 59/64] Revert "Revert "AddCollatSequence"" --- Maths/CollatzSequence.js | 29 +++++++++++++++++++++++++++++ Maths/test/CollatzSequence.test.js | 8 ++++++++ 2 files changed, 37 insertions(+) create mode 100644 Maths/CollatzSequence.js create mode 100644 Maths/test/CollatzSequence.test.js diff --git a/Maths/CollatzSequence.js b/Maths/CollatzSequence.js new file mode 100644 index 0000000000..29fda8a8e1 --- /dev/null +++ b/Maths/CollatzSequence.js @@ -0,0 +1,29 @@ +/** + * @function collatz + * @description Applies the Collatz Sequence on a specified number. + * The Collatz Sequence states that every natural number will always fall in a 1, 2, 4 loop when iterated under the following function: + * If the number is even, divide by 2, and if its odd, multiply it by 3 and add 1. + * + * @parama {Integer} n The number to apply the Collatz Sequence to. + * + * @return An array of steps and the final result.. + * + * @see (Collatz Conjecture](https://en.wikipedia.org/wiki/Collatz_conjecture) + * + * @example collatz(1) = { result: 1, steps: [] } + * @example collatz(5) = { result: 1, steps: [16, 8, 4, 2, 1] } +*/ +export function collatz (n) { + const steps = [] + while (n !== 1) { + if (n % 2 === 0) { + n = n / 2 + } else { + n = 3 * n + 1 + } + + steps.push(n) + } + + return { result: n, steps: steps } +} diff --git a/Maths/test/CollatzSequence.test.js b/Maths/test/CollatzSequence.test.js new file mode 100644 index 0000000000..f837bd90d7 --- /dev/null +++ b/Maths/test/CollatzSequence.test.js @@ -0,0 +1,8 @@ +import { collatz } from '../CollatzSequence' + +describe('The Collatz Sequence', () => { + it('Should be 1', () => { + expect(collatz(1)).toStrictEqual({ result: 1, steps: [] }) + expect(collatz(5)).toStrictEqual({ result: 1, steps: [16, 8, 4, 2, 1] }) + }) +}) From 32a021583a46cb6af91145a7aad607a8223afbd9 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 19:15:49 +0800 Subject: [PATCH 60/64] Delete JugglerSequence.js --- Maths/JugglerSequence.js | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 Maths/JugglerSequence.js diff --git a/Maths/JugglerSequence.js b/Maths/JugglerSequence.js deleted file mode 100644 index 96a2a35150..0000000000 --- a/Maths/JugglerSequence.js +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Juggler Sequence: https://en.wikipedia.org/wiki/Juggler_sequence - * function jugglerSequence - * Juggler Sequence is a series of integer number in which the first term starts with a positive integer number n - * and the remaining terms are generated from the immediate previous term using the recurrence relation - * Produce Juggler Sequence using number n as the first term of the sequence and store in an array - * Reference: https://www.geeksforgeeks.org/juggler-sequence/ - * jugglerSequence(3) // returns [3, 5, 11, 36, 6, 2, 1 ] - * jugglerSequence(9) // returns [9, 27, 140, 11, 36, 6, 2, 1] - * jugglerSequence(15) // returns [15, 58, 7, 18, 4, 2, 1] - */ - -function jugglerSequence (n) { - const sequence = [] - sequence.push(n) - // Calculate terms until last term is not 1 - while (n !== 1) { - n = Math.floor(n ** ((n % 2) + 0.5)) - sequence.push(n) - } - return sequence -} - -export { jugglerSequence } From bf86a6995de63b6ac5bbff0f6bb2299d0c83245e Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 31 Aug 2022 19:16:05 +0800 Subject: [PATCH 61/64] Delete JugglerSequence.test.js --- Maths/test/JugglerSequence.test.js | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 Maths/test/JugglerSequence.test.js diff --git a/Maths/test/JugglerSequence.test.js b/Maths/test/JugglerSequence.test.js deleted file mode 100644 index 392047a95b..0000000000 --- a/Maths/test/JugglerSequence.test.js +++ /dev/null @@ -1,21 +0,0 @@ -import { jugglerSequence } from '../JugglerSequence' - -describe('Testing jugglerSequence function', () => { - it('should return [3, 5, 11, 36, 6, 2, 1 ] if the number is 3', () => { - expect(jugglerSequence(3)).toEqual( - expect.arrayContaining([3, 5, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [9, 27, 140, 11, 36, 6, 2, 1] if the number is 9', () => { - expect(jugglerSequence(9)).toEqual( - expect.arrayContaining([9, 27, 140, 11, 36, 6, 2, 1]) - ) - }) - - it('should return [15, 58, 7, 18, 4, 2, 1] if the number is 15', () => { - expect(jugglerSequence(15)).toEqual( - expect.arrayContaining([15, 58, 7, 18, 4, 2, 1]) - ) - }) -}) From 4707eff79f986f5603c683d16c8b5ae7b688a190 Mon Sep 17 00:00:00 2001 From: tehliang Date: Sat, 3 Sep 2022 08:12:07 +0800 Subject: [PATCH 62/64] Update style ci --- ...le and tests CI.yml => Test script, style and Spelling CI.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{Spelling, style and tests CI.yml => Test script, style and Spelling CI.yml} (100%) diff --git a/.github/workflows/Spelling, style and tests CI.yml b/.github/workflows/Test script, style and Spelling CI.yml similarity index 100% rename from .github/workflows/Spelling, style and tests CI.yml rename to .github/workflows/Test script, style and Spelling CI.yml From 4b401898d12a06ddacf26d86ef0efd5e4292c6a1 Mon Sep 17 00:00:00 2001 From: tehliang Date: Sat, 3 Sep 2022 08:18:39 +0800 Subject: [PATCH 63/64] Update name --- ...and Spelling CI.yml => Test script, style and spelling CI.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{Test script, style and Spelling CI.yml => Test script, style and spelling CI.yml} (100%) diff --git a/.github/workflows/Test script, style and Spelling CI.yml b/.github/workflows/Test script, style and spelling CI.yml similarity index 100% rename from .github/workflows/Test script, style and Spelling CI.yml rename to .github/workflows/Test script, style and spelling CI.yml From fa7540fb7c7389145813e5122528091f85685e80 Mon Sep 17 00:00:00 2001 From: tehliang Date: Wed, 21 Sep 2022 16:53:32 +0800 Subject: [PATCH 64/64] Change something --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..450a2ea73f --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +sdewd \ No newline at end of file pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy