manubuntu - is what I call my portable computer, with affection.

Thatdamnthing - is what I call my portable computer, without frustration.

It's come to a point where I can no longer ignore the lack of response to repeated finger workout sessions on the power button.

The screen stays black, the ventilation fans whirr, but nothing happens.

It makes for a great something-you-can-chuck-at-villian's-heads prop at these times.
evil villain image courtesy: Tarale on flickr.com
And if you can't find a villain, there's always a wall.

So, today I have enough time to backup the pictures I have taken but not done anything with so far. And then send manubuntu off to the cleaners.
Dad came back after a 30-hour shift. He then took my grandfather - mother's dad - to the Sankara eye hospital nearby. That was for a routine checkup. And in the end, grandad ended up getting laser surgery on his eye.

Here's a timeline of events:
Friday -
Dad leaves at 9 AM for work

Saturday -
Dad is back home at 4 AM
Leaves for the eye hospital at 11 AM
Back at 5 PM

Time spent awake: 32 hours

Grandad is seeing things much much better. Quite

You want to be great at your job, your relationships, and your life. You'd better count on being sleep-deprived a lot of the time.

That's something I'm going to be learning soon.

Now listening to an episode of You Look Nice Today - "Jobbo"

Which reminds me, I got my joining letter from TCS. Just one day after that big rant.

Passport Status Updated

Passport status
It was stuck at 'Waiting For Police Report' for the past three weeks.

A welcome change.

I need to

  • Become an SCJP
  • Design a kickass personal homepage
  • Help grandad get home
  • Road to fitness - take the first step
  • Do the AOL Advanced course, before which I do my kriya for 7 days in a row without too much flinching
  • Solve all the problems in the CodeChef practice set, post the solutions/code for those problems on the Internet
  • Get passport and all other documents required for TCS ready
  • Read all books in dad's DeBono collection
  • Fix dad's old Nikon
  • Fix the Sony Cybershot
  • Start a photoblog
  • Fix the timer in the desktop
  • Learn how to program in assembler
  • Pick up where I left off with C
  • Consolidate all my blogs into one familiar web resource, so that all my friends don't have to chase me around the web
  • Learn the art of self-defense (karate seems like a good option)
  • Learn how to fold shirts like mother
  • Learn how to put on a tie
  • Make a killing in the stock market
  • Develop a nice portfolio monitor for dad
  • Develop that game I came up with in mid-pee

Thoughts On The Long Wait For TCS

What prompted this?
I've found myself asking at times "Oh, mera number kab aayega!?" when I open my inbox and a bunch of new emails in which everybody has torn to pieces the latest bit of news that some college somewhere else, which nobody'd ever heard of had been batched. Anguish, disappointment, outrage.

While I was sucked into it initially, by and by I learnt that nothing but the disappointment of unmet expectations would come from this.

So, I thought about it, and asked myself...

Why worry?
Why worry about a date that could be 4 days from now, or even 4 months from now?

Why worry, when clearly, TCS has got far more important matters, like for instance keeping an organisation with a headcount larger than the population in a lot of countries running smoothly, all while adding more people at the same time?

Why worry, when you're dealing with a company that's got a lot of history, a well-respected organization which has time and time again kept up its promises?

Why worry, when you're young?

Why worry, when there are so many other opportunities out there besides thisto fall back in case it doesn't work out?

Sure, you've lost a lot of time, but 6 months isn't the rest of your life. It will seem like a tiny blip when you look back on it 40 years from now.

It's not our problem to figure out "When?" It's theirs.
Screw it! that's what I'm saying. They'll batch us when they can, and need us.

Continued harassing of the people at TCS is certainly not going to help the situation.
They're a big organisation, and since there are orders being passed down a chain of command taller than Mount Everest, there are differing levels of awareness at each level. The HR people like Arun keep getting calls from us, and all he can do is pacify us and stall for another 5 minutes before the next call, because there is very little he can do without the approval of 10 other managers across various departments - finance, recruitment, and so on...

What can I do in the meantime?
If you took a few moments and thought about it, this is time that you have been given to do some amazing stuff.

