Tuesday, April 1, 2014

Good bye How I Met Your Mother

Just finished How I Met Your Mother season finale.I have so many emotions and thoughts rambling through my mind.First, of all its been an amazing journey.3-4 years for me and 9 years for many of you guys.I was this bright,young guy just out of school ,having so many ambitions of conquering the world when i started watching the show.Back then, i thought life was this fairy tale and good things happen to everyone and everybody is good they just need to be given the atmosphere so that the goodness can come out. Oh yes,I was naive. And now the show has come to an end. What an escape it has served for me from the boring ,sometimes terrible life. To know that I can watch this show and i will laugh my guts out no matter how terrible my life is. It has been one hell of a ride and i have enjoyed every bit of it.
This was the first(and only) show I followed religiously and probably the last one. And yeah i have laughed,i have cried,i have felt sad and i have felt rejuvenated .I cried when barney broke up with Nora and asked robin to do the same with Kevin but she didnt. I cried when ted was left at the altar. I laughed when barney used to pull tricks out of his playbook.I laughed hysterically at times. It has been a surreal experience to say the least.
The best part is the show was so relate-able.Haven't every one met a hopeless romantic in their life(ted), or a delusional and funny guy like barney, or a career oriented go-getter like robin or a lovely couple like Marshall and Lily. Yes, everyone has met each and every kind of person mentioned in the list above. And if you haven't then you need to live a lot more. It has taught a lot about life to me. People come , people go. They do everything to make you happy.And then dont even remember you on your birthday.They say you are the most important person in their life and throw you away as you were nothing.Some people stay for few days and some stay for more. No matter how much we try and hold on to those people they will soon be gone .And its not necessarily a bad thing.  You were with them for brief yet unforgettable time and no matter what happens , no matter how the things ended no one no one can take it away from you.Never ever in your life forget that on one day , you will step out of your front door and your life will change forever. Away from all the disappointments your life will soon change and it will be all happy and sad and funny and gloomy .But , above all it will be a life worth living with 100's of stories to tell. Whats the point of having lived a life if you cannot tell all that you did in your life to your children or your grand children.So live like you want, go big ,trust people,laugh hysterically,do stupid things ,cry , get hurt , work hard,party harder, do everything you want to,trust people,love them ,many will not be worth your love(i have found many in my journey) but who knows one fine day someone worth it will come and make a dull boring thing that you call life worth living.And lastly no matter what life throws at you remember if you were honest with people and others were not ,you did everything you could to keep them in your life, and still were not able to,let them go dont let it break you.To have that emotional endurance needed to get yourself out of that loneliness and heartache will be tough but in the end it'll be worth it. It'll be fine in the end. It'll be great but till then keeping living keep learning and keep laughing at your troubles because one fucking day they will be over and you will be happy. Make friends make tonnes of them because they will all be a part of those stories you will be telling 50 years from now.And if you havent done anything mentioned above till now.Go out right  now, no matter how sad your life is.Look at the stars,the moon, feel the chill of the wind and you will know life may be sad right now but its beautiful and it will remain so forever.And above anything love everyone around you because "love is the best thing we do" . 

Its been one hell of a journey and HIMYM you will be missed.


Saturday, March 22, 2014

Khud ko tha mai ranbeer smjhta, Katrina si woh lagti thi...

Writing after a long time.One of my oldest poem.Hope you like it :)



1st year ki masti thi,
apni bhi alag tab hasti thi...
khud ko tha main ranbeer samjhta,
katrina si woh lagti thi...!

ek baar kabhi anjaane begaane no. se call mjhe aaie,
ek meethi se awaaz receiver se aaie,
physics ke notes dede mujhe,
yeh! instruction introduction se pehle aaie...



ushki awaaz ne mujhko aisa mohya,
bhramachari sa vyakti ladki ke khwabon mai khoya,
20 minute tak north gate pe ruka aur soya,
metro tak sath chalenge mann mein ye sapna tha boya...

tabhi rickshaw se ek apsara utri,
notes liye, ushi rickshaw mein baithi aur chaldi...
north gate ke guard ne dekha aur bola,
bhaiya! tera toh bohot bade wala katta hai hoya...

ek pyaari si hasi hoton pe fir bhi khila krti thi,
jab bhi nesci ya zayca mai woh apsara mujhko mila krti thi,
khud ko tha main ranbeer samjhta,
katrina si woh lagti thi...!

