Skip to content

Fix2 #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Fix2 #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: cs197lec2
channels:
- defaults
dependencies:
- python=3.9
- tqdm
prefix: /Users/raghavrama/miniconda3/envs/cs197lec2
7 changes: 4 additions & 3 deletions number_of_ways.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -59,5 +59,6 @@ def test_number_of_ways():
"""
print(numberOfWays(1, 2, 3))


if __name__ == "__main__":
test_number_of_ways()