Go out and learn a new language. Go clubbing. Dance. Figure out how to write a word processor in assembly language. Solve a problem. Write a poem. Be silly. Do everything that you've wanted to do all when you were stuck attending dull lectures at college. Travel. Do all of this and more. Because if you think about it, this is time that you'll never ever get.

This surely isn't the time to be whining about whether the harrassed HR people at TCS are going to chalk off CMRIT on their big training blackboard. It really isn't.

A problem/solution approach:
If you can't help but think about this, then look at it as a problem that needs a solution. The problem can quite simply be described as uncertainty arising from a lack of information. What is a solution to this?

Communication - regular, and reliable.

TCS needs to have a blog of sorts where they put down a list of colleges that have been batched so far, and the next probable set of colleges to be batched. It'd be simple and effective. And at least, the amount of confusion regarding which grade each person's college falls into can be avoided.

Even a twitter profile should do the trick. Believe me, one thing they won't have is a shortage of followers.

Something easily accessible, they can even put it on NextStep if they want to restrict it to just students.

Right now, there are groups on social networking sites like orkut and facebook, that are relied on for information. But these are unofficial, and I'm just a little sceptical when it comes to relying on the information posted here.

It's particularly sad that there is nobody I've found at TCS making use of social networks to send information out to students. Maybe I've not searched hard enough, but they really should start something on those lines. It would definitely reduce the number of calls handled by the people at HR.

They should really think about this.

My position as of now.
Sometimes, there's some good news, and while I'm happy for the people who have been batched so far, and more recently, the non-CS* students from our college, for having been given a chance at something that's really going to be a possible future vertical that TCS is going to be involved in, and like all the CS students, I'm still left clutching at straws when it comes to my future with TCS.

But I've gotten some things crossed off my list. Not a lot, but it is definitely a start.

While, I'm not going to be happy now about not having anything but "Sure, January or February (or any month in 2010)" as an answer each time I'm asked "When?", I'm pretty sure the answer is soon in coming.

Till then, stop worrying, and start living. Life and the time-of-your-life is too precious to be wasted in worrying about some day in the future.

Just have a little faith, and enjoy yourselves. That's all I'm saying.

Apologies on the length of this, but I do hope you gained some perspective on this. This is not a definitive guide on how to spend 6 months while waiting for a joining date, that guide will be written by you, for you.

* I've seen the term non-CS take on some kind of discriminatory shade. Not good. They're engineers just like the rest, and they've worked equally hard (possibly more( to get through 4 years of VTU. Same goes for the grading of colleges. Does it even remotely matter who is better? And believe me, that is probably a subjective definition based on internal company policy. Which we can't figure out. So, why make assumptions?

Se7en

Probably has nothing to do with this. Just probably.

There's a guy named Tomek (I'd be surprised if there isn't something puzzley about that) who has 1337 (and this one too) friends on Facebook. Now he wants them to join in a big circle of hand-holding togetherness to celebrate the launch of Karmic Koala. (You Windows people throw house parties, we hold hands and look up at the sky. It's just the way we do it. (And yes, we are cooler!)

So, while on one of these weird hand-holding orgies, Tomek decides that they should bring an element of fun into the ritual (about time somebody did that!) and he starts playing a game of 7UP (no, this event is not sponsored or endorsed in any way by the popular brand of carbonated beverage!) where people count up from 1 up to infinity.

Now there's a twist to Tomek's game of 7UP. Counting goes upward continuously clockwise from whoever calls out 1 to begin the game. So, if person 1 calls out 1:

person 2 calls out 2

person 3 calls out 3

and so on...

till person 7 calls out 7

and person 6 calls out 8

person 5 calls out 9

and so on...

till person 1337 at the end of the circle (does that make any sense?) calls out 14

and then...

person 1 calls out 15

person 2 calls out 16

So, to end the counting and summarize the rules of the game:

  1. Each person calls out a number. The next person calls out the next number. The number to be called out is always incremented by one.


  2. The direction of counting starts clockwise from 1 to 1337.

  3. Direction reverses when a number that is:


    1. divisible by 7 (eg 7, 14...)

      OR


    2. contains the digit 7 (17, 27, 455677221, 7000)




So, those are the rules of the game.

