Contest experience – Infosys CampusConnect Aspirations 2020


https://vishnuramesh.wordpress.com/wp-content/uploads/2011/09/infoysys.jpg?w=155This is the first time I’m taking part in a real programming contest. Had so much fun and learned a lot more. My teammates were Sai Vikneshwar (Third year CS) and Aswin Akhilesh (Fourth Year CS). They are really good at this. I’m glad I got this opportunity to work with them. At first I had doubts if I could keep up with them. But it turned out to be a really good learning experience. There were 7questions and 5hours. Within the first our we read all the problems and started with what we felt was the easiest and could be submitted. The problems were pretty tough. The lab was pretty much filled up in the beginning. The contest was a crash course on vectors for me. I had never used vectors before. Knew it was really cool. We had to work using an arena which they supplied. The interface was pretty lame. And we had to stick to a directory structure which they specified. That again was lame. I did not like the lack of freedom. For all the problems they had supplied a header file containing a class and a function. We just had to complete the function according to the given instructions. This was the first time I’m dealing with problems like this. In the problems which I’ve seen before we just had to get the output correct. Anyway we managed to solve one problem. It had no compilation errors and worked perfectly with all test cases we tried. But the arena just refused to accept our program. It was compiling our program as if it was a c program, but ours was cpp. Anyway I learnt a lot today. I was able to keep up with the code 😀 Great experience. The last time I sat five hours at a stretch in lab was for our end semester lab exam for C programming in S2. But back then the problems were simple and we were working on mooshak. I really admire mooshak. Its a really cool software and fun to work with. Mooshak gave me my first A+ grade 🙂

Oh I also learned a lot about pointers, scope of variables, debugging and is the first time I’m actually noticing varriables getting destructed when their scope ends.

Operator overloading


Using Operator overloading we can overload operators to work with the classes defined by us. For example: consider I have a class to store complex numbers. I may now overload the + – = operators to work with objects of my complex class the way these operators work with int or float data types. This enables me to add objects of complex data type using the + operator. Well its a lot like functions. The only difference I could figure out was that if you use operators instead of functions, you feel like the code is more abstracted. Moreover I think it’s really cool. But I’m sure that there must have been a more beautiful goal behind operator overloading.

Note that just like a function an operator also has to be called by an object.

I studied operator overloading using the following program.


// to study operator overloading by implementing a class on coordinates of a point in space
#include <iostream>
using namespace std;

class coords {
int x,y,z;
public:
coords() {
x=y=z=0;
}
coords( int a , int b , int c ) {
x=a;
y=b;
z=c;
}
void print() {
cout << "(" << x << "," << y << "," << z << ")" ;
}
coords operator+ (coords op2) {
coords temp;
temp.x = x + op2.x;
temp.y = y + op2.y;
temp.z = z + op2.z;
return temp;
}
coords operator-() {
x=-x;
y=-y;
z=-z;
return *this;
}
};

int main() {
coords p1(10,20,30);
cout << "p1.print()\t\t" ;
p1.print();
cout << endl;
coords p2(1,2,3);
cout << "p2.print()\t\t" ;
p2.print();
cout << endl;
coords p3;
cout << "p3.print()\t\t" ;
p3.print();
cout << endl;
p3 = p1 + p2;
cout << "p3 = p1 + p2" << endl;
cout << "p3.print()\t\t" ;
p3.print();
cout << endl;
p3 = - p3;
cout << "p3 = - p3" << endl;
cout << "p3.print()\t\t" ;
p3.print();
cout << endl;
p3 = p1 + p2 + p3;
cout << "p3 = p1 + p2 + p3" << endl;;
cout << "p3.print()\t\t" ;
p3.print();
cout << endl;
return 0;
}

Output:


p1.print()        (10,20,30)
p2.print()        (1,2,3)
p3.print()        (0,0,0)
p3 = p1 + p2
p3.print()        (11,22,33)
p3 = - p3
p3.print()        (-11,-22,-33)
p3 = p1 + p2 + p3
p3.print()        (0,0,0)

Arduino Workshop


Arduino_uno_board
Arduino UNO

Arduino is an electronics platform which is meant for artists, students and hobbyists. It is extremely easy to use. Arduino was created at Interaction Design Institute Ivrea, Italy by Massimo Banzi and Casey Reas. It’s hardware and software is open source. This is the first time I’m hearing about open source hardware. It means that the layout and schematics of the hardware is available to the user. This means that anyone can make their own arduino board after refering the original schematics. I attended a workshop on arduino at Ettimadai Campus of Amrita Vishwa Vidyapeetham, thats how I know about it. Arduino is programmed using simple C language. Its IDE came bundled with a lot of examples to make anyone feel homely. Arduino UNO uses the ATmega328P microcontroller.

The workshop was conducted by Ajith Peter sir. He is an electronics enthusiast. He has a lot of sensors and shields. He let us play with all the cool stuff we had. He is really friendly. He is presently doing his PhD in IIT-B. The workshop was conducted by Dept of Computational Engineering and Networking. CEN’s HOD, Soman sir also presided over the workshop. He is an expert in maths. A talk with him helped me to visualize the first and second semester maths geometrically. I had no idea what they meant. He helped me relate it to the simple high school maths.

InduinoX Board
InduinoX Board

We did a lot of stuff with Arduino. The first program we did was to make the LED on the board blink. Ajith sir explained the importance of this simple piece of code. It is the equivalent of the “Hello World!” program which every programmer begins with. Arduino doesn’t come bundled with any in-built output devices, so debugging is a problem. This is where the simple blink comes to the rescue. You can insert the blink code between modules of your program to check their functionality. We played with a lot of sensors. We used the Passive Infra Red(PIR) sensor to build a motion detector. Ultrasonic range finder to findto any obstruction in front of the device. Then we used GPS module to get gps data and used the serial monitor to display the data. We even connected a LCD display to the arduino and learnt how to use it. We learnt about serial communication, UART (Universal Asynchronous Receiver Transmitter), I2C protocol. Ajith sir also showed us how to build a circuit board using toner transfer and told us about the importance of spacing and thickness of lines on a circuit board. He introduced us to softwares like Eagle CADsoft and fritzing which maybe used to build schematics of various circuits and then create the circuit board using toner transfer.

Arduino with music shield
Arduino with music shield
Ultrasonic sensor and PIR sensor
Ultrasonic sensor and PIR sensor
GPS module connected to Arduino
GPS module connected to Arduino

The workshop was fun-filled and at the same time very informative. We’re planning to conduct a similar workshop in Amritapuri campus.

Linux Command – cal


What it does : Displays the calendar  of the current month.

You can even specify the year or the month.

Example

cal

Now here is something interesting. Checkout September in the example given below.

Find out why that happened by referring the man page of cal.

Thanks to Anish Chandran Sir for showing this to me 🙂