Showing posts with label Hacking. Show all posts
Showing posts with label Hacking. Show all posts

07 September 2011

Mobme Codejam - Solutions

    I hope you have read about Mobme Codejam here. 
Here are my solutions to some of the contest problems.

Mirror
    Write a program which when given links to two images on the Internet, finds out how similar they are.
Bonus points if it ranks images on a similarity scale from 0 - very different to 100 - exactly the same. 
Here is my Solution

Ternary
    Write a number generator that keeps printing out 10 digit numbers, one in each line. Write a second program called filter that takes the output of this number generator and filters it based on its first digit: if the first digit starts with 0, write it to a file named 0.txt, if the first digit is 1, write it to a file named 1.txt, and so on. Write a third program that when run keeps a watch on these files and prints out the count of numbers in these files every second.
Note: Three separate programs are required here.  
Here is my Solution

Tricolour
    Write a program which will generate the Indian national flag. 
Here is my Solution


Spell
    Write a spell checking program which checks an input text with help of an English dictionary. Remember: the spell checker is better if it manages to catch the most likely errors.
[Bonus points if you use cool data structures, like say, a Bloom filter] 
Here is my Solution

Sandbox
    Write a simple TCP server that supports the following commands:
  • list - Lists all the files in the directory the server is running on.
  • pwd - Print the path of the directory the server is running on.
  • cat - Print the contents of the filename given as argument.
  • rm - Delete the filename given as argument.
  • touch - Create a file with name and content given as argument.
  • time - Returns the current time on the server.
Also implement a simple client program that uses this server. The client must create a file every minute on the server with a random filename and with the content being the current server time. 
Here is my Solution

Invariant
    Consider the following process done on 4 digit numbers:
Take any four digit number which has at least 2 different digits. (1111 is not allowed, but 1112 is)
Arrange the digits first in descending order to get another 4 digit number (2111) and then in ascending order to get one more four digit number (1112). Add leading zeroes if necessary.
Subtract smaller number from the larger number (eg: 2111 - 1112 = 0990)
Repeat from step b
Example - Starting with 1112
2111 - 1112 = 0999
9990 - 0999 = 8991
9981 - 1899 = 8082
8820 - 0288 = 8532
8532 - 2358 = 6174
It’s an interesting fact that this process when done on 4 digit numbers always ends up at 6174 after a few iterations. In the example above, 1112 took 5 iterations to evaluate to 6174.

Write a program that performs the above operation on all valid 4 digit numbers from 1000-9998 and find out how many iterations it takes each number to evaluate to 6174.

Also: print a frequency distribution table with number of iterations needed to reach 6174 as one column and the total count of numbers corresponding to that iteration as another. [Bonus marks if you can represent this as a nice looking graph.]
Example Output:
Iteration Total Count of Numbers
    1       10
    2      151
    3      240

Here is my Solution 
Here is the github hub of the solutions - https://github.com/jithusunny/Mobme-Codejam

27 July 2011

Mobme Codejam

      This post is about a programming competition I participated in recently. Mobme Codejam...!
   
    Mobme Codejam is the name of an online programming competition that was conducted by Kerala-based IT-firm Mobme Wireless in June 2011. It was a 14 day long event in which the questions for each day were put at a website specially designed for the event. Every day a new question is out at 11pm. Contestants have 1 day for solving the questions. The contestants can program in any of five programming languages - C, Php, Python, Ruby, Clojure. A cash prize of Rs.1000 was awarded to the daily winners & a whooping 1 Lakh for the final lucky guy...!! The Grand finale winner is Karthik R from NIT-C.
        The questions were more dynamic/real-world type than traditional algorithmic problems. The question set is here. The philosophy is also different from other coding competitions. They look for idiomatic & elegant code. They support this view - the program is not only for the 'computers to execute' but also for the 'humans to read'. That's good..!

        I just thought of giving a try when I heard of this event. And to my surprise(!!) I was selected as the daily-winner on two days(codenames: 'mirror' & 'ternary'). I used Python, my favorite programming language, for solving both. The experience was fresh to me and I loved it very much - designing & solving(googling, ofcourse..!) and submitting it in time was absolutely thrilling. You can see the daily-prize winners here.
        The Grand finale was held at the Mobme Wireless Office at Kochi. A few words about Mobme. It is the result of a small group of young entrepreneurs from Kerala. Ruby is the major language used by them. They have bagged innovation awards from the NASSCOM twice. 
        The question for finale was to write a 'generic USSD application server'. I couldnt even write a working program for that. And I took it as an alert for me to learn at least the basics of web technologies. Now I'm working on it.. ;-) The winners program didnt work either. The prize was for his design. It should have been really ingenious..! I won't say 'I was not at all disappointed'. Yes, I was. But I had many other things - My first experience inside a real software company, Interaction with the 'very friendly' CEO, CTO and other persons at Mobme(they took us to 'Hotel Presidency' in their cars for lunch), the thrill of the climax of a different coding competition & most importantly I got a chance to meet and interact with other finalists, the best programmers in Kerala..!
        The next version of Mobme Codejam, probably a bigger event, would be conducted next year. 
        I will later put my prize winning codes here...till then byeeeee...:-)

Update: Here is the post about the solutions - http://jithusunnyk.blogspot.com/2011/09/mobme-codejam-solutions.html

03 October 2010

Unixhub

New hangout space for Unix lovers..!           wix.com/jithus/unixhub


I created a website using Wix. Discussion forum, Chat, Poll options are there. Links to useful websites and good articles are also included. Do check out and dont forget to give me feedback..:)

#Also checkout Wix - really cool. Just so easy.

17 January 2010

Hacker is a person who...!!

           The meaning of a word is the meaning that most people convey using that word. In the case of "Hacker", the majority conveys the wrong meaning. Wrong in the sense, not original. To many(mostly comprising of people not directly related to), hacking is breaking into private systems, stealing passwords, making profit out of confidential details etc.
          Hacker is a highly creative person who does brilliant work often concentrating in a specific field. Originally, the word "Hacker" was used in this sense in the Programming society. Eventhough it is more popular in the computer related contexts, it can be used in any discipline.
           To be more strict, there is a process in becoming a hacker. There is a culture and a community that has become the backbone of computer science-Free Software Community. Here hackers are respected by all and the word "HACKER" is considered as a prestigious label.

          The hacker's attitude and the subtle line characterizing "both types" of hacking is clearly presented by Brian Harvey,University of California, Berkeley at http://www.eecs.berkeley.edu/~bh/hacker.html