Posts

Showing posts with the label python3

Program of the Week 02 - Unique Element

So initially I was planning to do a program on basic object / motion detection from video using opencv. I tried to find my old code for it but was unable to find it. So I thought rather than wasting time finding it, I'd rather find it myself. But since you are reading this long introduction and you probably have read the title by now, that ain't happening; this week at least. So what alternative I have then today, pretty sure there are a ton of programs for finding unique elements from a list or what not, and this one will probably join its ranks as well. A little bit of backstory for the problem / program at hand is that last week one of my friends went for an interview for a new job. He'd cleared many rounds before and was now in the technical round. The problem given to him was simple: "Given a list of elements, you need to find the non-repeating element from the list. The space complexity needs to be O(k) and...

Program of the Week 01 - Common Day Finder

I know the title of this post ain't that great and TBH I couldn't come up with something better. So what is this program about. A few days back a friend of mine celebrated his birthday. I was wondering how do I find all the years when, his birthday and mine fall on the same day of the week. It was not a great question, but it piqued me and I wrote a rudimentary program for it on my phone. While this is not the same code I wrote it is kinda similar. I will be writing it in Python as that is the language I'm most comfortable in right now. I'll be using the trusty 'datetime' utility in python for this task. Below is the basic version of the program: from datetime import datetime # Initialize the dates date1 = "15/02" date2 = "23/05" # Initialize the start and end years start_year = 2019 end_year = 2100 # Initialize a list for all results results = [] # Now loop in the year range and find the days for year in range(start_year, end_...