Deleting the code you wrote is hard

I'm passionate about coding and enjoy working with embedded systems, app development, and compiler design.
There 's something special about writing code that comes entirely from your own thinking. Not because it 's perfect, but because every, basically, line reflects the way your mind approached the problem. It 's your idea, your logic, your solution. Sometimes that solution works. Sometimes it does n't. But building it yourself teaches lessons that copying a standard answer never can. You learn how you think, where your assumptions lead you, and how to question them. Those lessons stay with you far longer than the result itself. In fact, what surprised me the most was n't that I had to replace my code.
#This passed like 165 test cases on leetcode but failed here [3,2,6,5,0,3]
class Solution:
def maxProfit(self, prices):
lowp=min(prices)
leng=len(prices)
i=0
sub=[]
ans=0
if leng<2:
return 0
if lowp == prices[-1]:
temp=prices
del prices[prices.index(lowp)]
lowp=min(prices)
leng-=1
for n in prices:
i=prices.index(n)
if n==lowp:
for j in range(i,leng):
sub.append(prices[j])
if sub:
ans=max(sub)-lowp
return ans
return profit
Honestly, it was how difficult it felt to let it go. After spending time thinking through the job, testing ideas, and shaping the logic, the code no longer felt like just text on a screen. It felt ilk something I had created. Deleting it almost felt like throwing away a portion of that journey. But that 's what software engineering is. What's more, we do n't just write codification — we build ideas, test them against reality, and improve them.
Sometimes the hardest part is n't finding the better resolution. Certainly, it 's accepting that the first one, despite all the effort and thought behind it, has done its job and it 's time to move on. Besides, the code may not survive, but the mentation that created it does. And that 's the portion that makes you a enhance programmer.





