December 31, 2019

it's never too late Don't give up keep going on.


It's never too late to try to achieve your dream!
it's never too late to learn something new!
it's never too late to experience something beautiful!
its never too late to keep on trying, no matter how many times you fail!
it's never too late...

There was a man, born a long time ago, 
Bought up in a simple middle-class family, his father was a long family man and use to work on his farm.
Lost his father when he was five years old, he was too young to realize what had happened.

At the age of seven, he learned to cook, to feed his younger siblings and his mom away working.
At the age of ten, he began working as a helper in the farmland and then took up job painting horse carriages,
At the age of thirty, he established a ferry boat company the ferry was an instant success and venture failure.

Lost many jobs than finally started running a service station that got failed after six years of works.
Many businesses failed, Almost bankrupt.

Decided to sell his recipe to the various restaurants,
Rejected for 1009 times

At the age of 65, he tasted success as KFC
Founder of Kentucky Fried Chicken.
He is colonel sanders

Don't give up keep going on. 


 

December 21, 2019

OSI Model Explained | OSI Animation | Open System Interconnection Model | OSI 7 layers Animation

Animated tutorial- OSI Model Explained




Thanks


A complete source code for Tic Tac Toe program in Java will be posted soon in this blog

December 14, 2019

Spiral unwinding a matrix interview question solved java source code

To unwind a matrix spirally to an array.

/**
 * Unwinding a matrix in java
 * Tested a 5 x 5 matrix
 */
package com.konzern.solution;

/**
 * @author Arjun Babu
 *
 */
public class Unwinding {

/**
* @param amazon
*/
public static void main(String[] hematcs) {
Unwinding unwindMatrix = new Unwinding();
int[][] matrix = unwindMatrix.getInput();
unwindMatrix.display(matrix);
int[] value = unwindMatrix.unwindMatix(matrix);
}

private void display(int[][] matrix) {
System.out.println("The Input Matrix \n");
int len = matrix.length;
for (int i = 0; i < len; i++) {
for (int j = 0; j < len; j++) {
System.out.print(matrix[i][j] + "\t");
}
System.out.println();
}

}

private int[] unwindMatix(int[][] matrix) {
System.out.println("\nThe Output Array \n");
int len = matrix.length;
int loopCount = len * len;
int data[] = new int[loopCount];
int flag = 0;
int maxRow = len - 1;
int maxCol = len - 1;
int minRow = 0;
int minCol = 0;
int row = 0;
int col = 0;
for (int i = 0; i < loopCount; i++) {
data[i] = matrix[row][col];
System.out.print(data[i] + " ");
switch (flag) {
case 0:
col = col + 1;
if (col > maxCol) {
col = maxCol;
row = row + 1;
minRow++;
flag = 1;
}
break;
case 1:
row = row + 1;
if (row > maxRow) {
row = maxRow;
col--;
maxCol--;
flag = 2;
}
break;
case 2:
col = col - 1;
if (col < minCol) {
row = row - 1;
col = col + 1;
maxRow--;
flag = 3;
}
break;

case 3:
row = row - 1;
if (row < minRow) {
row = row + 1;
col = col + 1;
minCol++;
flag = 0;
}
break;
default:
break;
}
}
return data;
}

private int[][] getInput() {
int matrix[][] = { { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 10 }, { 11, 12, 13, 14, 15 }, { 16, 17, 18, 19, 20 }, { 21, 22, 23, 24, 25 } };
return matrix;
}
}


The Input Matrix 

1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25

The Output Array 

1 2 3 4 5 10 15 20 25 24 23 22 21 16 11 6 7 8 9 14 19 18 17 12 13 


December 07, 2019

Unwinding a matrix in java

/**

Unwinding a matrix in java

 * Unwinding a matrix in java
 */
package com.konzern.solution;

/**
 * @author Gokul balan
 *
 */
