From 06d1f90219d512289766c66b9ced945c5dae19a3 Mon Sep 17 00:00:00 2001 From: Rama <41026094+raghavrama21@users.noreply.github.com> Date: Wed, 21 May 2025 22:33:10 -0400 Subject: [PATCH 1/2] Added environment.yml Earlier the repo didnt specify how to get number_of_ways.py to work well. --- environment.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 environment.yml diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..1ee8058 --- /dev/null +++ b/environment.yml @@ -0,0 +1,7 @@ +name: cs197lec2 +channels: + - defaults +dependencies: + - python=3.9 + - tqdm +prefix: /Users/raghavrama/miniconda3/envs/cs197lec2 From bdbacb62a9be6cd2dfc7ac520f5052b7e106c579 Mon Sep 17 00:00:00 2001 From: Rama <41026094+raghavrama21@users.noreply.github.com> Date: Wed, 21 May 2025 22:54:41 -0400 Subject: [PATCH 2/2] Fixed the error in number_of_ways.py --- number_of_ways.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/number_of_ways.py b/number_of_ways.py index bebe306..3c32615 100644 --- a/number_of_ways.py +++ b/number_of_ways.py @@ -5,18 +5,18 @@ def numberOfWays(startPos: int, endPos: int, k: int) -> int: """ Solving Leetcode Problem. https://leetcode.com/problems/number-of-ways-to-reach-a-position-after-exactly-k-steps/ - + Given two positive integers startPos and endPos Initially, you are standing at position startPos on an infinite number line. With one step, you can move either one position to the left, or one position to the right. - + Given a positive integer k, return the number of different ways to reach the position endPos starting from startPos, such that you perform exactly k steps. """ # start with path of length 1 - paths = [startPos] + paths = [[startPos]] # loop k times for i in tqdm(range(k)): @@ -59,5 +59,6 @@ def test_number_of_ways(): """ print(numberOfWays(1, 2, 3)) + if __name__ == "__main__": test_number_of_ways()