06 April 2014

Machine Graded Programming Tests

While doing my post-graduation in C-DAC — this was the 6 month full time PGDST (Post Graduate Diploma in Software Technology) course at E-city — we found that we'd pass the course only if we passed the minimum number of Machine Graded Programming Tests (MGPT's). These tests were similar to Google Code Jam, where you'd have to submit your program to a software program which will supply various inputs to your program and you pass the test only if each and every one of those inputs give the desired output.

It's a test that makes students very nervous, because let's say you're writing a program to accept a string and print whether it's a palindrome or not, some programmers won't consider the possibility that the program might receive an empty string as an input. The software which supplies such boundary conditions to your program, was called the "Parikshak" program, in C-DAC. We'd be given our questions and had 45 minutes to write our program on paper. Then, we could go to the lab where we had 45 minutes to type our program, correct it and keep feeding it into Parikshak. We used to wait in trepidation each time we submitted the program to Parikshak, and Parikshak would evaluate the program by supplying inputs to it and we'd see if the outputs were correct, by (if I remember correctly), "X" symbols for every correct output and "-" for every wrong output. If we got even a single "-", we got zero marks for the question, and had to correct our program and re-submit.

The challenge eased:
I decided to put this nervousness to rest by requesting the course coordinator to allow us to create our own questions for Parikshak, so that our classmates could attempt solving it and thereby be prepared for the real MGPT's. Nobody had ever attempted to do this in C-DAC, and our generous course coordinator was happy to allow us (two other programmer enthusiast classmates of mine, joined in) to volunteer. We called ourselves the "Mock MGPT team" (play rock music now for some effect). A few months later a third classmate joined the team. We became the B.RA.I.N.S team.
B - Binish
RA - RAghvendra
I - Ipe 
N - Navin
S - Shiv

