Tuesday, November 17, 2009
IT Challenge
Well, today proved to be good.. i had my Project Management presentation approved without many problems. The second good thing happening was my qualification to Imagine Cup - IT Challenge Round 2. 16th November, 2009 witnessed the largest ever IT Challenge quiz organised by Microsoft in which about 1080 students from throughout the world participated. I eventually ranked 148th but consider it as a miracle coz the quiz was totally pitched into Network Administration using Microsoft tools. The results of the Round 1 can be found at http://imaginecup.com/Competition/Leaderboard.aspx The second round involves a case study following which 6 people from different countries will advance towards the Imagine Cup 2010 world finals to be held at Poland. Though the chances of qualification are next to nil... its definitely worth the effort!!
Wednesday, October 7, 2009
The MSP Programme
Today i got the good news that i had been selected as the Microsoft Student Partner. Its really a great initiative that microsoft takes to promote knowledge sharing between people across the globe. One of the cool benefits of being an MSP is that you will also receive a one-year subscription of MSDN Premium.There are also a variety of other awards throughout the year :)
Though im a student partner. im under probation till 21st of November until whn ive to earn 150 points to get the maximum benefits outta the program.. i am required to conduct some activities to introduce people to microsoft technologies.. lets hope i succeed...:)
Though im a student partner. im under probation till 21st of November until whn ive to earn 150 points to get the maximum benefits outta the program.. i am required to conduct some activities to introduce people to microsoft technologies.. lets hope i succeed...:)
Monday, October 5, 2009
ICPC Kanpur
One of the worse days of my life was the 4th October, 2009. ICPC Kanpur regionals left me dismayed because our team didnt perform well. Even when we were 11th at the 1st submission, we failed to solve any further problems.. some of us were too attached to our personal codes on the more difficult problem that left us with lesser time to attempt more easier problems that were accepted even on O(n!) ! Personally i feel that we freaked out just because the team combination wasnt good But as they say.. "every dark cloud has a silver lining". Even though i feel that this is a really dark cloud, the silver lining might be that such a contest has made me realize the does and donts of a programming contest. Hope we perform better at Amritapuri site..!
Sunday, September 13, 2009
ACM ICPC 2009
ICPC criterion for selection to onsite rounds was modified at Amritapuri this yr. Since ICPC aims at increasing the number of universities participating.. the selection criterion was something like the selection was confirmed for the top team of each university provided they have at least a code accepted.. In case there were less than 50 such teams, best performers would be chosen. Since most of the teams participating managed to solve at least one question.. almost at least one team from all participating colleges gets in. Even though our team "missingDigit" wasn't affected by it, but i feel that the criterion is unfair to be maintained because even teams who got three questions correct but ranked 2nd or 3rd in their institute are likely to be left out. But does this criterion actually make ICPC a "battle of brains" ??
Sunday, August 30, 2009
Fractals
Fractals are really amazing recursive shapes that can be generated with the least programming effort! I worked on the escape time fractals and was successfully able to code the "Mandelbrot set". I used SDL to generate a program in C. What came as an output was an amazing and beautiful fractal which im never tired of admiring. Depending upon the resolution the program might take from minutes to hours to generate a good fractal. The source code uses SDL and is given below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <windows.h>
#include <math.h>
# define ITR 10000
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
/*
PLEASE NOTE: the program will require SDL.dll which is located in
dev-c++'s dll directory. You have to copy it to you
program's home directory or the path.
*/
/* The screen surface */
SDL_Surface *screen = NULL;
/* This function draws to the screen; replace this with your own code! */
static void
draw ()
{
static int direction = 0;
static int value = 0;
static int which = 0;
SDL_Rect rect;
Uint32 b,w;
/* Create a black background */
b = SDL_MapRGB (screen->format, 0, 0, 0);
w = SDL_MapRGB (screen->format,255,255,255);
int it=0,br=2;
double x0,y0,x,y,t;
Uint32 color;
for(int i=-7120;i<2820;i++)
{
for(int j=-3840;j<3840;j++)
{
x=0;
y=0;
x0=i/(5120.0/1.5);
y0=j/(5120.0/1.5);
it=0;
while(it < ITR && (x*x+y*y)<=4)
{
it++;
t=x*x - y*y + x0 ;
y=2.0*x*y +y0 ;
x=t;
}
if(it==ITR)
{// If pixel is in the mandelbrot set and has successfully completed the iterations
putpixel(screen,7120+i,3840+j,b);
}
else
{
double col= it + (log(log(2))-log(log(t)) )/log(2);
color = SDL_MapRGB (screen->format,0,10*col,0);
putpixel(screen,7120+i,3840+j,color);
}
}
}
SDL_SaveBMP (screen,"fractal.bmp");
}
int main (int argc, char *argv[])
{
char *msg;
int done;
/* Initialize SDL */
if (SDL_Init (SDL_INIT_VIDEO) < 0)
{
sprintf (msg, "Couldn't initialize SDL: %s\n", SDL_GetError ());
MessageBox (0, msg, "Error", MB_ICONHAND);
free (msg);
exit (1);
}
atexit (SDL_Quit);
/* Set 640x480 16-bits video mode */
screen = SDL_SetVideoMode (10240,7680, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);
if (screen == NULL)
{
sprintf (msg, "Couldn't set 640x480x16 video mode: %s\n",
SDL_GetError ());
MessageBox (0, msg, "Error", MB_ICONHAND);
free (msg);
exit (2);
}
SDL_WM_SetCaption ("SDL MultiMedia Application", NULL);
draw ();
return 0;
}
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to set */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp) {
case 1:
*p = pixel;
break;
case 2:
*(Uint16 *)p = pixel;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel >> 16) & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = pixel & 0xff;
} else {
p[0] = pixel & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}
break;
case 4:
*(Uint32 *)p = pixel;
break;
}
}
The crux of the beauty of a fractal rests on it's coloring scheme. What i used was the Escape Time Algorithm for smooth colouring. Fractals can be made even more beautiful with a little innovation. Three dimensional effects can also be incorporated.. with only a little more effort..!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <windows.h>
#include <math.h>
# define ITR 10000
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
/*
PLEASE NOTE: the program will require SDL.dll which is located in
dev-c++'s dll directory. You have to copy it to you
program's home directory or the path.
*/
/* The screen surface */
SDL_Surface *screen = NULL;
/* This function draws to the screen; replace this with your own code! */
static void
draw ()
{
static int direction = 0;
static int value = 0;
static int which = 0;
SDL_Rect rect;
Uint32 b,w;
/* Create a black background */
b = SDL_MapRGB (screen->format, 0, 0, 0);
w = SDL_MapRGB (screen->format,255,255,255);
int it=0,br=2;
double x0,y0,x,y,t;
Uint32 color;
for(int i=-7120;i<2820;i++)
{
for(int j=-3840;j<3840;j++)
{
x=0;
y=0;
x0=i/(5120.0/1.5);
y0=j/(5120.0/1.5);
it=0;
while(it < ITR && (x*x+y*y)<=4)
{
it++;
t=x*x - y*y + x0 ;
y=2.0*x*y +y0 ;
x=t;
}
if(it==ITR)
{// If pixel is in the mandelbrot set and has successfully completed the iterations
putpixel(screen,7120+i,3840+j,b);
}
else
{
double col= it + (log(log(2))-log(log(t)) )/log(2);
color = SDL_MapRGB (screen->format,0,10*col,0);
putpixel(screen,7120+i,3840+j,color);
}
}
}
SDL_SaveBMP (screen,"fractal.bmp");
}
int main (int argc, char *argv[])
{
char *msg;
int done;
/* Initialize SDL */
if (SDL_Init (SDL_INIT_VIDEO) < 0)
{
sprintf (msg, "Couldn't initialize SDL: %s\n", SDL_GetError ());
MessageBox (0, msg, "Error", MB_ICONHAND);
free (msg);
exit (1);
}
atexit (SDL_Quit);
/* Set 640x480 16-bits video mode */
screen = SDL_SetVideoMode (10240,7680, 32, SDL_SWSURFACE | SDL_DOUBLEBUF);
if (screen == NULL)
{
sprintf (msg, "Couldn't set 640x480x16 video mode: %s\n",
SDL_GetError ());
MessageBox (0, msg, "Error", MB_ICONHAND);
free (msg);
exit (2);
}
SDL_WM_SetCaption ("SDL MultiMedia Application", NULL);
draw ();
return 0;
}
void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to set */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp) {
case 1:
*p = pixel;
break;
case 2:
*(Uint16 *)p = pixel;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel >> 16) & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = pixel & 0xff;
} else {
p[0] = pixel & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}
break;
case 4:
*(Uint32 *)p = pixel;
break;
}
}
The crux of the beauty of a fractal rests on it's coloring scheme. What i used was the Escape Time Algorithm for smooth colouring. Fractals can be made even more beautiful with a little innovation. Three dimensional effects can also be incorporated.. with only a little more effort..!
Subscribe to:
Comments (Atom)