public class Unwinding {

/**
* @param args
*/
public static void main(String[] args) {

Unwinding w = new Unwinding();
int[][] matrix = w.getInput();
w.display(matrix);
int[] value = w.unwindMatix(matrix);

}

private void display(int[][] matrix) {
int len = matrix.length;
for (int i = 0; i < len; i++) {
for (int j = 0; j < len; j++) {
System.out.print(matrix[i][j] + "\t");
}
System.out.println();
}

}

private int[] unwindMatix(int[][] matrix) {
int len = matrix.length;
int loopCount = len * len;
int data[] = new int[loopCount];
int flag = 0;
int maxRow = len - 1;
int maxCol = len - 1;
int row = 0;
int col = 0;
for (int i = 0; i < loopCount; i++) {
data[i] = matrix[row][col];
System.out.print(data[i] + "\t");
switch (flag) {
case 0:
row = row;
col = col + 1;
if (col > maxCol) {
col = maxCol;
row = row + 1;
flag = 1;
}
break;
case 1:
row = row + 1;
col = col;
if (row > maxRow) {
row = maxRow;
flag = 2;
maxCol--;
}
break;
case 2:
row = row;
col = col - 1;
if (col < 0) {
flag = 3;
maxRow--;
}
break;

case 3:
row = row - 1;
col = col;
if (row < 0) {
flag = 0;
}
break;
default:
break;
}

}

return data;
}

private int[][] getInput() {
int matrix[][] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
return matrix;
}

}


Output

The marix

1 2 3
4 5 6
7 8 9

After Unwinding

1 2 3 6 9 8 7 4  5

Getting the exception


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
at com.konzern.solution.Unwinding.unwindMatix(Unwinding.java:45)
at com.konzern.solution.Unwinding.main(Unwinding.java:20)


Source Code


/**
 * Unwinding a matrix in java
 */
package com.konzern.solution;

/**
 * @author Konzernites
 *
 */
public class Unwinding {

/**
* @param args
*/
public static void main(String[] args) {

Unwinding w = new Unwinding();
int[][] matrix = w.getInput();
w.display(matrix);
int[] value = w.unwindMatix(matrix);

}

private void display(int[][] matrix) {
int len = matrix.length;
for (int i = 0; i < len; i++) {
for (int j = 0; j < len; j++) {
System.out.print(matrix[i][j] + "\t");
}
System.out.println();
}

}

private int[] unwindMatix(int[][] matrix) {
int len = matrix.length;
int loopCount = len * len;
int data[] = new int[loopCount];
int flag = 0;
int maxRow = len - 1;
int maxCol = len - 1;
int minRow = 0;
int minCol = 0;
int row = 0;
int col = 0;
for (int i = 0; i < loopCount; i++) {
data[i] = matrix[row][col];
System.out.print(data[i] + "\t");
switch (flag) {
case 0:
row = row;
col = col + 1;
if (col > maxCol) {
col = maxCol;
row = row + 1;
flag = 1;
minRow++;
}
break;
case 1:
row = row + 1;
col = col;
if (row > maxRow) {
row = maxRow;
col--;
flag = 2;
maxCol--;
}
break;
case 2:
row = row;
col = col - 1;
if (col < minCol) {
row = row - 1;
col = col + 1;
flag = 3;
maxRow--;
}
break;

case 3:
row = row - 1;
col = col;
if (row < minRow) {
row = row + 1;
col = col + 1;
flag = 0;
}
break;
default:
break;
}

}

return data;
}

private int[][] getInput() {
int matrix[][] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
return matrix;
}

}


Output

The marix

1 2 3
4 5 6
7 8 9

After Unwinding

1 2 3 6 9 8 7 4  5

Tik Toc Toe in python, two player game, playing with computer complete source code available soon...

December 01, 2019

The Girl who knows to code - The Disappointed Day

The Disappointed Day



An aggressive shout from the Head of Technology Section.
 " What the hell he did ??? " 
" He and his scrap Ideas !!! "
 Shouting loudly, where people in a kilometre distance can hear his sound. 
Head who is a exaggerate in character was a half politician. 
He scolds the guy who came up with that solution. 
The solution was good enough, and the problem now happening was not due to the solution. The guy was disappointed much for giving a solution to the problem.
Head himself made that guy a scapegoat in many situations earlier already.
Failure in BIOS battery resets the system date to a past date since there is privilege restriction the ordinary users (unit staffs) cannot change the date, the only administrator can do it. 
So he could not log in to the software. 
Even replacing the battery could solve the issue permanently. 
People like these head are making the situation in many offices the worst. 
The subordinates even quit their job because of these peoples.

Facebook comments