samay ka pahiya aisa ghuma,
end sem aane lage,
physics ki relativity,
chemistry ki electro-negativity,
english ki subjectivity,
metals ki weld-ability,
maths ki complexity,

sab main sir aisa ghuma,
katrina ko akela chodd,
jaggi mathur ke maths ko tha bas maine chuma,

after that to impress my katrina,
i went to a showroom and bought a new puma,

(koi line jaa nhi rhi thi)
exam times mein kabhi-kabhi
e.d ke doubts woh mujse pucha krti thi,
doubts ka answer dene ke chakkar mein,
e.d bhi aasaan laga krti thi,
side view; top view; front view ki uljhone ko suljhane ke bad bhi
sardi ki dhoop si mujhe woh lagti thi,
khud ko tha mai ranbeer samjhta,
katrina si woh lgti thi...!

ek din school ke dost ka col aya,
pucha humare sath ambience ghumne aega?
maine bhi jhath se han bola,
mje kya pta tha yeh han mjhe baad mai bht sataega,
doston k sath tha gadi mai,tabhi phone baja,
kisko pta tha pebbles ka col tabhi hi aaega,
phne uthaya to dost sataenge,kat diya toh ldki naraaaz,
kisne socha tha aisa trivial sa dilemma bhi ek din,
jee cleared student ko sataega,
tbhi bahana mara,ki mum ka col aya h,
kisne socha tha ki ladki se baat krne k style se,
kiska phone tha doston ko pta chl jaega,
15 minute baat hui,phne rkha,
tbhi piche se awaaz ayi,
beta rehne do...!! tumse naaa ho paega...!!

bohot achi dost ban gyi thi woh,
sukh dukh ki sathi woh lagti thi,
khud ko tha main ranbeer samjhta,
katrina si woh lgti thi...!

ek din usne mjhe electronics padhaya,
tbhi uske crush ka call aaya,
mera ek ek ansun amplify hogya,
ignore kiya woh call aur uski aknhon mai kahin kho gya,
phone rkha usne meri meri taraf pyar sa smile kiya,
mjhe tbhi lga shayad uska dil mere dil k sath 0 degree in phase hgya....

jab usne diya class mai answer,
ushki sureele awaaz mein kahin kho gya,
low pass high pass ka toh pta nhi,
par mera dil band pas filter hogya,
ab toh uski awaaaz kano mai resonate hone lagti thi,
khud ko tha mai ranbeer smjhta,
katrina si woh lagti thi...!

4th sem tak ate ate,
d.s ka subject agya,
avl tress ka insertn deletion upar se bypass hogya,
uske pas gya mai doubt leke,
usne aisa smjhya,
ki O(logn) ka to pta nhi,
dil mera O(1) mai uska hgya...

ab toh sali recursion bhi easy si lagne lgti thi,
khud ko tha main ranbeer samjhta,
katrina si woh lagti thi...!

ladai hui use fir,
shayad galti bhi meri thi,
baat honi band ho gayi,
dosti bhi apni shayad maili thi..
dil mein basaya tha jisko,
aaj use wahan se nikalne ki koshish krne lga,
dil tha sala mera,
par property uski hi lagti thi...

khud ko hun ab bhi ranbeer smjhta,
katrina si ab bhi woh lgti h,
khud ko hu ab bhi ranbeer smjhta,
katrina si ab bhi woh lgti h...!


so that's it..its a long one..i hope u like it :)
P.s: the poem is purely fictitious and any resemblance  to any person living or dead is purely coincidental :)

Monday, February 3, 2014

Codeforces Round #228 (Div. 2)

This is my first editorial for the Codeforces rounds...please share your views....as to how it can be improved...the coding round was held on 3rd February form 9:00 pm IST to 11:00 pm IST

The contest was held on codeforces and the dashboard can be found here . I will now be discussing the algorithm that i used for each question and how did I implement the solutions.

A.FOX AND NUMBER GAME.

The question was really easy.However i thought of a little complex solution for it and thus wasted a lot of time debugging.Got only 458 points for it and wasted 21 minutes on it.

Question: 

The question was we were given and array of n numbers.let is be a such that of 1<=a[i]<=100.Now we had an operation to chose any two indexes of the array i and j such that a[i]>a[j] and do the operation a[i]=a[i]-a[j].We can do as many operations on a single element as we want.Now we were supposed to output the least possible sum of all such elements after application of all the operation.It can be found here.

example:
input
3
2 4 6
output
6

Explanation: we chose 6 and do a[2]=6-4=2
and then we do a[1]=4-2=2
so array becomes 2 2 2
and sum is 6 and hence the answer.

