## The advantages of knowing Computer Science

In India, Computer Science as a subject is mostly considered as a high status subject. It is as the top choice of all the top rankers in major entrance examination (for graduation) even though they really do not have any insight into programming. Ghastly isn't it. Its just a subject to get a good job.

Computer science is one subject I won't mind studying 16 hours a day because it interests me. Its not needed for any entrance examination I am going to give soon though. It is my get-away. A blissful world.

Recently my mother came up to me and handed me a maths problem. The problem reads:

"If you are given a total of Rs.100 (Rs. :Rupees, Indian currency) and 7 bags, How will you distribute the Rs.100 (in integral numbers) among the 7 bags so that if asked for any sum of money (from 1 to 100), you would just have to hand over certain number of those bags to achieve the denomination. You can hand in 1 bag or all the seven bags accordingly. "

I took the problem on a sheet of paper and put it away because I was busy with other stuff. I remembered having seen such a problem before and remembered faintly that the solution I saw was to do with geometric progressions. I continued my work without sparing a thought to the problem. I was doing physics. A subject which mattered for the entrance examination.

After a while, I finally became fed up with all the capacitors and my mind slowly began to drift over to thinking about what I had studied in computer science last night. Pretty soon, I was not drawing capacitors but a logical map of a program I had set for myself to practice ( I am still a new programmer and practice makes you perfect doesn't it). My eyes finally fell on the logic puzzle. I had taken it down as badly as I could and was having a hard time figuring out the writing. When I finally did, I read the puzzle out loud to myself. And the answer struck me immediately.

My mind had initially rejected the puzzle because it had the impression that it had to think over some geometric progression to get the answer. But when it was in its turbo state thinking about computer science, it evaluated the answer through the basics of computers devoid of any geometric sequence or any permutations. The logic was as simple as a gravy. I think I mean gravity but anyways. The logic was 1 byte.

Any person who knows how a computer works know that it is the 1's and the 0's that do the trick, And any person who dwelt further into it to find out how and why knows that 1 byte is an array of 8 bits where each bit has either 1 or 0 in it. With the combination of the 8 digits (containing only 1 and 0) you can obtain a number from 0 to 255. Any number! This is done in the following way:

ex: if the 1 byte looks like:

Computer science is one subject I won't mind studying 16 hours a day because it interests me. Its not needed for any entrance examination I am going to give soon though. It is my get-away. A blissful world.

Recently my mother came up to me and handed me a maths problem. The problem reads:

"If you are given a total of Rs.100 (Rs. :Rupees, Indian currency) and 7 bags, How will you distribute the Rs.100 (in integral numbers) among the 7 bags so that if asked for any sum of money (from 1 to 100), you would just have to hand over certain number of those bags to achieve the denomination. You can hand in 1 bag or all the seven bags accordingly. "

I took the problem on a sheet of paper and put it away because I was busy with other stuff. I remembered having seen such a problem before and remembered faintly that the solution I saw was to do with geometric progressions. I continued my work without sparing a thought to the problem. I was doing physics. A subject which mattered for the entrance examination.

After a while, I finally became fed up with all the capacitors and my mind slowly began to drift over to thinking about what I had studied in computer science last night. Pretty soon, I was not drawing capacitors but a logical map of a program I had set for myself to practice ( I am still a new programmer and practice makes you perfect doesn't it). My eyes finally fell on the logic puzzle. I had taken it down as badly as I could and was having a hard time figuring out the writing. When I finally did, I read the puzzle out loud to myself. And the answer struck me immediately.

My mind had initially rejected the puzzle because it had the impression that it had to think over some geometric progression to get the answer. But when it was in its turbo state thinking about computer science, it evaluated the answer through the basics of computers devoid of any geometric sequence or any permutations. The logic was as simple as a gravy. I think I mean gravity but anyways. The logic was 1 byte.

Any person who knows how a computer works know that it is the 1's and the 0's that do the trick, And any person who dwelt further into it to find out how and why knows that 1 byte is an array of 8 bits where each bit has either 1 or 0 in it. With the combination of the 8 digits (containing only 1 and 0) you can obtain a number from 0 to 255. Any number! This is done in the following way:

ex: if the 1 byte looks like:

**1 0 0 1 0 1 0 0**,all we need to do is multiply each bit (starting from the

**right**) with powers of 2 (from**0 to 7**) and add them up.Like this = (0x 2

^{7}) + (0 x 2^{6}) + (1 x 2^{5}) + ... +(1 x 2^{0}) = (0x128) + (0x64) + (1x32) + (0x16) + (1x8) + (0x4) + (0x2) + (1x1)

which will evaluate to = 32 + 8 + 1= 41 (which is indeed the conversion of 41(decimal) in binary).

Therefore, going back to the puzzle, we need only 7 bits, or bags. But if we really go by the above method word to word, we would end up with a total denomination of over 100. Hence we take only 6 bags and the 7th bag has 100 minus the amount already put in the bags. Our answer is therefore:

--

Ashutosh Rishi

Stay Hungry, Stay Foolish

Therefore, going back to the puzzle, we need only 7 bits, or bags. But if we really go by the above method word to word, we would end up with a total denomination of over 100. Hence we take only 6 bags and the 7th bag has 100 minus the amount already put in the bags. Our answer is therefore:

2

^{0}, 2^{1}, ... , 2^{4}, 2^{5}, (100 - the amount put in) i.e:**1 , 2 , 4 , 8 , 16 , 32 , 37 ---ANS**

(But this is just one of the many combinations we can have, this one just attracts me)

So you see, computer science is indeed helpful to know for gathering various skills. So next time anyone comes and tells me that do all the computer stuff later and do physics or chemistry or maths, I shall tell them this small story which is a part of many larger and wonderful stories dealing with the versatility of Computer Science. Well, it has 'science' in its name doesn't it?

And on a second thought, I solved a good puzzle in just 1 byte. Thats good programming. I am going to buy myself something now.

--

Ashutosh Rishi

Stay Hungry, Stay Foolish

Reactions: |