As a kid, I participated in a game that involved bouncing a tennis ball on the ground using your hands. The winner was the one who was able to bounce the ball the most number of times in 60 second.
All the little ones (including me) went first (since the game was primarily meant to keep us busy). I was top scoring with a little over 70 bounces in 60 second. What I did to get there was try and go as fast as I possibly could without losing control of the ball, and focusing heavily on where the ball was at all times.
Then the grown-ups started and for a while no one was able to beat that score. Then one smart dude knelt down when the signal to start was given. Everyone else had already started bouncing there balls and were in to their second bounce, and this guy was taking his own time getting settled in his squatting position. When he was ready, he started bouncing the ball, and boy did he go fast! He had just out-smarted everyone else with a better algorithm for getting more bounces in the same time duration.
Better algorithms are like bicycles for the mind.
Before we had sorting algorithms that ran efficiently [O(n log n)], we had micro-optimizations applied to every known O(n2) sorting algorithm in an attempt to make it perform fewer comparisons, or exit early, and hence run faster. Fixing the algorithm, however, was the real game changer.
Showing posts with label random. Show all posts
Showing posts with label random. Show all posts
Saturday, December 07, 2013
Monday, April 18, 2011
News these days
Being the beneficiary of a headache yesterday, I had the privilege of being unproductive and just fixing myself in front the of television set and watching the daily news with the rest of the family. The news reader almost mechanically read out these 2 news items back to back (in the same segment):
- Police firing in The Ratnagiri district of Maharashtra kill 1 and injures 5, and
- Indian Ministers oppose the wastage of food at weddings and ask the organisers to provision accurately
Sunday, November 14, 2010
Undecidable
Many times have I come across concepts that mimic the concept of an Undecidable problem. So, for all you people who don't know what an Undecidable (or partially decidable -- please pardon the terminoloty) problem is, you can check out the wiki page here or read the layman's definition below:
If a solution to the problem has a "yes" answer then it WILL be found, but if it has a "NO" answer, you'll never know so because you'll keep running the algorithm in the hope of finding the "YES" answer.
Now, it turns out that in the last few months I've come across many instances of such "undecidable" problems. I'll list out a few here:
So, the next time I have an argument/discussion with anyone and I mention "this is undecidable", I'll try to give them a link to this post as well.
If a solution to the problem has a "yes" answer then it WILL be found, but if it has a "NO" answer, you'll never know so because you'll keep running the algorithm in the hope of finding the "YES" answer.
Now, it turns out that in the last few months I've come across many instances of such "undecidable" problems. I'll list out a few here:
- If you have good marks on a test, you are a good student, but if you don't then it doesn't mean that you are a bad student
- If you have lots of fans on your facebook page, then you are famous but if you don't, it doesn't necessarily mean that you aren't
So, the next time I have an argument/discussion with anyone and I mention "this is undecidable", I'll try to give them a link to this post as well.
Tuesday, June 22, 2010
A new water pump for our washing machine
(This blog post has the potential to be discursive and go in no particular direction, so I'll try my best to remain as unwavering as I can)
It all started off when our washing machine konked off and decided to stop working. My grandma sent it off to the repairers who fixed it and then had the brilliant idea to suggest attaching a water pump so that water from the tank above would flow in much faster. Now, anyone who has played with a syringe would know that no matter how hard you push (or pull), you just can NOT for the love of anything (or anyone) get more than a certain amount of liquid through the syringe (or in this case the pipe).
Now, our pipes are really old and are rusting from the inside. This is the reason that the flow of water has gone down as compared to the time when they were first installed. Even though I suggested getting the pipes changed due to the above mentioned reason (since that is the real problem, my grandma would hear nothing from me... Oh well... so be it...)
The brilliant engineer's suggestion came as a massive shock to me and it almost felt funny. Anyways, the pump has been installed and guess what... The flow of water in the pipe is still the same!! I wonder how that happened. Isn't the pump working (scratch head, etc...)
The rate of flow of water in a pipe depends upon many things. One of them being the inner diameter of the pipe and another being the friction offered by the sides of the pipe. I don't know the exactly formula, but I am guessing it is easy to come by. The pressure exerted by the water in the tank is more than sufficient to max. out the flow rate in the pipe and I would have guessed those engineers to know that. I guess it's back to the drawing board for them ;)
It all started off when our washing machine konked off and decided to stop working. My grandma sent it off to the repairers who fixed it and then had the brilliant idea to suggest attaching a water pump so that water from the tank above would flow in much faster. Now, anyone who has played with a syringe would know that no matter how hard you push (or pull), you just can NOT for the love of anything (or anyone) get more than a certain amount of liquid through the syringe (or in this case the pipe).
Now, our pipes are really old and are rusting from the inside. This is the reason that the flow of water has gone down as compared to the time when they were first installed. Even though I suggested getting the pipes changed due to the above mentioned reason (since that is the real problem, my grandma would hear nothing from me... Oh well... so be it...)
The brilliant engineer's suggestion came as a massive shock to me and it almost felt funny. Anyways, the pump has been installed and guess what... The flow of water in the pipe is still the same!! I wonder how that happened. Isn't the pump working (scratch head, etc...)
The rate of flow of water in a pipe depends upon many things. One of them being the inner diameter of the pipe and another being the friction offered by the sides of the pipe. I don't know the exactly formula, but I am guessing it is easy to come by. The pressure exerted by the water in the tank is more than sufficient to max. out the flow rate in the pipe and I would have guessed those engineers to know that. I guess it's back to the drawing board for them ;)
Saturday, May 29, 2010
A few rules to live by
- you can only lie to others, never to yourself
- don't hurt others -- it will only come back to you
- you can justify anything -- we all can -- but don't try too hard. you might end up lying
- python rocks
- java bites shite
- java has resulted in more deaths and cases of insanity than road accidents world-wide
- the average lifespan of a java programmer is 10 years less than that of a python programmer and 7 years less than the average for a human
- what can kill chuck norris -- programming in java
- listen to music you like -- don't pretend
- eat food you like -- don't pretend
- wear what you like (if you want to wear anything that is) -- don't pretend
- criticize -- don't be diplomatic when you don't need to
- praise -- it spreads good vibes -- but don't praise falsely -- it doesn't help at all
- music will set you free ;)
- do what you want to, not what you have to or need to -- sometimes you may "need/have" to do the things though; but don't stretch it too much
- listen to "sunscreen" if you haven't yet
- don't recommend it to others because it's "cool", but because you think it's worth doing
- don't do anything "just" because it's "cool"
- don't not to anything just because it's not cool
- the arts are purgative and cathartic; write, act, sing, cook, code... anything is art and art is everything...
- you may need to twist your finger to get the fat out(transated from a hindi proverb); but do it only if it's absolutely necessary
- talk is cheap; actions are not
- neither is code
- show me the code you piece of shite
Saturday, January 09, 2010
It's funny to know....
.... that something you have thought of doing and have done has been thought of by someone else across the world and done in almost exactly the same way as you have....
It's saddening and encouraging at the same time. Saddening because it's not something novel any more. Someone has "been there.. and done that..". Encouraging because you know that you are not having any insanely weird and impractical thoughts and ideas and that you are solving some real problem out there.
This is the second time that this has happened to me, and it is a real confidence booster I should say!!
The project under question is StickyLinks. The exact same thing was done in 1997 and is called WebCite. The funny thing is that it was made for the exact same problem that I was trying to solve, which probably explains why it turned out to be so similar.
The thing that still gets to me is that even the layout of the version page (view where a version of a certain page is displayed) is almost identical. Both projects use frames. Both projects have a bookmarklet.
However, there are ways I plan to extend StickyLinks, so stay posted!!
ps. My next idea: To develop a search engine that will let you search for already existing ideas/concepts/implementations of thoughts that you may have and may think are novel. I use the internet (esp. the search engines) a lot to search for projects that I may want to undertake, just to check if it's already been done by someone else. Most of the time I have to search a lot of times, tweaking my search keywords ever so slightly in the hope of a match. Many a times, I fail to chance upon the right set of keywords (the words that the original author used to describe his/her idea/project) and am under the impression that the idea I have is novel/un-thought of. However, many times it does happen that such a thing does not exist. However, it is only time that lets you ascertain this (if a similar concept exists, you hear of it sooner rather than later, assuming you have shared it with friends).
It's saddening and encouraging at the same time. Saddening because it's not something novel any more. Someone has "been there.. and done that..". Encouraging because you know that you are not having any insanely weird and impractical thoughts and ideas and that you are solving some real problem out there.
This is the second time that this has happened to me, and it is a real confidence booster I should say!!
The project under question is StickyLinks. The exact same thing was done in 1997 and is called WebCite. The funny thing is that it was made for the exact same problem that I was trying to solve, which probably explains why it turned out to be so similar.
The thing that still gets to me is that even the layout of the version page (view where a version of a certain page is displayed) is almost identical. Both projects use frames. Both projects have a bookmarklet.
However, there are ways I plan to extend StickyLinks, so stay posted!!
ps. My next idea: To develop a search engine that will let you search for already existing ideas/concepts/implementations of thoughts that you may have and may think are novel. I use the internet (esp. the search engines) a lot to search for projects that I may want to undertake, just to check if it's already been done by someone else. Most of the time I have to search a lot of times, tweaking my search keywords ever so slightly in the hope of a match. Many a times, I fail to chance upon the right set of keywords (the words that the original author used to describe his/her idea/project) and am under the impression that the idea I have is novel/un-thought of. However, many times it does happen that such a thing does not exist. However, it is only time that lets you ascertain this (if a similar concept exists, you hear of it sooner rather than later, assuming you have shared it with friends).
Tuesday, January 13, 2009
GIGO
Sometimes, the the title of a post doesn't quite describe what the post is all about. I think this post is a classic case of the above.
I'll try to keep it as simple as possible.
Suppose you are writing a program to compute the factorial of a number, you would also add a function to find if a string is a substring of another string, or check if a string is a palindrome? If you answer "yes" to any of the above questions, I would surely like to see you actively use the above in your program. For the rest of you un-interesting lot(Rule:0 of blogging; never lower the self-esteem of your readers), I would like to ask you if you would eat a packet of biscuits just because it was available for free. I'm guessing you wouldn't eat anything unless you were hungry, and if you consider biscuits as not belonging to the class of "healthy foods", you probably wouldn't eat those as well.
I'll try to keep it as simple as possible.
Suppose you are writing a program to compute the factorial of a number, you would also add a function to find if a string is a substring of another string, or check if a string is a palindrome? If you answer "yes" to any of the above questions, I would surely like to see you actively use the above in your program. For the rest of you un-interesting lot(Rule:0 of blogging; never lower the self-esteem of your readers), I would like to ask you if you would eat a packet of biscuits just because it was available for free. I'm guessing you wouldn't eat anything unless you were hungry, and if you consider biscuits as not belonging to the class of "healthy foods", you probably wouldn't eat those as well.
Saturday, November 24, 2007
The one that got left behind
What comes to your mind when you read the title above? Make a quick list of a few things that do. It could be:
1. The ugly duckling
2. Some taste left behind in your mouth after having something utterly distasteful/pleasing
3. Some food speck left behind between your teeth
4. A good/bad memory, though more often than not, it's the latter that stays
5. The tune of some song that you just can't get out of your head
6. Some task on your list that you forgot to do
But, I ain't gonna to be talking about any of the above. What I'm going to focus my attention on today is on that last bit of poop left behind after you flush. No matter how hard your try, how many tumblers of water you put in, however fast, it just won't go down! It's like one of those resilient warriors; kind of reminds me of cockroaches. Every time you try a different angle to put the water in, and look in to see if you've managed to get rid of it, it just bobs up right back in your face. It's like as if it's there to stay. So, you try again, and again, and again, and before you know it, your bucket of water is over, and there's none left for you to wash your hiney!!!! You think "Now is a really bad time for me to run out of water". Reminds me of a few problems I've faced in my little life so far. They've mostly been self-created like this one, but more often than not, they just go away with time, or I find a solution if I think about it with a clear head; but not this one. No matter how much time you give it, it just stays there - probably soaking up more water, or doing whatever it does best. You know that the only way you are going to get rid of it is to flush again, or heave another full bucket of water in it, but you don't have the patience to wait till the flush tank is full again, and at the same time, don't want to waste another bucket of water, now that you've already used up one already. You start thinking and staring at that mass of excreta in a very contemplative way; but to no avail. Exasperated, you move on to let the next person clean up your shit.... Well, that's life....
1. The ugly duckling
2. Some taste left behind in your mouth after having something utterly distasteful/pleasing
3. Some food speck left behind between your teeth
4. A good/bad memory, though more often than not, it's the latter that stays
5. The tune of some song that you just can't get out of your head
6. Some task on your list that you forgot to do
But, I ain't gonna to be talking about any of the above. What I'm going to focus my attention on today is on that last bit of poop left behind after you flush. No matter how hard your try, how many tumblers of water you put in, however fast, it just won't go down! It's like one of those resilient warriors; kind of reminds me of cockroaches. Every time you try a different angle to put the water in, and look in to see if you've managed to get rid of it, it just bobs up right back in your face. It's like as if it's there to stay. So, you try again, and again, and again, and before you know it, your bucket of water is over, and there's none left for you to wash your hiney!!!! You think "Now is a really bad time for me to run out of water". Reminds me of a few problems I've faced in my little life so far. They've mostly been self-created like this one, but more often than not, they just go away with time, or I find a solution if I think about it with a clear head; but not this one. No matter how much time you give it, it just stays there - probably soaking up more water, or doing whatever it does best. You know that the only way you are going to get rid of it is to flush again, or heave another full bucket of water in it, but you don't have the patience to wait till the flush tank is full again, and at the same time, don't want to waste another bucket of water, now that you've already used up one already. You start thinking and staring at that mass of excreta in a very contemplative way; but to no avail. Exasperated, you move on to let the next person clean up your shit.... Well, that's life....
Monday, October 22, 2007
The geek in you.
After reading the previous post(Of wed-locks and love-handles), a friend of mine pointed out a spelling mistake that I had made. However, when I went back and re-read the title, something very interesting struck me. If you notice carefully, the words locks and handles are technical terms used quite frequently in computer engineering ;-)
Sunday, October 21, 2007
A bumpy bus ride
A friend and I were returning to Mumbai from Pune on the MSRTC Volvo bus, and here is something that I wrote while on the bus.
We were sitting over the malfunctioning suspenders of a bus travelling at a relatively high speed(about 90km/hr) on a road littered with irregularities. The intermittent halt at the toll naka was a very welcome one. My hand writing did improve while we were stationary, but went back to its illegible self once the bus re-commenced its jerky ride back to Mumbai.
Friday, June 01, 2007
Random stuff; About today.
Hello everyone. I know there aren't too many of you who read this blog, but to the few who do "Hiya!!!!"
Statutory Warning: I may get bored while writing this post, and it may just terminate abruptly; much like a road that ends(if you know what I'm talking about). You may also find paragraphs ending, and a new one starting out of nowhere. This is because my mind was filled with void for the time between.
Today on the way from Pune to Mumbai, I spotted(somewhere ar Lonavala) to the right a hotel called (forgot name), and to left was Lion's Den.
Further, was the new cricket stadium that was being build which, I think is at Khargar. Just beyond that was a Royal Enfield showroom. Well, you don't see to many of those these days. My room mate(KD) is a big fan of those and owns one. In fact, he is contemplating purchasing another one, just for the road while he plans to use the current one only for races. There's a guy with passion.
About 10mins down the road, I could see a traffic jam in the opposite direction which was(to say the least) a couple of kilometers long. I hate traffic jams, because if you are stuck in one, you are effectively getting nowhere. And I do get restless when I am stuck in one.
There was a sign on the divider which mentioned the safe upper bounds for the different vehicle classes such as buses, cars, trucks, etc.... However, you could very clearly that everyone was moving in unison, and that too at some speed greater than the globally maximum allowable for any type of vehicle. That kind of begged the quesion if those signs were just put up for fun or for that day when people wore helmets, and had their license, and their vehical's documents, etc.... and the only resort left for the police was to catch them of the count of over-speeding. This kinda begs the question if that's what American cops have been up to for so long....
I was just thinking about the link about writing style sent to me by [RS](not to be confused with in the class R or S), and a very strange thought crossed my mind. Is it possible for someone to have memorized all of those rules, and created a mental map to be called upon whenever they wrote an article? Well, I hope not. At least not immediately. Which then leads to the obvious question: "When????". Then it struck me like the lightening that was shuddering in the fair distance ahead: "When they are all old and experienced...." Is this all experienced people did? Go through their subordinate's articles checking for incorrect application of the rules mentioned on the document. Well, I hope not. At least not where I want to be working. My ideal job place involves hard core work along with a lot of fun and frolic. Not something that I've found yet, but hey, the search is still on....
I reached Dadar only to find out that my phone could not detect my service provider's network. I thought that it would work over time, but even after repeated trials, it refused to budge. That's when my other(as yet dormant) senses woke up to the realization that others in the bus were facing the same problem and I hadn't been singled out(It's always a relief to know that ;-)).
I got off the bus, and straight away entered the Monginis cake shop. Hehehe(The rest you all know). From there, my stomach beckoned me to stop at the first Arey outlet that my eyes could set their focus upon, and ask(very polietly) for a coffee flavoured energy. AFter that devouring that miracle of mankind, I marched off toward the station, and it began drizzing, so I hurriedly got my body under the station roof.
As luck would have it, I was able to get a CST fast local, which stopped only at Byculla. So that facilitated my more expedited approach home.
Now, I find myself writing this post and sipping on a cup of tea. I'll spare you people the details, and just let you enjoy the rest of the day.... Ciao.... ;-)
Statutory Warning: I may get bored while writing this post, and it may just terminate abruptly; much like a road that ends(if you know what I'm talking about). You may also find paragraphs ending, and a new one starting out of nowhere. This is because my mind was filled with void for the time between.
Today on the way from Pune to Mumbai, I spotted(somewhere ar Lonavala) to the right a hotel called (forgot name), and to left was Lion's Den.
Further, was the new cricket stadium that was being build which, I think is at Khargar. Just beyond that was a Royal Enfield showroom. Well, you don't see to many of those these days. My room mate(KD) is a big fan of those and owns one. In fact, he is contemplating purchasing another one, just for the road while he plans to use the current one only for races. There's a guy with passion.
About 10mins down the road, I could see a traffic jam in the opposite direction which was(to say the least) a couple of kilometers long. I hate traffic jams, because if you are stuck in one, you are effectively getting nowhere. And I do get restless when I am stuck in one.
There was a sign on the divider which mentioned the safe upper bounds for the different vehicle classes such as buses, cars, trucks, etc.... However, you could very clearly that everyone was moving in unison, and that too at some speed greater than the globally maximum allowable for any type of vehicle. That kind of begged the quesion if those signs were just put up for fun or for that day when people wore helmets, and had their license, and their vehical's documents, etc.... and the only resort left for the police was to catch them of the count of over-speeding. This kinda begs the question if that's what American cops have been up to for so long....
I was just thinking about the link about writing style sent to me by [RS](not to be confused with in the class R or S), and a very strange thought crossed my mind. Is it possible for someone to have memorized all of those rules, and created a mental map to be called upon whenever they wrote an article? Well, I hope not. At least not immediately. Which then leads to the obvious question: "When????". Then it struck me like the lightening that was shuddering in the fair distance ahead: "When they are all old and experienced...." Is this all experienced people did? Go through their subordinate's articles checking for incorrect application of the rules mentioned on the document. Well, I hope not. At least not where I want to be working. My ideal job place involves hard core work along with a lot of fun and frolic. Not something that I've found yet, but hey, the search is still on....
I reached Dadar only to find out that my phone could not detect my service provider's network. I thought that it would work over time, but even after repeated trials, it refused to budge. That's when my other(as yet dormant) senses woke up to the realization that others in the bus were facing the same problem and I hadn't been singled out(It's always a relief to know that ;-)).
I got off the bus, and straight away entered the Monginis cake shop. Hehehe(The rest you all know). From there, my stomach beckoned me to stop at the first Arey outlet that my eyes could set their focus upon, and ask(very polietly) for a coffee flavoured energy. AFter that devouring that miracle of mankind, I marched off toward the station, and it began drizzing, so I hurriedly got my body under the station roof.
As luck would have it, I was able to get a CST fast local, which stopped only at Byculla. So that facilitated my more expedited approach home.
Now, I find myself writing this post and sipping on a cup of tea. I'll spare you people the details, and just let you enjoy the rest of the day.... Ciao.... ;-)
Subscribe to:
Posts (Atom)