So we set out on this new journey with the blessings of both our teachers and our classmates. For me, it was a creative journey too. These are some of the questions I created (just came across them today in an old email and thought I'd post it online):

Question 1:

PROBLEM STATEMENT:
A software error in a data entry software caused the string "MGPT" to get added to some institution names in a list of instutitions in Bangalore. When word got out, the principals of those institutions thought it a pretty good idea to introduce MGPT in their colleges. The students however, are worried, and have pleaded with you to remove MGPT from the list before the principals return from their tea break and take a final decision on the matter.

Your job is to write a program which will locate the "MGPT" string in the institution names and remove the string from the institution name.
If an institution name is CDAC (upper case, lower case or both), you are to leave the MGPT string in that institution name intact.
If the "MGPT" string occurs in any institution name, it will not occur more than once.
All institution names will begin with an alphabet.
Institution names may contain only alphabets, spaces and/or full stops.
The list of institution names not containing the MGPT strings have to be sorted alphabetically before being output.
The default priority for alphabetical sorting is: 1.Spaces, 2.Full stops, 3.Upper case letters 4.Lower case letters. (This is the same priority followed by the Java string handling functions)
The "MGPT" string may either consist of upper case or lower case letters.

INPUT:
The first input will be a number N, indicating the number of institution names that will follow.
N number of institution names will be provided, each on a new line.

OUTPUT:
The list of institution names, sorted alphabetically. Each on a new line.


SAMPLE INPUT:

7
Ammgptbc Institute of Technology
Z P College of EngineeringmGpt and Technology
Ghost ColMGptlege of Engineering
MGPTJanaloka Education Institute
JSM College of EngineeringmgpT
cmgPtDac
M. R. College of Engineering

SAMPLE OUTPUT:

Ambc Institute of Technology
Ghost College of Engineering
JSM College of Engineering
Janaloka Education Institute
M. R. College of Engineering
Z P College of Engineering and Technology
cmgPtDac


PROGRAM:
import ncst.pgdst.*;

class m
{

 public static void main(String[] args)throws IOException
 {
  SimpleInput s=new SimpleInput();
  int n=Integer.parseInt(s.readLine());
  String[] word=new String[n];//stores the original strings
  String[] big=new String[n];//strings converted to upper case
  String[] removed=new String[n];//strings with 'mgpt' removed
  for(int i=0;i  {
   word[i]=s.readLine();
   big[i]=word[i].toUpperCase();//convert it to upper case for ease of use
   removed[i]="";
  }//for

  for(int i=0;i  {
   int start=0,end=0;
   String w="";
   start=big[i].indexOf("MGPT");
   if (start>=0)//found the mgpt string
   {
    end=start+4;
    w=word[i].substring(0,start)+word[i].substring(end,word[i].length());
    String temp=w.toUpperCase();
    if (temp.compareTo("CDAC")==0) {w=word[i];}
   }//if
   else w=word[i];
   removed[i]=w;
  }//for

  //sort alphabetically
  for(int i=0;i  {
   for(int j=0;j   {
    if (removed[j].compareTo(removed[j+1])>0)
    {
     String temp=removed[j+1];
     removed[j+1]=removed[j];removed[j]=temp;
    }
   }//for
  }//for

  for(int i=0;i  {
   System.out.println(removed[i]);
  }
 }//main
}//class


-----------------------

Question 2 for Mock MGPT (classmates found this one very amusing)

When Tarzan came swinging to the CDAC campus, he heard of forests and trees being discussed in the classes. The CDAC'ians offered Tarzan three binary search trees to start swinging on, but Tarzan was afraid that if he tried to swing on a leaf node, he'd fall down.
A bunch of monkeys decided to help him with this. The monkeys would climb up onto the trees, according to their ages, in the same way that numbers are inserted into a binary search tree.
Any node which is not null is a node containing a monkey.

Tarzan doesn't like crash-landing on monkeys and he can't swing on the leaf of a tree, so he will swing only on VALID branches of the trees.
He differentiates between VALID branches and leaves (ie:leaf's) this way (this is a little different from conventional terminology)
A VALID branch is a node which is null and has a sibling node which contains a monkey.
A node is a leaf node if it is null and its sibling node is also null.

We will specify a swinging height for Tarzan (one swinging height will apply for all trees) so that he doesn't crash into the CDAC building. The swinging height is always greater than zero. Even if there is a single VALID branch at the specified height on a tree, Tarzan can swing on that tree.
Tarzan will be jumping from the CDAC building, onto the first tree, then to the second tree and then to the third tree, in that order. He doesn't jump after he reaches the third tree. Each time he jumps, he yells "OOOEEOOOYEEEOOOHH". If a tree doesn't have any VALID branches at the specified height, Tarzan falls down and yells "OOH AAH OUCH". Once he falls down, he doesn't attempt to jump onto any more trees.

You have to write a program to create three binary search trees and insert monkeys (age of the monkeys) into the trees. You should output the words that Tarzan yells when he attempts to jump onto the first tree, the second tree and the third tree. Assume the root node to be at a height of zero.


INPUT SPECIFICATION:
Three lines of numbers, each on a new line. The first number N of each line specifies that N numbers (these are the ages of the monkeys) are present after it on the same line. The first line of monkey ages are for insertion into the first binary tree, the second line for the second tree and so on.
One number on a new line, specifying the swinging height.

OUTPUT SPECIFICATION:
"OOOEEOOOYEEEOOOHH" (without quotes) if Tarzan can jump onto a tree with VALID nodes.
"OOH AAH OUCH" (without quotes) if he cannot land on a tree because it doesn't have VALID nodes at the specified height.

SAMPLE INPUT/OUTPUT:

Input1:
3 4 2 3
6 10 9 60 5 11 61
6 8 6 21 4 7 30
1

Output1:

OOOEEOOOYEEEOOOHH
OOH AAH OUCH

Input2:
3 4 2 3
6 10 9 60 5 11 61
6 8 6 21 4 7 30
2

Output2:
OOOEEOOOYEEEOOOHH
OOOEEOOOYEEEOOOHH
OOOEEOOOYEEEOOOHH

Input3:
4 4 2 3 5
6 10 9 60 5 11 61
6 8 6 21 4 7 30
1

Output3:
OOH AAH OUCH


PROGRAM:

import ncst.pgdst.*;

class t
{
 public static void main(String[] args)throws IOException
 {
  SimpleInput s=new SimpleInput();

  Node r1=new Node();
  int t=Integer.parseInt(s.readWord());
  for(int i=0;i
  Node r2=new Node();
  t=Integer.parseInt(s.readWord());
  for(int i=0;i
  Node r3=new Node();
  t=Integer.parseInt(s.readWord());
  for(int i=0;i
  int sHeight=Integer.parseInt(s.readWord());
  boolean fell=false;
      //check if first tree has VALID nodes
  if (r1.search(sHeight))
     System.out.println("OOOEEOOOYEEEOOOHH");
  else {System.out.println("OOH AAH OUCH");fell=true;}

  if (!fell)
     {//check if second tree has VALID nodes
      if (r2.search(sHeight))
         System.out.println("OOOEEOOOYEEEOOOHH");
      else {System.out.println("OOH AAH OUCH");fell=true;}
     }
  if (!fell)
     {//check if third tree has VALID nodes
      if (r3.search(sHeight))
         System.out.println("OOOEEOOOYEEEOOOHH");
      else {System.out.println("OOH AAH OUCH");fell=true;}
     }
 }//main
}//class

class Node
{
 Node left,right;
 int value;
 int height;

 Node() {left=null;right=null;value=0;height=0;}
 Node(int v, int h) {left=null;right=null;value=v;height=h;}

 public boolean search(int searchHeight)
 {
  boolean b=false,bv=false;
  if (height==searchHeight-1)
  {
   if ((right!=null && left==null) || (right==null && left!=null)) bv=true;
  }
  else
  {
   if (right!=null) {b=right.search(searchHeight);if (b) bv=true;}
   if (left!=null) {b=left.search(searchHeight);if (b) bv=true;}
  }
  return bv;
 }//search

 public void insert(int v)
 {
  if (value==0) value=v;
  else
  {
   if (v>value)
      {
       if (right==null) {Node n=new Node(v,height+1);right=n;} else right.insert(v);
      }
   else
      {
       if (left==null) {Node n=new Node(v,height+1);left=n;} else left.insert(v);
      }
  }//else
 }//insert

}//Node


--------------------

Question 3:

Students complained that bugs, which accidentally entered the Brinjal curry in the canteen food which they ate, were turning up as bugs in their software programs, which highly inconvenienced them while writing bug-free code during MGPT's.
Following these complaints, the canteen decided to install a device, capable of detecting and driving out bugs from the food with a K.N machine that emits special, patented Keeda-Naashak rays.

The food on a plate consists of many layers of food. Each layer is uniform in constitution, and is represented here with 5 characters. The character representation meaning is given below:
'P' is for a layer of Paapad. 'C' is for a layer of curry. 'R' is for a layer of rice.
'K' is a bug that can be present in any layer of food.
When a bug is present in a layer of food, the layer of food is represented with 4 food characters and one bug character.

The K.N machine emits rays laterally into a plate of food for 2 seconds. This irritates the bug, which immediately crawls up the layers of food and flies away when it reaches the surface.
The bug takes one second to crawl through a layer of food. The exception to this rule is that the bug takes 2 seconds to crawl through the curry layer.
If in the beginning the bug is in a layer of curry or once the bug passes through a layer of curry while crawling up, the bug always takes 2 seconds to crawl through ANY layer of food. Curry layers are not additive. ie: if a bug passes through two layers of curry, it won't take 2+(2+2) seconds to cross the layer. The time taken to cross the two layers of curry will be 2+2=4 seconds.

At the end of the 2 seconds for which the machine scans the food, if the bug is still in the food, the machine displays "KEEDA ALERT" (without quotes) on its screen. If there is no bug or if the bug has managed to reach the surface within the two seconds, the machine displays "CLEAN" (without quotes) on its screen.
You have to write a program to find out if at the end of the 2 seconds of scanning, would the food be bug-free or not. Your output will be the same as what is displayed on the screen of the K.N machine.

Assumptions:
1. The bug always crawls upward perpendicularly.
2. Assume that the number of layers of food will always be: number of layers >= 3 and number of layers <= 5
3. All inputs will be in upper-case characters
4. Assume that there can be only one or no bugs in a plate of food

INPUT:

One integer M, representing the number of plates to be scanned
M number of plate inputs will follow.
A plate input consists of:
One integer N on a new line, representing the number of layers of food in a plate.

N layers of food will follow, each on a new line.

OUTPUT:
"KEEDA ALERT" (without quotes) is displayed for a plate if it has a bug at the end of the two second scan.
"CLEAN" (without quotes) is displayed for a plate if it has no bug in it at the end of the two second scan.


SAMPLE INPUT:
5
4
PPPPP
PPPPP
CCCKC
RRRRR
3
PPPPP
CCCCC
KRRRR
3
PPPPP
RRRRR
KRRRR
5
PPPPP
PPPPP
RRRRR
RRRRK
CCCCC
3
CCCCC
PPPPP
RRRRR

SAMPLE OUTPUT:
KEEDA ALERT
KEEDA ALERT
CLEAN
KEEDA ALERT
CLEAN


CODE:
import ncst.pgdst.*;
class keeda
{
 public static void main(String[] args)throws IOException
 {
  SimpleInput s=new SimpleInput();
  int plates=Integer.parseInt(s.readWord());
  for(int j=0;j<plates;j++)
  {
   int n=Integer.parseInt(s.readWord()),foundInLayer=999;
   boolean alert=false,curry=false;
   for(int i=0;i<n;i++)
   {
    String layer=s.readWord();
    if (layer.indexOf("K")!=-1 && i>1) {foundInLayer=i;alert=true;}
    if (i<3 && layer.indexOf("C")!=-1) curry=true;
    if (foundInLayer==2) alert=curry;
   }//for i
   if (alert) System.out.println("KEEDA ALERT"); else System.out.println("CLEAN");
  }//for j
 }//main
}//class


And these were some of the questions my classmates created:
 
Problem 1:
 
Print the Fibonacci series which is prime number.
Fibonacci-series: A sequence of numbers in which each number equals the sum of the two preceding numbers.
For example: 2 3 5 8 13 21 34 55
Prime Numbers: A number which is divided only by 1 or itself.
(Note: 2 is a prime number).
For example: 3,5,13 etc.
You have to generate Fibonacci series and choose prime number among them and print it.

Input specification:
The first line of input will be two integers, a and b, separated by a space, specifying the first numbers in Fibonacci series.
The second line is also an integer, specifying the number of elements to be generated to check prime numbers.

Output specification:
The output contains only one line, containing each elements in Fibonacci series which should be prime number having single space between them.

Sample Input/Output:

Input:
2 3
5
Output:
2 3 5 13
 
 
 
Problem 2: LUCKY-5-PRIME

The objective of the program is to count the number of lucky-5-prime numbers occurring within a given range of integers. Lucky-5-prime numbers are those prime numbers the sum of whose digits add up to integer value 5. If the sum of digits of a number generates a two digit number add it's digits again to generate a single integer value.
For eg, 345=3+4+5=12
12=1+2=3

INPUT SPECIFICATION:
Input line contains two integers M and N which is the range of numbers
OUTPUT SPECIFICATION:
If number is found print LUCKY followed by the number of lucky 5 prime numbers after a space, terminated by a newline
If number is not found in the given range print NO LUCK terminated by a newline

Sample Input/Output:

Input
1 50
Output
LUCKY 3
 
 
Problem 3: Maximal Subsequence Problem:
Consider a series of numbers:
Eg: -2, 11, -4, 13,-5,-2
What is its maximal subsequence, i.e., a contiguous part of this series whose sum is maximum of all such subsequence?
Total sum is: 11
Subsequence <11,-4,13>= 20.(Maximum).
You have to write a program to find the maximal subsequence and print it with starting and last address. Assume position start with 1 and if there is more than one duplicate maximum then should be preferred first set of numbers.

Input specification:
The input will be single line containing an integer N, followed by N integers.
Output specification:
Only 3 values separated by single space
1st is maximum value.
2nd is position of first value.
3rd is position of second value.

Sample Input/Output:

Input:
8 -2 -3 45 25 -90 50 20 -1 -2
Output:
70 3 4

Input:
8 23 34 -90 34 5 6 7 98
Output:
150 4 8


Problem 4:
Create a stack consisting of the following elements : {32,29,24,20,12}. Observe that the stack created is arranged in
descending order from bottom to "top"(Top is the
upper bound of the stack from where insertions and deletions take place.) Given an ITEM to be pushed, insert into the
stack without disturbing the order of elements,
i.e stack should be in descending order even after insertion of ITEM and also without disturbing the property of stack.
Input Specification:
One line of input consisting of an integer value ITEM, which is to be pushed into existing stack.
Output specification:
Print the steps involved in pushing the new item into the stack i.e to push an item print PUSH <item> and for popping out
an item print POP <item>.
The popped item is reinserted into the stack according to it's value. Terminate each step with a newline.

For eg.
Input
22
Output
POP 12
POP 20
PUSH 22
PUSH 20
PUSH 12

Input
24
Output
POP 12
POP 20
PUSH 24
PUSH 20
PUSH 12


Problem 5
Consider a fees payment counter. Students waiting for service form a queue. At the start, the queue is empty and time is zero. The service per student is 5 minute. The input to the program consists of an integer N followed by a sequence of integer and float values indicating the arrival time (in
minutes) and amount paid respectively by the student. The times are given as offset from the start of simulation. So that an input 50 means 50 minutes
from the start of the simulation.If value of N is equal to the value of the arrival time of the student you have to consider that the student had paid his
amount.

The sequence of input numbers is terminated by number-1.
A program must simulate the queue and print the following.
1. The number of students processed until N minutes from the start of the
simulation.
2. The total amount of fees submitted from the students at time=N minutes.

In the output, each value must be separated by a space. Terminate your output with a newline character. For doing the computation, you can assume that
if the counter is expected to be vacant at time T, the first student in the queue will be scheduled for service before counting is done for time T.

Assumptions:-

1.The given arrival times will be already in sorted order.
2.The no of students will always be less than 200.
3.The input will terminated by -1.

Input:-
17 3 200.0 7 110.0 8 6.3 8 20.9 10 300.0 -1

output:-
3 316.3

Few interested classmates regularly attempted the mock MGPT's. Some of them were the only ones to crack the real MGPT's too. The sessions were helpful in taking a bit of the tension away from our minds. If I may humbly mention, I was the first one in my class to crack the real MGPT's and eventually was the only one to pass my PGDST course in the first attempt, because I was the only one in a class of 38 (comprising of CS engineers and MCA grads), to clear the necessary number of MGPT's.

The FPGDST (one year course) students had it easy. Their MGPT's were extremely simple. We PGDST (half year course) students had it very tough. Clearing it was not only a challenge, it was satisfying to have given my best shot at something and winning!

05 April 2014

Conference: Open source for startups

My first self-motivated decision to be a part of the larger software community by attending a software conference today at IIM-B:

It was an interesting conference with a panel discussion : Doing Business With Open Source


Panel members
• Prof. Rahul De – Hewlett-Packard Chair Professor @ IIMB (Moderator)
• Ms. Mishi Choudhary, Legal Director @ New York based Software Freedom Law Center
• Mr. Charudath Doddanakatte, Co-Founder & CTO of MyCloudPortal
• Mr. Abinash Saikia,   Co-Founder, EnCloudEn
• Mr. Abhas Abhinav, Founder & CEO of DeepRoot Linux
• Mr. Rohan Joshi, Founder, WokenSoft

 An intro by prof.De and Ms.Mischi touched upon how the non-proprietary FOSS final product has no price signalling capability in the market (price being an indicator of quality) and how it affects the adoption rates of FOSS. About how to face competition in the market while using FOSS, especially since seeing it as a reusable repository of code isn't reliable because of the general lack of documentation and the high rate of disruption that the IT industry is bringing (books, and the old music industry disappearing at a high rate being one example).

The talk randomly encompassed points like
  • Warranties of performance of FOSS
  • What if the code that you're borrowing goes under
  • When to upstream code to contribute back to the community
  • Which license is best for reuse

Contributing to Open Source
Both Prof. De and the other panelists spoke of how the community benefits and improves, when we give back to it. Many people download free softwares, but rarely contribute back to it. The practice of contributing back has to be encouraged.

Is GPL bad?
Some panelists referred to the GPL with adjectives like 'plague', 'viral' and a 'cancer'. Indicating how whatever the GPL touches, becomes GPL too. Indeed, people seem to take a dislike to being forced to expose their code as open source :-) During the question-answer session that followed, I tried giving it a different perspective, that the GPL was more like the Midas touch, where whatever it touches becomes gold. Free software really could be considered the equivalent of gold. It's the hard-work of a lot of people, intellectual contribution and time that's being put into it.

Malicious code in free software
Ms. Mishi (she gives free legal service to Debian, OpenSSL etc.) tried encouraging people to make their softwares GPL, as you're giving back to the community, saying that you'd be able to use even the competitors code. Mr.Abhas adding to that, saying then, the competition will no longer be about the code, but about the services provided. I asked the panel about the issue of trust in such a scenario, where malicious code could also be part of open source software and there's no real way to verify it even if you have the code with you. Mr. Abhas rightly said it would depend on the reputation of the source of software, and on asking the lawyer among the panelists, Ms.Mishi replied, saying that what a lawyer would ask you in such a situation is, "you got something for free and you got screwed?", well there's nothing you can legally do in such a situation; but apparently banks like Goldman Sachs also use open source software.

Did you know that software which does not having any licensing is implicitly protected by the copyright law? One example being Qmail.

Helping hands
So how do people who write free software make money? Something I was surprised to learn, was that the people at the Apache software foundation made their money via day jobs and by teaching people about the free softwares they created. Apparently, groups like the Open Invention Network and the Software Freedom Law Center etc. provide a helping hand to entrepreneurs for legal issues that arise while using FOSS. They help with knowing which legal notices to ignore and which to escalate, especially because for a startup, it's necessary for them to focus on the product in order to grow and survive in the market, rather than spend time fighting legal battles. We were also introduced to a term called "defensive suspension". The free software people are just as savvy about intellectual property rights as companies creating proprietary software. They have lawyers (paid) to help them. The GPL violation foundation and the Software Freedom Conservancy also come to the help of entrepreneurs.

Patenting software
Long back when a senior person I know was encouraging people to apply for patents. I had done some of my own research to end up find out that India doesn't allow software patents. The same was mentioned in the conference. One person in the audience deferred by saying that patents are allowed for embedded software, to which Ms.Mishi replied that only an embedded device can be patented; the software itself won't be. *sigh* wish India would encourage patenting too. At least the Kerala government had taken a good step forward in wanting to be a nodal agency for FOSS.

Misc
The conference was also a nice way of networking with some interesting people who introduced me to sysplay, the computer club, linux trainings, sogo and deeprootlinux. There was also a cryptography wiz enthusiastically taking pics of everyone, for 'documentary evidence' as he called it. Weird.

I'd encourage more people to participate in such conferences and discussions (more than 200 people had been part of this conference). It's a very good way to expand your knowledge and meet enthusiastic people in the field.


Say thank you or donate

25 March 2014

Being comfortable while seated at your workstation

I've seen many people carrying the strict discipline they learnt in school to office too. In an environment where they have to be seated for hours at an end, they try their best to not complain and adjust. Many end up seriously damaging their health. A friend's sister ended up requiring spinal surgery because she tried her best to sit straight and stiff while working; ignoring her back pain all the while.

Some chairs are designed for people with long thighs. People with short thighs won't be able to adjust to it (and vice versa). Good news is, chairs can be adjusted. But I rarely see people doing it. I did.


Got the armrests removed and the back of the chair tightened and phew! It was such a relief to be able to sit comfortably!

More on adjustments: http://www.ccohs.ca/oshanswers/ergonomics/office/chair_adjusting.html

20 March 2014

My Creations

My story: During school days, when friends were merely playing computer games, I was creating games. That's how much I loved programming. My story has a lot of twists though. In 1998, schools had few computers, so my school devised a logic test. Only those who passed could study computer science (CS). I passed easily but classmates said CS is tough so I opted for commerce. My parents said that CS is the future and forced me to choose CS. My teacher said my math and physics score aren't good enough, so I may struggle with CS, and recommended commerce. Overjoyed, I told my parents this but they insisted on CS. After almost failing my first CS test, my CS teacher motivated me, realizing my struggle was just a lack of practical experience with computers. I used an old abandoned computer to practice. A classmate shared a book containing BASIC game program listings and I understood how games were made. I accidentally discovered the MS-DOS manual and discovered various OS commands. Soon I started building my own games and was among the top programmers in class. My math and physics scores also improved, and I was among the top 6 rankers in class. When the dot com bubble burst, software engineers were losing their jobs and the scare (similar to how engineers are being laid off in 2025 due to AI) made parents and relatives force me to take up the '"safer" mechanical engineering. Even while studying mech I continued programming, and seniors were surprised to find me in the library reading CS books. I became a mech engineer, but took up a software programming job, loved it and decided to study software formally at CDAC. Due to MGPT's, only I passed the tough course in a class full of CS students. Got a job in a defence company as software engineer, eventually wrote CS GATE, got rejected by colleges due to my mech degree and finally MSRUAS which rejected me initially, called back saying that I could join the multidisciplinary AI course. I completed my MTech in AI, becoming the first ranker in my class and publishing research papers in the field of AI. I finally officially became a CS engineer and had a dream fulfilled. Eventually the long hours of work and lack of proper sleep crippled me with chronic eye strain and I figured out how to solve it, but my screen time is seriously limited now as I can't afford to slip back into a state of chronic eye strain.

 
Hobby projects created during school/college

Most of my initial programs were created on a 286 computer which didn't have Windows installed. Only MS-DOS. Black and white monitor (so I had to imagine the colors when creating programs). Max speed of the computer: 20MHz. Hard disk capacity: 30MB :-) It was only after my engineering course that I got an internet connection at home, so the below programs are a result of hard-work and self-study of API's and documentation.

Jump-up: 
https://github.com/nav9/JumpUp
Some neighbour kids in 3rd and 4th grade used to enjoy this game (circa 1998-1999, when not many people had computers here). I guess it's because of the simplicity and the funny sounds I programmed into it. This was the first game I programmed (in GW-BASIC) when I was in 9th grade, and my little brother was crazy after it. He even beat my highscore! (he was too young to know that it was partly dependent on chance). The game was originally meant to have a scrolling screen like Google's dino game, but at that time my programming skills were very basic.




Bricks
https://github.com/nav9/Bricks
A game with ten levels of increasing difficulty and challenges. Created when in 10th grade. Was introduced to the term "cheat codes" at this point of time, and introduced this into the game. At times it gets hard to hit the last few bricks, so I recommend just using the cheat codes to see all the levels :-)



Maze
https://github.com/nav9/Maze
I used to create mazes on paper, and decided to program one too. It was a daunting task, setting up the arrays on large sheets of paper that I stuck together and then replicating the same on the computer. The maze was programmed with portals and wells (which you might fall into and die). It was also divided into 4 sections which made it very difficult to solve, because you had to remember the previous screens to find your way. My classmate tried it for three hours, and said he couldn't solve it (to date, I'm the only one who has solved it).








Digger
https://github.com/nav9/Digger
This was one game I really wanted to program. Had played it many years back on a cousin's computer, and wanted to play it at home too, so just created it myself. Wasn't familiar with Q-BASIC graphics at that time, so I used ASCII characters. It's a game with a digger machine digging through mud, collecting diamonds. Monsters try to destroy the machine and the machine is able to shoot at the monsters or drop sacks of money on them to kill them. The collapsed sacks can be collected to get more ammo. I created an initial version and then improved upon it. You can play the original retro digger game here: http://www.futrega.org/digger/




Calculator program
https://github.com/nav9/Calculator
Okay, this one was simple, but it was programmed to be user friendly by allowing the user to navigate from one key to another using the arrow keys and by providing a square root option (which I'm surprised that many calculators strangely still don't provide).



Mock antivirus program
https://github.com/nav9/MockAntiviruses
You'd recollect I was using my uncle's computer (which was infected with the NYB virus which we couldn't remove because the computer couldn't run any of the newer antiviruses), and I thought of pulling a prank on him. I created an antivirus interface which was pretty similar to the real MSAV antivirus interface of those days. The program pretends to scan the computer and pops up an alert that it found a boot sector virus which can't be removed. My uncle and my dad actually believed it! :-)
Apart from games, the annoying viruses were another reason I wanted to be a computer science engineer. For a short period of time in 9th or 10th grade, I planned to eventually join an antivirus company to help rid the world of these viruses.



Vein: An MS-DOS OS interface, like Windows
https://github.com/nav9/Vein---MS-DOS-OS-Interface
Since the commandline required a lot of typing and since the computer didn't have Windows, I created an interface (while in 11th grade) for interacting with MS-DOS. Pretty much like how the Windows graphical interface was created by Microsoft. This was a period of time when I discovered the MS-DOS help manual (similar to the Linux man pages) and spent quite some time learning a lot of new functionality.




Digger forever
https://github.com/nav9/Digger
Yes, the name is based on "Batman Forever" and the "forever" meant that I didn't intend to create another version of Digger after this. I wanted to make my Digger game closer to the actual game I had played at my cousin's house (now available here), so while doing my engineering, when the ISTE student chapter organized a state level hobby project competition, I borrowed my room-mate's computer for two weeks and created Digger with BASIC graphics (presented it along with my other games). And guess what? I won the competition with a Rs.2000 cash prize! Roommate got a generous treat and seniors were all-praise :-)  
[update] Just found the original of the printout my very-happy-seniors had put up on the college and hostel notice board after I won the prize. S.R.C is the abbreviation for Standout Recreation Club. I thought it meant "Outstanding Recreation Club", but a senior recently clarified that the club was created when their seniors were sent out of class and made to stand in the corridor :-)
 






My game received a kind review from Sparcie, who had similarly tried making a Digger game during his childhood.
 


Message decoder program
https://github.com/nav9/Decoder
Converting text from English to a cryptic language and vice versa being slow, I wrote a program for it. Also kept it flexible for it to be able to accept a new code sequence too.



Mechanical force visualization software
https://github.com/nav9/Unipar
A Civil engineering lecturer at my college asked me if I could create for him, a program which would show a 2D representation of the normal and tangential forces on a beam. He also wanted a simple graph to show the force distribution. By this time, I had derived 3D projection equations on my own (I didn't know this would be available on the internet, so I had actually drawn projections on paper and derived the equation by using whatever I learnt in trigonometry), so I took my lecturer completely by surprise by using the graphics of C (using the Turbo C compiler) and created the beam in 3D, as an application with full-fledged menus and an interactive graph. You can actually rotate the beam in 3D using arrow keys, feed in various values using textfields (all UI elements were manually programmed) and also load/save the values. When I look at the program today, I find it hard to believe that I actually programmed it at that age!


I now know the colours are atrocious. Engineers aren't taught about how to use colours well. However, now I've learnt the right use of colours from interaction designers.



Ben
https://github.com/nav9/Ben
I wanted to make a game like Dangerous Dave, and I began with Ben. But this program was left incomplete, since BASIC does not have the concept of threads. So on adding a monster in the second screen, gameplay became too slow (could have also been due to some other issue, but I didn't have the time to look into it back then). Was able to get over the tough part of programming multi-key input to make Ben jump around.




Robot arm project

I wanted to build a robot, but there was not a soul who was willing to help us or sponsor it. So my enterprising team members and I decided to build it from scratch. We designed the robot arm in AutoCAD, created prototypes with thermocol, did the filing, drilling and cutting on our own in the workshop and built a working model which could be controlled with conducting copper strips on gloves. The arm was designed to be a stand-alone detachable arm which could be removed from the main structure and wrapped onto a human arm using velcro, becoming a bionic arm. Using just wrist movements, the 'jaw' would open and close. This was designed to be used by persons affected with leprosy. Our college appreciated the hard work and our applications for sponsorship were the first in our college to be accepted by the Karnataka State Council for Science and Technology. They fully funded our project and invited us to exhibit our project in Gulbarga at the KSCST exhibition.




Evolutionary algorithms

Examples I built, to showcase how evolutionary algorithms can solve highly multidimensional problems in a very short amount of time. Some of these videos were found by the creator of PyMunk, and he decided to add it to the PyMunk showcase page.



 
 
 

 
 
 

A simple Galton board 


 
 
 

Greasemonkey for auto-clicking a web-page

A certain page required clicking a link every time I visited the page. So I thought I'd automate the process with this code snippet. 

var element = document.getElementsByTagName("a"); // get element by tag namevar theEvent = document.createEvent("MouseEvent");
theEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 30, 79, false, false, false, false, 0, null);
//var element = document.getElementById('link');
element[0].dispatchEvent(theEvent);

Recursing directories
https://github.com/nav9/recursor

 
I wanted to be able to move recursively through directories to automatically delete those annoying Thumbs.db and desktop.ini files, so wrote a small python script for it. After writing it, I discovered that the functionality was already available in Python via the walk command ... *sigh* ... anyway at least there's the joy of creating a program on my own and being able to tweak it as I wish!
UPDATE: This functionality is now available in the file duplicate deletion program I built (mentioned below).
 
File duplicate removal

A handy program that finds duplicate files based on size and binary chunks. It then moves the duplicates to a separate folder. The program is also capable of recursing directories and deleting unnecessary files that the User specifies. There's also a feature to recognize duplicate images, irrespective of the file format or size of the image. I've also recently added a feature to undo actions performed.

Resting my eyes
https://github.com/nav9/System-Tray-Program
https://github.com/nav9/iRest

 

What's the point of knowing VC++ if you aren't using it to your advantage? I borrowed some open source code for a program which sits in the system tray in Windows, and modified it to start at logon and pop up a message at a specified interval of time, alerting a person to rest their eyes for 5 min. Strained-eyed friends and I found this program to be a boon. Of course when I found Eye Leo, I switched to it immediately.
Also created a Python program as a cross-platform solution.

Popup Destroyer
https://github.com/nav9/PopupDestroyer



A poor security setting created by someone, made an "Authentication required" popup appear whenever I opened a new page on my browser. The user just had to press Esc to make the popup go away and it was very annoying. So I wrote a sentinel program in VC++ to run in the background, scanning all window titles for the "Authentication required" string. When it found one, it'd immediately issue the Esc keypress command to the window automatically and the window would get closed. I used to enjoy watching those windows disappear while I continued with my work happily :-).


Volunteering website
See it working here: https://nav9.github.io/EmployeeVolunteeringWebsite/index.html
https://github.com/nav9/EmployeeVolunteeringWebsite

Our volunteering team in Tata Power SED needed a website and we decided to create it ourselves. I created an interactive prototype in 3 days and soon other volunteers pitched in to improve it further. We made good use of free and open source code available on the internet.



hashCSV
https://github.com/nav9/hashCSV
This I created for a friend in the field of data analytics, who needed to hash specific columns in CSV files. More about it here.


Snacker
https://github.com/nav9/snacker

At one of my previous workplaces, they decided to buy evening snacks everyday. Our office assistant used to go around asking a different employee everyday what snack to buy. Since this became a bit annoying for employees to choose (and others to grumble about the choice), I decided to automate it :-) I created a Java program which our office assistant could use, which would randomly select a snack and display it on the screen. A 'recent snacks' list avoided redundancy and if he rejected a snack, he'd be shown another random option. After a while, I noticed he wasn't so keen on using it. I investigated and found that he didn't understand the concept of brackets and commas in the JSON file which contained the snacks list :-) So I converted it into a CSV which he could open and edit in MS Excel. Obviously everyone was amused at an "AI" selecting their snacks for them. The COO said "...when we write a book about our startup, this is going to be one of the anecdotes in it...when we had trouble selecting snacks, one of our engineers wrote a program for it".


Groot GPT
Without writing any code, I used ChatGPT to generate the entire code for a chatbot which responded like Groot. Although it may be trivial now, it was a big deal in the early days of discovering ChatGPT. More about it and Prompt Engineering, here.

One of my clients needed some work done with FFMPEG, for their auto-video recording feature, and to save disk space they needed to reduce video quality too. Since video comparison tools were scarce, I spent some time and created this handy video comparison tool which allows you to compare multiple videos of even varied dimensions.



Auto-correcting audio-video async
https://github.com/nav9/audio_video_synchronizerThis is just a demo that needs a lot more work to be production-worthy. One of my clients had a problem with Zoom and Google Meet network traffic causing audio-video async in the recorded meeting videos. We couldn't fix the issue even using timestamps, since the async happened within Zoom's server/apps itself. So on a long weekend, I created this program as a demo to show that with a bit more work, we could indeed use AI to auto-fix the audio-video async. MediaPipe detected lip motion, and speech recognition was used to match the pauses in speech. The client couldn't proceed with it unfortunately, because of their compute budget being tight.
 

 
VCF files merger

A simple tool to help merge multiple Virtual Contact File (VCF) files. These are the vCard files used in smartphones. It automatically finds unique contacts and displays duplicate contacts for you to inspect. Contacts are analyzed for similarity based on the last few characters in the rows that store phone numbers.

Private Chat
Alt text
 
I noticed that I sometimes received advertisements based on the content of the messages I sent to my contacts. If chats were not really private and some algorithm was analyzing them, I wanted to make it private. So I prompted Google's Gemini and created Private Chat which allows encrypting messages before sending/receiving them across any other messaging platform.
 

Imager helps find image enhancement combinations and settings you may have never imagined. It also helps because there are so many settings that can be tweaked in so many ways that it gets exhausting to go through those permutations. Imager reduces the search to a simple selection of the best image and clicking "Evolve" to allow the algorithm to find the settings that bring the final result closer to how you wanted to enhance the image. Google's Gemini Pro generated a lot of the code for me.
 
 
Multi Recorder
Often when recording a video meeting, the screen recorder chooses the wrong audio channel and the audio does not get recorded, or the audio from one channel gets recorded and does not record the audio from the microphone. So to avoid having to make the User choose the correct channels, I created an application which can automatically detect all available channels for webcam, video, audio, microphone and also capture the screen. All these will automatically be saved to a folder and the User can later choose to merge them. (this project is still under development)
 
Linux AppImage Builder
Linux applications can be created as a standalone AppImage. The process to create it is unnecessarily complex and error prone, so I prompted Grok to build a GUI to automate the creation for Flutter apps that need to run on Linux, and requested the community to provide simpler options.

 
Food Contaminant Visualizer
A simple d3.js application I created to easily visualize which contaminants cause what issues, which foods may have such contaminants, how they are detected, and what their remedies are. I initially wished to build this as a full-fledged app which could display the human body in 3D and even recommend safe sources of food.
 



Android Apps

I've built many more apps for Android (by vibe-coding) than what is shown below, but it'll be a while until they can be published in Playstore.
 
Simple Notes
Some default android notes apps did not have the features I wanted. To be able to encrypt notes, export them and also be able to open the encrypted notes in Linux, changing the theme to dark, inserting the current time, merging notes, being able to search and replace and the obvious trust issue of whether the apps built by someone else could be siphoning away my private data. So I built one for myself by prompting ChatGPT.
https://github.com/nav9/simple_notes   (I made this repository private now)
 

Automatic Slideshow
I could not find any good slideshow app that showed the slideshow in the way I wanted, with the duration I wanted for each photo, scrolling the way I wanted, and with options to pause and play the way I wanted. So I built one for myself by prompting ChatGPT.
https://github.com/nav9/automatic_slideshow (I made this repository private now)


 
 

10 March 2014

Setting the fastdial page as your homepage

I've always found it more productive to have the fastdial (it's a Firefox addon like speeddial of Opera) page open for me whenever I open my browser.

The latest version though, didn't show fastdial as the homepage. So a bit of digging up got me this:

chrome://fastdial/content/fastdial.html

Use the above link as your homepage, set Firefox to open the homepage when you open the browser and set Fastdial to show up when you open a new tab, and you'll have your most-used websites at your fingertips with fastdial.



02 March 2014

A minimalist interface

Downloaded and started using the GitHub client for Windows today and noticed that they had designed the application to have a minimalist interface. So beautifully designed!

Creating a minimalist interface isn't easy though. Takes a lot of planning and guts to put on the screen nothing more than what is actually required. I'm a fan already :)

Here's Martin Fowler's views on it and the KISS principle which support it. GitHub client's interface also reminded me of the clever no-click interface created by the institute for interactive research.



Unite. A hobby project

Unite, is a project I began working on, when I wanted to re-learn web app programming. The project is designed to have a highly customizable front-end, a robust back-end and either a relational or a graph database. The project is hosted on GitHub under GPL v3. This is also meant to serve as a project that will give me a deeper understanding of using Git, continuous integration (Jenkins), Issue tracking (Trac), automated testing, automated code coverage checking, build scripting (Gradle), automated bug finding and deployment (Phew! Big target to achieve with the limited time I get everyday). This page captures the progress of the project.

Setting up the basics

Setting up a new project on GitHub was a breeze. Once done, I cloned the repository onto my local machine and using SmartGit, created an authentication token, the folder structures, spent an awful lot of time learning Gradle by myself and decided to use Gradle with Netbeans (which has Gradle support built-in) because the Eclipse plugin ended up giving me some errors during build. Setting up a continuous integration build right from the start was a practice I wanted to follow, so after installing Jenkins (tried Hudson too. It's good, but I liked Jenkins' interface better), it's plugins and successfully figuring out how to trigger a build on Git commit (this is a better approach than making Jenkins poll to check for code changes), the project was ready for some real coding.

D3.js as a general purpose data visualization library on the web

What would one do when one wants to use JavaScript to graphically display some data or statistics on a web-page? Use a library of course. I saw a lot of libraries, but was shocked at what d3.js had to offer. Just have a look at these:



Amazing! The initiators are Michael Bostock, Jeffrey Heer, Vadim Ogievetsky, who created d3.js (BSD license) based on the experience they had from the stepping stones of other similar projects that didn't work out very well.

It takes a while to figure out how to use d3. If you have a good understanding of JavaScript, you can start off right away. If not, the concepts of anonymous functions and closures will help you learn. Most of the impressive functionality can be implemented with just the d3.js file (319kB). A more compressed version of the file d3.min.js (144kB) is also available. More advanced functions are available in the supporting script files of d3.

A novice would find it surprising, the way d3.js works. By selecting elements of the DOM before they're even created. By passing variables like "d" and "i" internally, which don't seem to be declared anywhere.

But that's the challenge that makes it worth learning! D3 is a tool with which you can use on any area of the DOM. You can create any kind of visualization you want.

To make d3.js simpler, there are encapsulating libraries like nvd3, c3, cubism and rickshaw.

Went through the source code of d3 as usual, and was completely taken aback when I saw they've used the actual pi, phi and lambda symbols as variable names! Decided to ask my community, and here's what they had to say about it. Although it looks fancy, it's better to stick to variable names rather than symbols. Psst...if you want to generate pi on your screen, make sure the num lock on your keyboard is on; then keep the alt key pressed and type 227 on the num pad and you'll get the pi symbol like this ( π ). I pasted it in notepad, and it didn't turn into a junk character. Cool, isn't it?!
Jeff Atwood had an article on the use of unicode too (the 'entity' word is to be replaced by a heart symbol).

After dabbling with d3.js for about a week, I created an ajax program to query a servlet for data and display the retrieved data on a d3 graph. Worked like a charm!

A nice source for learning are the tutorials from the main website, practically trying it out a little, a free book and if that isn't enough, more than a thousand examples with sources, for you to refer. Definitely a work of art!