mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-19 19:03:02 +08:00
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort * Fixed doctest error due whitespace * reduce loop times for optimization * fixup! Format Python code with psf/black push Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -8,31 +8,31 @@ from math import factorial
|
||||
|
||||
def lattice_paths(n):
|
||||
"""
|
||||
Returns the number of paths possible in a n x n grid starting at top left
|
||||
corner going to bottom right corner and being able to move right and down
|
||||
only.
|
||||
Returns the number of paths possible in a n x n grid starting at top left
|
||||
corner going to bottom right corner and being able to move right and down
|
||||
only.
|
||||
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 50
|
||||
1.008913445455642e+29
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 25
|
||||
126410606437752.0
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 23
|
||||
8233430727600.0
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 15
|
||||
155117520.0
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 1
|
||||
2.0
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 50
|
||||
1.008913445455642e+29
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 25
|
||||
126410606437752.0
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 23
|
||||
8233430727600.0
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 15
|
||||
155117520.0
|
||||
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 1
|
||||
2.0
|
||||
|
||||
>>> lattice_paths(25)
|
||||
126410606437752
|
||||
>>> lattice_paths(23)
|
||||
8233430727600
|
||||
>>> lattice_paths(20)
|
||||
137846528820
|
||||
>>> lattice_paths(15)
|
||||
155117520
|
||||
>>> lattice_paths(1)
|
||||
2
|
||||
>>> lattice_paths(25)
|
||||
126410606437752
|
||||
>>> lattice_paths(23)
|
||||
8233430727600
|
||||
>>> lattice_paths(20)
|
||||
137846528820
|
||||
>>> lattice_paths(15)
|
||||
155117520
|
||||
>>> lattice_paths(1)
|
||||
2
|
||||
|
||||
"""
|
||||
n = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1,
|
||||
|
Reference in New Issue
Block a user