Papiha Joharapurkar

algorithm challenges

The week has drawn to an end, hurrah! Today the learnings are slim, had some meetings for an important project which took up quite a lot of my time and brainpower. Today I had just an algorithm-problem I solve. With these problems, I try to solve without AI assistance as well as time-box myself. I solved a variation of this problem. The aim was that I needed to find the first letter in a word that broke alphabetical order (i.e. the last E in Beehive). The way that I solved this problem included looking at the ord of the char while iterating through all the characters in the word. After reviewing the problem and taking some time away, I realize I could have just compared the characters with a (char1) < (char2) as Python can compare strings alphabetically. Big whoop. I also did not ensure my function had consistent return types as when I had a failure, I returned the char but if a success, I didn't return anything at the end and should have returned None (not to mention raising a ValueError for invalid input). I think these problems I timebox myself to do are helpful as it helps me become a better thinker/programmer, which is incredibly important in the age of AI. I also realize something else I can do when writing a function is to create type hints before my code i.e. something like the following so that I can ensure I have the right returns. That's all for today! On and forwards!

def what_program_should_do(word:str) -> str | None:

All daily logs