Motherfucker Bertrand Russell

I’m gonna talk about the Russell’s Paradox and the motherfucker who wrote it. What’s a paradox? It’s the ultimate question. It has been echoing inside you all along. You see a pretty dress and see yourself in it, next moment you wonder why that old man is so weak and then why the fuck there […]

Preview

I don’t know what I am going to write about, but I guess I should because I don’t know what else is there to do? My priorities are made up, my principles too, my personal constitution and all the decisions are based on life events around me, and those I have procured in my big […]

This one is not code related

My last five posts have been completely naive in a sense that they describe merely the code of what I found amazing to have solved on my own or appreciated for a little amount of time at a point in my life while I was still exploring the programming world. Now that one long sentence […]

Counting Valleys

def countingValleys(n, s): valleys = 0 hikes = 0 for i in s: if i==’D’: if hikes==0: valleys += 1 hikes -= 1 else: hikes += 1 return valleys Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike, he took exactly  steps. For […]

Power Set – algorithmic and fast

class Solution: # @param A : list of integers # @return a list of list of integers def subsets(self, A):     if len(A) == 0:         return [[]]     h, t = A[0], A[1:]     subsets_excluding_h = self.subsets(t)     subsets_including_h = [sorted([h] + ss) for ss in subsets_excluding_h] […]

Atoi

class Solution: # @param A : string # @return an integer def atoi(self, A): mx = (2**31)-1 mn = -(2**31) s = ” for x in A: if x.isdigit() or (A.index(x)==0 and x in (‘-‘, ‘+’)): s += x else: break if (s and s[0].isdigit()) or (len(s)>1 and s[0] in (‘+’, ‘-‘)): if 0 <= […]