Idea:

The idea was very simple.I needed to subtract the largest number smaller than the given number from the given number in the array until such a subtraction wasnt possible anymore.So what i did was maintained a frequency array to maintain the count of all the number occurring in the array and then started from the max number  and kept on subtracting from the largest number smaller than the number in the array until the subtraction was possible i.e a smaller number than the result of the operation existed in the array.

C++ code can be found here.

B.FOX AND CROSS

Again the question was really easy.And it took less time to be completed than the 1st ques itself.I submitted it in like 14 after i submitted A and got 860 points for it.

Question:

Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a symbol '#'.
A cross on the board is a connected set of exactly five cells of the board that looks like a cross. The picture below shows how it looks.
Ciel wants to draw several (may be zero) crosses on the board. Each cross must cover exactly five cells with symbols '#', and any cell with symbol '#' must belong to some cross. No two crosses can share a cell.
Please, tell Ciel if she can draw the crosses in the described way.

Sample test(s)
input
5
.#...
####.
.####
...#.
.....
output
YES

IDEA:

Idea was again very simple.I checked for every # in the array if it was the center of any cross as shown above in the picture.If it was i removed all the '#' of the cross and replaced it by '.'.Now i again checked the 2-d array to see if there were any '#' left.If there were the answer was 'NO' else it was 'YES'.

Code can be found here.

C.FOX AND BOX ACCUMULATION 

Question:

Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box).
Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For example, imagine Ciel has three boxes: the first has strength 2, the second has strength 1 and the third has strength 1. She cannot put the second and the third box simultaneously directly on the top of the first one. But she can put the second box directly on the top of the first one, and then the third box directly on the top of the second one. We will call such a construction of boxes a pile.
Fox Ciel wants to construct piles from all the boxes. Each pile will contain some boxes from top to bottom, and there cannot be more than xi boxes on the top of i-th box. What is the minimal number of piles she needs to construct?
Sample test(s)
input
3
0 0 10
output
2
In example 1, one optimal way is to build 2 piles: the first pile contains boxes 1 and 3 (from top to bottom), the second pile contains only box 2.

IDEA:

I struggled with this problem a lot.Initially i tried to put the largest strength box at the bottom and then put a box with either equal strength or a lower strength on top of it and then count number of such piles.However it was failing on this case
3
0 0 0 1 1 1 2 2 10

it gave the output as 5.However the output for this will be 3.The stacks or piles for the given test can be arranged as:
pile 1: 10=>1=>0
pile 2: 2=>1=>0
pile 3: 2=>1=>0

I tried various variants of my algorithm but almost all of them failed on pretest cases 10 and 11.Then a friend of mine suggested what if we did the reverse.Chose the lowest strength box and then put the larger strength boxes below it.I tried implementing it and it worked.All the pretests passed.The solution passed system testing too.
So for the above test case this would work as follows:

PILE 1: we will 1st use box of strength 0.Now we have to use a box of strength 1 or greater than 1 as the size of the pile is 1.So we put box of strength 1 below the 1st box.After that applying the same logic till I cannot not put any more boxes below the last one I get my 1st pile as 
10=>2=>1=>0
repeating the above algo we get
PILE 3:
2=>1=>0
PILE 1:
1=>0
so we get three piles and thus the algorithm works fine for the given test case.
The code to this problem can be found here.

RESULT: 

I was not able to do D and E questions .Also, i wasted a lot of time in A and C.I need to work on my speed and accuracy.Overall i was not happy with my performance but than it was not bad at all.Finished 666.I hope you guys benefit from this Editorial. If there are any mistakes please point out in the comments section below.This was my first such editorial and i hope you  guys like it.Till the next time bye bye!! 

Sunday, January 26, 2014

Love demystified

"Fill your life with love. But you will say, "We always love." And I tell you, you rarely love. You might be longing for love…and there is a vast difference between the two. To love and to need love are two very different things. Most of us remain like children all our lives because everyone is looking for love. To love is a very mysterious thing; to long for love is a very childish thing. Small children want love; when the mother gives them love they grow. They want love from others also and the family loves them. Then when they grow older, if they are husbands they want love from their wives, if they are wives they want love from their husbands.

