From 5560a1ed76f53951ce7c6669ed2334ff2249a693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Fri, 28 Oct 2022 17:37:36 +0200 Subject: [PATCH 1/2] fix: Project Euler P35 off-by-one error --- Project-Euler/Problem035.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Project-Euler/Problem035.js b/Project-Euler/Problem035.js index b62a8f0312..f422defcde 100644 --- a/Project-Euler/Problem035.js +++ b/Project-Euler/Problem035.js @@ -15,7 +15,8 @@ function problem35 (n) { if (n < 2) { throw new Error('Invalid input') } - const list = sieveOfEratosthenes(n).filter(prime => !prime.toString().match(/[024568]/)) // Get a list of primes without 0, 2, 4, 5, 6, 8 + // Get a list of primes without 0, 2, 4, 5, 6, 8; this discards the circular primes 2 & 5 + const list = sieveOfEratosthenes(n).filter(prime => !prime.toString().match(/[024568]/)) const result = list.filter((number, _idx, arr) => { const str = String(number) @@ -28,7 +29,7 @@ function problem35 (n) { return true // If all rotations are prime, then the number is circular prime }) - return result.length + 1 // Add 2 to the result because 2 is a circular prime + return result.length + 2 // Add 2 to the result because the circular primes 2 & 5 were discarded } export { problem35 } From b3791227e5c3f9421b844cc57ed4063099e008bf Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 28 Oct 2022 15:38:07 +0000 Subject: [PATCH 2/2] Updated Documentation in README.md --- DIRECTORY.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index a32addb9de..0c12cc96d1 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -57,6 +57,7 @@ * [LocalMaximomPoint](Data-Structures/Array/LocalMaximomPoint.js) * [NumberOfLocalMaximumPoints](Data-Structures/Array/NumberOfLocalMaximumPoints.js) * [QuickSelect](Data-Structures/Array/QuickSelect.js) + * [Reverse](Data-Structures/Array/Reverse.js) * **Graph** * [Graph](Data-Structures/Graph/Graph.js) * [Graph2](Data-Structures/Graph/Graph2.js) @@ -81,6 +82,7 @@ * **Tree** * [AVLTree](Data-Structures/Tree/AVLTree.js) * [BinarySearchTree](Data-Structures/Tree/BinarySearchTree.js) + * [SegmentTree](Data-Structures/Tree/SegmentTree.js) * [Trie](Data-Structures/Tree/Trie.js) * **Vectors** * [Vector2](Data-Structures/Vectors/Vector2.js) @@ -105,18 +107,19 @@ * [RodCutting](Dynamic-Programming/RodCutting.js) * [Shuf](Dynamic-Programming/Shuf.js) * [SieveOfEratosthenes](Dynamic-Programming/SieveOfEratosthenes.js) - * [UniquePaths](Dynamic-Programming/UniquePaths.js) * **Sliding-Window** * [LongestSubstringWithoutRepeatingCharacters](Dynamic-Programming/Sliding-Window/LongestSubstringWithoutRepeatingCharacters.js) * [PermutationinString](Dynamic-Programming/Sliding-Window/PermutationinString.js) * [SudokuSolver](Dynamic-Programming/SudokuSolver.js) * [TrappingRainWater](Dynamic-Programming/TrappingRainWater.js) * [TribonacciNumber](Dynamic-Programming/TribonacciNumber.js) + * [UniquePaths](Dynamic-Programming/UniquePaths.js) * [ZeroOneKnapsack](Dynamic-Programming/ZeroOneKnapsack.js) * **Geometry** * [ConvexHullGraham](Geometry/ConvexHullGraham.js) * **Graphs** * [BellmanFord](Graphs/BellmanFord.js) + * [BinaryLifting](Graphs/BinaryLifting.js) * [BreadthFirstSearch](Graphs/BreadthFirstSearch.js) * [BreadthFirstShortestPath](Graphs/BreadthFirstShortestPath.js) * [ConnectedComponents](Graphs/ConnectedComponents.js) @@ -126,6 +129,7 @@ * [Dijkstra](Graphs/Dijkstra.js) * [DijkstraSmallestPath](Graphs/DijkstraSmallestPath.js) * [FloydWarshall](Graphs/FloydWarshall.js) + * [Kosaraju](Graphs/Kosaraju.js) * [KruskalMST](Graphs/KruskalMST.js) * [NodeNeighbors](Graphs/NodeNeighbors.js) * [NumberOfIslands](Graphs/NumberOfIslands.js) @@ -158,6 +162,7 @@ * [EulerMethod](Maths/EulerMethod.js) * [EulersTotient](Maths/EulersTotient.js) * [EulersTotientFunction](Maths/EulersTotientFunction.js) + * [ExponentialFunction](Maths/ExponentialFunction.js) * [ExtendedEuclideanGCD](Maths/ExtendedEuclideanGCD.js) * [Factorial](Maths/Factorial.js) * [Factors](Maths/Factors.js) @@ -190,6 +195,7 @@ * [MeanSquareError](Maths/MeanSquareError.js) * [MidpointIntegration](Maths/MidpointIntegration.js) * [MobiusFunction](Maths/MobiusFunction.js) + * [ModularArithmetic](Maths/ModularArithmetic.js) * [ModularBinaryExponentiationRecursive](Maths/ModularBinaryExponentiationRecursive.js) * [NumberOfDigits](Maths/NumberOfDigits.js) * [Palindrome](Maths/Palindrome.js) @@ -209,6 +215,7 @@ * [ReversePolishNotation](Maths/ReversePolishNotation.js) * [ShorsAlgorithm](Maths/ShorsAlgorithm.js) * [SieveOfEratosthenes](Maths/SieveOfEratosthenes.js) + * [SieveOfEratosthenesIntArray](Maths/SieveOfEratosthenesIntArray.js) * [SimpsonIntegration](Maths/SimpsonIntegration.js) * [Softmax](Maths/Softmax.js) * [SquareRoot](Maths/SquareRoot.js) @@ -243,6 +250,7 @@ * [Problem023](Project-Euler/Problem023.js) * [Problem025](Project-Euler/Problem025.js) * [Problem028](Project-Euler/Problem028.js) + * [Problem035](Project-Euler/Problem035.js) * [Problem044](Project-Euler/Problem044.js) * **Recursive** * [BinaryEquivalent](Recursive/BinaryEquivalent.js) @@ -317,6 +325,7 @@ * [CheckRearrangePalindrome](String/CheckRearrangePalindrome.js) * [CheckSnakeCase](String/CheckSnakeCase.js) * [CheckWordOccurrence](String/CheckWordOccurrence.js) + * [CountLetters](String/CountLetters.js) * [CountSubstrings](String/CountSubstrings.js) * [CountVowels](String/CountVowels.js) * [CreatePermutations](String/CreatePermutations.js)