Archive for April, 2006




April 10th, 2006

Personal Blog

Sudoku solver in c programming! ha.. how in the wo…

Sudoku solver in c programming! ha.. how in the world is someone supposed to be able to prgram this after learning for 3 months.

#include 

void readGrid(FILE *fp, int grid[9][9]){   int i, j;   char ch;

   for (i = 0; i    {      for (j = 0; j       {         fscanf(fp, “%c”, &ch);         grid[i][j] = ch - ‘0′;      }      fscanf(fp, “%c”, &ch);   }}

void printGrid(int grid[9][9]){   int i, j;

   for (i = 0; i    {      for (j = 0; j       {         if (grid[i][j])            printf(”%i”, grid[i][j]);         else            printf(”.”);         if (j%3 == 2) printf(” “);      }      if (i%3 == 2)         printf(”\n”);      printf(”\n”);   }}

int possibleDigit(int grid[9][9], int x, int y, int digit){   int i, j;

   for (j = 0; j       if (grid[x][j] == digit)         return 0;

   for (i = 0; i       if (grid[i][y] == digit)         return 0;

   for (i = x/3*3; i       for (j = y/3*3; j          if (grid[i][j] == digit)            return 0;

   return 1;}

int solveSudoku(int grid[9][9]){   int i, j, k;

   for (i = 0; i     for (j = 0; j       if (!grid[i][j]) // if there is an empty cell at [i,j]      {         for (k = 1; k             if (possibleDigit(grid,i,j,k))            {               // set the empty cell to its possible digits one-by-one               grid[i][j] = k;  

               // call the next recursion to fill in the next empty cell               // and return 1 if the puzzle is solved               if (solveSudoku(grid))                  return 1;            } 

         // if all possibleDigits have been tried and failed,          // set empty cell back to 0 and return failure to the caller         grid[i][j] = 0;         return 0;            }

   // this is the base case where success is returned   // when all empty cells have been filled    return 1;}

int main(){   FILE *in;   int grid[9][9] = {{0}};

   in = fopen(”sudoku1.txt”,”r”);   if (in == NULL)   {      printf(”Error reading file\n”);      return 1;   }   else   {      readGrid(in, grid);

      printf(”START STATE\n”);      printf(”———–\n”);      printGrid(grid);

      solveSudoku(grid);

      printf(”FINAL STATE\n”);      printf(”———–\n”);      printGrid(grid);

      fclose(in);   }

   return 0;}

Wah… i throw in the towel already.

April 10th, 2006

Personal Blog

For all of those first generation nintendo players…

For all of those first generation nintendo players! Remember this?

I think it was my grandma who bought one for my cousins and us and we’d go to her house to play it whenever we were there. There were countless fights, spoilt cartridges, rented cartridges, and cleaning of cartridges cos of it. Haha… I even remember the first computer they had there too.. We played it till the monitor burned out!!! oh well. My grandma has since passed away long long time ago. Hmm.. yesterday went to my grandpa (paternal and maternal side), neighbour, the fan’s grandma and my great grandpa’s graves. Hmmm.. Sometimes i think thinking about it makes you feel sad. But if you just remember the funny happenings and the great things they did for you, i think its really cause to be happy just because they were in your life before.

Anyway, before i finish off here’s some nintendo music! heh.. mario, tetris, zelda, mortal kombat… some others even i can’t tell what they are.

April 6th, 2006

Personal Blog

wah!!!! i’m being smashed by super alot of stress …

wah!!!! i’m being smashed by super alot of stress man…

I’ve reached the burnout stage before i’m even close to finishing the syllabus for this sem and new stuff is still coming in! one more week of sch, one week of study, then the torrent of exams will arrive. 3 months and then it’ll happen again!

“The winners don’t do different things, they do things differently” - Jason

Now i’m really wondering what i’m doing wrong all these years. I think i’m mildly hyperactive and i cannot sit still but i’m thinking that if i can sit still to watch a movie, play a game or even to programme, then there’s something else that has to do with it. Argh! my goodness, my relaxed don’t need to study so extremey hard also can scrape through mentality is crumbling with each sem. I’m feeling more and more woefully inadequate to breeze through uni with a cap of 3 and above.

Anyway on to more normal things, Eng Joo is enlisting this sat! going to tekong with him. Think the girls want to lunch with him tomolo.. and i’m going also. Afterwhich i will adjourn to an interesting birthday dinner i suppose? oh well.

April 4th, 2006

Personal Blog

*inner monologue* yh: “I’ve never studied so muc…

*inner monologue*

yh: “I’ve never studied so much in my life before!”

yh: “wait… i think you’ve said that before…”

yh: “Well, i think this tops it all, compared to my previous levels of study la!”

yh: “i’ve got this feeling you’ll say this very soon again! like in 6 months time.”

yh: “yeah, me too.”

yh: “oh well, that makes one of us”

April 2nd, 2006

Personal Blog

I found these amusing.. haha.. From subtle,To …

I found these amusing.. haha..

From subtle,To corny,


To cool!

And i think this one’s the best… the monkey looks pretty funny

April 2nd, 2006

Personal Blog

Stress la, just stress la… totally man.

Stress la, just stress la… totally man.