And whoever wants love suffers because love cannot be asked for, love can only be given. In wanting there is no certainty that you will get it. And if the person from whom you expect love also expects love from you, it is a problem. It will be like two beggars meeting and begging together. All over the world there are marital problems between husbands and wives, and the only reason for this is that both expect love from each other but are unable to give love.Think about this a little – your constant need for love. You want someone to love you, and if someone loves you you feel good. But what you don't know is that the other loves you only because he wants you to love him. It is just like someone throwing bait to fish: he does not throw it for the fish to eat, he throws it to catch the fish. He does not want to give it to the fish, he only does it because he wants the fish. All the people that you see in love around you are only throwing bait to get love. They will throw the bait for a while, until the other person starts feeling that there is a possibility of getting love from this person. Then he too will start showing some love until eventually they realize that both of them are beggars. They have made a mistake: each had thought the other was an emperor. And in time each one realizes that he is not getting any love from the other, and that's when the friction starts."
-OSHO

I read this awesome quote at a site and it intrigued me.So may be thats what love is.Here are my $0.02.

May be its not something you can have but only something you can give. But then why will anyone love anyone and not expect it in return.May be its just an illusion of the wanting someone to be with you through the ups and downs of life. Just an illusion. Or may be its just chemicals like dopamine and norepinephrine (no no i didnt become some expert on chemistry leaving my beloved computer science aside if thats what you thought) playing havoc with our brain,forcing us to behave differently.Or may be its an imaginary feeling that directors and producers use to make money.


For me love is the strongest ,the poorest and the most beautiful of all human emotions. Strongest because i dont think any emotion can overpower it.Poorest because it makes you feel dodgy in your knees.It makes you weak. Suddenly you have something to lose.As a famous dialogue of the movie Fight club goes "It's only when you lose evrything that you are free to do anything" , that feeling of losing something makes everyone inhibited , weak and just not themselves. Another quote from another movie "Love is your biggest enemy. It weakens you. Puts doubts in your mind. Suddenly you have something to lose."


 But then isnt it one of the most beautiful feelings in the world??to be loved by someone.Its the only time in your life, I truly believe, you find someone who can completely turn your world around. You tell them things that you’ve never shared with another soul and they absorb everything you say and actually want to hear more. You share hopes for the future, dreams that will never come true, goals that were never achieved and the many disappointments life has thrown at you. When something wonderful happens, you can’t wait to tell them about it, knowing they will share in your excitement. They are not embarrassed to cry with you when you are hurting or laugh with you when you make a fool of yourself. Never do they hurt your feelings or make you feel like you are not good enough, but rather they build you up and show you the things about yourself that make you special and even beautiful. There is never any pressure, jealousy or competition but only a quiet calmness when they are around. You can be yourself and not worry about what they will think of you because they love you for who you are. The things that seem insignificant to most people such as a note, song or walk become invaluable treasures kept safe in your heart to cherish forever. Memories of your childhood come back and are so clear and vivid it’s like being young again. Colours seem brighter and more brilliant. Laughter seems part of daily life where before it was infrequent or didn’t exist at all. A phone call or two during the day helps to get you through a long day’s work and always brings a smile to your face. In their presence, there’s no need for continuous conversation, but you find you’re quite content in just having them nearby. Things that never interested you before become fascinating because you know they are important to this person who is so special to you. You think of this person on every occasion and in everything you do. Simple things bring them to mind like a pale blue sky, gentle wind or even a storm cloud on the horizon. You open your heart knowing that there’s a chance it may be broken one day and in opening your heart, you experience a love and joy that you never dreamed possible. You find that being vulnerable is the only way to allow your heart to feel true pleasure that’s so real it scares you. You find strength in knowing you have a true friend and possibly a soul mate who will remain loyal to the end. Life seems completely different, exciting and worthwhile. Your only hope and security is in knowing that they are a part of your life.

Whatever love is you cant live with it and sure as hell cant live without it.I am confused and i feel its okay to feel that way once in a while specially on such a complex issue.Love may weigh you down but i believe it can lift you up too.

A long long post.I dont think anyone will read it completely but then if you do.Please comment and tell me if you liked it. Hasta la vista!!



First Post

It must be apt that I tell anyone who is reading this about myself in this first post. This is Shashank Gupta,currently pursuing B.E (computers) from Netaji Subhas Institute of Technology. An introvert, a guy with few friends ,very opinionated , gets ridiculously angry often,in short not perfect,in fact far from it.I Love competitive coding and thats practically the only thing i do.A Sports buff and a huge Rahul Dravid fan. I love to watch movies and my favorite one is Shawshank redemption as well as one little gem i recently watched Rush.

I will keep this short as lot of long post are about to come!!Till the next post Hasta la Vista !!