Skip to content

profit / gain [terminology]

Terminology

Usage

  • Keep domain-specific terms when they explain the quantity better than generic terms.
  • profit is the accumulated financial result.
  • gain is a positive or potentially useful increase between prices.
  • Do not mechanically rename them to total, diff, or ans.
profit = 0

for i in range(1, n):
    gain = prices[i] - prices[i - 1]
    if gain > 0:
        profit += gain