FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Remove redundant comparison in 32_stonks.py by owljacob · Pull Request #123 · codedex-io/python-101 · GitHub

Remove redundant comparison in 32_stonks.py - #123

Open
owljacob wants to merge 1 commit into
codedex-io:mainfrom
owljacob:32-stonks
Open

Remove redundant comparison in 32_stonks.py#123
owljacob wants to merge 1 commit into
codedex-io:mainfrom
owljacob:32-stonks

Conversation

owljacob commented Jun 16, 2025
edited
Loading

Copy link
Copy Markdown

The code for min_price can be improved by removing redundant comparison.

def min_price(a, b):
  mn = price_at(a)
  for i in range(a, b + 1):
    mn = min(mn, price_at(i))
  return mn

mn is initialized with the value of price_at(a) and that, however, means that the line where mn is updated becomes mn = min(price_at(a), price_at(a)), this is redundant and it's possible to skip it.

owljacob changed the title Update 32_stonks.py Remove redundant comparison in 32_stonks.py Jun 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL