Skip to content

Commit

Permalink
📦 NEW: Added test cases for Project Euler Problem 15 and a minor bug …
Browse files Browse the repository at this point in the history
…fix to the solution
  • Loading branch information
omkarnathparida committed Oct 8, 2024
1 parent 944077b commit 096e624
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Project-Euler/Problem015.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ How many such routes are there through a 20×20 grid?
// A lattice path is composed of horizontal and vertical lines that pass through lattice points.

export const latticePath = (gridSize) => {
let paths
for (let i = 1, paths = 1; i <= gridSize; i++) {
let paths = 1
for (let i = 1; i <= gridSize; i++) {
paths = (paths * (gridSize + i)) / i
}
// The total number of paths can be found using the binomial coefficient (b+a)/a.
Expand Down
13 changes: 13 additions & 0 deletions Project-Euler/test/Problem015.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { expect } from 'vitest'
import { latticePath } from '../Problem015'

describe('Finding total numbers of Latice Paths', () => {

Check failure on line 4 in Project-Euler/test/Problem015.test.js

View workflow job for this annotation

GitHub Actions / Check for spelling errors

Latice ==> Lattice
test.each([
[2, 6],
[4, 70],
[10, 184756],
[20, 137846528820]
])('If Grid Size: %i, then Latice Paths count: %i', (a, expected) => {

Check failure on line 10 in Project-Euler/test/Problem015.test.js

View workflow job for this annotation

GitHub Actions / Check for spelling errors

Latice ==> Lattice
expect(latticePath(a)).toBe(expected)
})
})

0 comments on commit 096e624

Please sign in to comment.