Skip to content

Remove redundant comparison in 32_stonks.py #123

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 1 commit into
base: main
Choose a base branch
from

Conversation

owljacob
Copy link

@owljacob owljacob commented Jun 16, 2025

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 owljacob changed the title Update 32_stonks.py Remove redundant comparison in 32_stonks.py Jun 16, 2025
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