Now, Tomek's a weirdo, (or we wouldn't be having this problem), so he wants us to write a program that can tell him where he has to stand if he wants to call out his favourite number.

So, if you were Tomek, what would your favourite number be? That's what we're writing this program for.

I came across this problem on the CodeChef website initially. And at the time I attempted to solve it, nobody had been able to submit a successful solution owing to length of time allotted for calculation a very generous ONE SECOND.

It does help if you look at that as ONE THOUSAND MILLISECONDS. A little.

So, I went to work on it. It sounded simple enough to write, but little did I realise that the number of elements to be processed would be HUGE if I merely brute forced this.

Imagine processing 100,000,000 elements checking each for divisibility and presence of 7! That's not good enough. And the running times proved it. When Tomek's favourite number is 100,000,000,000 we have around 3.5 minutes processing time. And to think that the size of the input can go up to 10100! We have something serious on our hands.

So, the question now is, could we optimize the algorithms used to determine divisibility and presence of 7 further or should we simply observe the state of the program over a period and see if there are any patterns that we can exploit? Which is simpler? Or more effective?

The answers to those questions are:

the first approach one is simpler, since there are plenty of well documented algorithms for that. Wikipedia has plenty of them. I used that one instead of using the standard % 7 == 0 test, since it increases the time required to process as the count goes up. But the first approach can only help so much.

The second approach brings maximum effectiveness since skipping over a bunch of elements which you know will anyway not contribute to the final answer eliminates the divisibility/presence tests associated with them.

So, your problem input size is probably reduced in size by half. And after much thought I decided to take a raw dump of the program as it worked. And ended up with a HUGE file after 3 test cases.

Will have to figure out the quirks and optimize.

The source for the program is attached. Documentation is something I'd love to do some more work on, but a work in progress is just that, it's a work in progress. This is the part where most programmer's like to spend time trying to play with code rather than document, so, I've tried explaining wherever I can. Links are also there to the pages where I got the algorithms from.

Will be posting a set of links here when I find the time.

How To Hurry Tomek's Ass Up (aka possible optimizations):



1. Who cares about the 70s, or the 700s, or the 70000000000000000000000000000000000000000s!


aka the remove the 7s way

Last night, as I was thinking about ways to optimize this, I realised that the processing required for complete blocks of the input could simply be eliminated.

Inputs of the form:

d* 7+ d* (d is any digit from 0-9)

viz. any range of concurrent numbers known to contain 7 in the same place. For example:

70 - 79


Here 10 numbers can be eliminated by simply adding 10 the count and keeping the direction of count the same. The counter does not change since the number of reversals is even as in:

caller 1 at 70

caller 1337 at 71

caller 1 at 72

caller 1337 at 73

and so on...

caller 1337 at 79

caller 1 at 80

caller 2 at 81

caller 1 at 82

and so on...

So, in effect, the person to call out the first number in the series is the person who counts the last number of the series. The direction of counting remains the same.

For larger inputs 7000-7999

caller 1 at 7000

caller 1337 at 7001

...

caller 1337 at 7999

caller 1 at 8000

1000 inputs skipped.

So, skip formula:

((10place of 7)) elements skipped and added to count. So the larger the input, the larger the skip.


After running some timing tests, this is what I found:


Test run without the remove 7s optimizations with an input of about 10,000,000,000 ran for 1 minute and 49 seconds.



And this is with the optimization:
1 minute and 12 seconds.



There is an improvement, definitely.
So, for such large inputs, we have a 1/3rd cut in running time.

While not as large an improvement as I expected, I am pleased to say that something worked.

Hotlinked. Oops!

I've not posted here for weeks. I noticed today that every time I was coming to the blog, I was being redirected to the wikipedia article on bandwidth theft. I spent some time puzzling over how this was happening. I was pretty sure I hadn't coded the page to do anything of that sort.

Then I realised it was a JS document.window.open() call, the target being the default, current window.

I found the source of the redirect being Kent Brewster's JS code snippet that had been changed since I put it on here. I hardly used it, it being here for just experimental purposes.

But as it turns Mr. Kent Brewster seemed to be getting a lot of traffic from people embedding identica badges on their websites. I didn't realise I was being irresponsible.

My apologies.