Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b7309f0
📦 NEW: Added solution for ProjectEuler-007
omkarnathparida Oct 7, 2022
d3a3b33
🐛 FIX: Spelling mistake fixes
omkarnathparida Oct 7, 2022
e9b5a6a
👌 IMPROVE: changed variable name from `inc` to `candidateValue` and t…
omkarnathparida Oct 7, 2022
e99c722
👌 IMPROVE: Modified the code
omkarnathparida Oct 7, 2022
5ac898f
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 10, 2022
0f9f1ba
👌 IMPROVE: Added test case for ProjectEuler Problem001
omkarnathparida Oct 10, 2022
3caad5c
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 15, 2022
b7584fd
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 16, 2022
6693f9c
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 17, 2022
0830570
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 18, 2022
4d7149c
Merge branch 'TheAlgorithms:master' into master
pomkarnath98 Oct 22, 2023
53e3938
👌 IMPROVE: Added test cases for Project Euler Problem 4
omkarnathparida Oct 22, 2023
96224e7
👌 IMPROVE: auto prettier fixes
omkarnathparida Oct 22, 2023
ae8ac3a
📦 NEW: Added solutuon and testcases for `Project Euler` problem 19
omkarnathparida Oct 25, 2023
b996553
👌 IMPROVE: Updated prettier changes
omkarnathparida Oct 25, 2023
5d1f546
🐛 FIX: indentation fixes
omkarnathparida Oct 25, 2023
4962de4
👌 IMPROVE: Prettier modifications
omkarnathparida Oct 25, 2023
4d4555c
Updated Documentation in README.md
Oct 25, 2023
c3b3bd5
👌 IMPROVE: Prettier modifications
omkarnathparida Oct 25, 2023
26773b3
Merge branch 'project-euler-problem-19' of https://github.com/pomkarn…
omkarnathparida Oct 25, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Bit-Manipulation/BinaryCountSetBits.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function BinaryCountSetBits(a) {

let count = 0
while (a) {
a &= (a - 1)
a &= a - 1
count++
}

Expand Down
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
* [Area](Maths/Area.js)
* [ArithmeticGeometricMean](Maths/ArithmeticGeometricMean.js)
* [ArmstrongNumber](Maths/ArmstrongNumber.js)
* [AutomorphicNumber](Maths/AutomorphicNumber.js)
* [AverageMean](Maths/AverageMean.js)
* [AverageMedian](Maths/AverageMedian.js)
* [BinaryConvert](Maths/BinaryConvert.js)
Expand Down Expand Up @@ -280,6 +281,7 @@
* [Problem016](Project-Euler/Problem016.js)
* [Problem017](Project-Euler/Problem017.js)
* [Problem018](Project-Euler/Problem018.js)
* [Problem019](Project-Euler/Problem019.js)
* [Problem020](Project-Euler/Problem020.js)
* [Problem021](Project-Euler/Problem021.js)
* [Problem023](Project-Euler/Problem023.js)
Expand Down
2 changes: 1 addition & 1 deletion Maths/AutomorphicNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ export const isAutomorphic = (n) => {
n = Math.floor(n / 10)
n_sq = Math.floor(n_sq / 10)
}

return true
}
16 changes: 8 additions & 8 deletions Maths/test/AutomorphicNumber.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ describe('AutomorphicNumber', () => {
})

test.each([
{ n: -3 , expected: false },
{ n: -25 , expected: false },
{ n: -3, expected: false },
{ n: -25, expected: false }
])('should return false when n is negetive', ({ n, expected }) => {
expect(isAutomorphic(n)).toBe(false)
})

test.each([
{ n: 7 , expected: false },
{ n: 83 , expected: false },
{ n: 0 , expected: true },
{ n: 1 , expected: true },
{ n: 376 , expected: true },
{ n: 90625 , expected: true },
{ n: 7, expected: false },
{ n: 83, expected: false },
{ n: 0, expected: true },
{ n: 1, expected: true },
{ n: 376, expected: true },
{ n: 90625, expected: true }
])('should return $expected when n is $n', ({ n, expected }) => {
expect(isAutomorphic(n)).toBe(expected)
})
Expand Down
6 changes: 3 additions & 3 deletions Project-Euler/Problem006.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// https://projecteuler.net/problem=6

export const squareDifference = (num = 100) => {
let sumOfSquares = (num)*(num+1)*(2*num+1)/6
let sums = (num*(num+1))/2
let sumOfSquares = (num * (num + 1) * (2 * num + 1)) / 6
let sums = (num * (num + 1)) / 2

return sums ** 2 - sumOfSquares // difference of square of the total sum and sum of squares
}
19 changes: 19 additions & 0 deletions Project-Euler/Problem019.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// https://projecteuler.net/problem=19

export const countSundays = (startYear = 1901, endYear = 2000) => {
let n = 0
let dayOfWeek = 2
const months = [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

for (let year = startYear; year <= endYear; year++) {
months[1] = 28 + ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0)

for (const month of months) {
dayOfWeek += month % 7
if (dayOfWeek % 7 === 0) {
n++
}
}
}
return n
}
11 changes: 11 additions & 0 deletions Project-Euler/test/Problem004.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { largestPalindromic } from '../Problem004.js'

describe('Largest Palindromic Number', () => {
test('if digit is 2', () => {
expect(largestPalindromic(2)).toBe(9009)
})
// Project Euler Condition Check
test('if digit is 3', () => {
expect(largestPalindromic(3)).toBe(906609)
})
})
11 changes: 11 additions & 0 deletions Project-Euler/test/Problem019.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { countSundays } from '../Problem019.js'

describe('Count Sundays', () => {
test('when start year is 1801 and end year is 1900', () => {
expect(countSundays(1801, 1900)).toBe(172)
})
// Project Euler Condition Check
test('when start year is 1901 and end year is 2000', () => {
expect(countSundays()).toBe(171)
})
})
48 changes: 24 additions & 24 deletions Recursive/test/BinaryEquivalent.test.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { binaryEquivalent } from "../BinaryEquivalent";
import { binaryEquivalent } from '../BinaryEquivalent'

const tests = [
{
test: 2,
expectedValue: "10"
},
{
test: 0,
expectedValue: "0"
},
{
test: 543,
expectedValue: "1000011111"
},
{
test: 4697621023,
expectedValue: "100011000000000000000001000011111"
}
{
test: 2,
expectedValue: '10'
},
{
test: 0,
expectedValue: '0'
},
{
test: 543,
expectedValue: '1000011111'
},
{
test: 4697621023,
expectedValue: '100011000000000000000001000011111'
}
]

describe("Binary Equivalent", () => {
test.each(tests)(
"of $test should be $expectedValue",
({test, expectedValue}) => {
expect(binaryEquivalent(test)).toBe(expectedValue);
}
)
describe('Binary Equivalent', () => {
test.each(tests)(
'of $test should be $expectedValue',
({ test, expectedValue }) => {
expect(binaryEquivalent(test)).toBe(expectedValue)
}
)
})
2 changes: 1 addition & 1 deletion Search/InterpolationSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ export function interpolationSearch(arr, key) {
}

return -1
}
}