Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,586 members, 7,816,442 topics. Date: Friday, 03 May 2024 at 11:18 AM

Authurowen's Posts

Nairaland Forum / Authurowen's Profile / Authurowen's Posts

(1) (2) (of 2 pages)

Science/Technology / Startup Ideas: Startup Inspiration From The Public by authurowen(m): 10:09pm On Jul 15, 2015
...
Properties / Re: Sale/lease:5b/r Duplex @elebu Near Orita Challenge/apata Expr For 58m (pictures) by authurowen(m): 4:02pm On Mar 14, 2015
Place your ad on Kobolist.com.ng to get more views and potential buyers
Software/Programmer Market / Re: *URGENT** PHP Developers With Codeigniter & Mysql Needed by authurowen(m): 5:31pm On Oct 01, 2013
goldincome: I am a PHP Developer with indepth codeigniter experience. You did not leave your email address. This is my phone no:08037184179

I'm still waiting on your response @goldincome.

Drop me a line lets go from there.
Software/Programmer Market / Re: *URGENT** PHP Developers With Codeigniter & Mysql Needed by authurowen(m): 11:28pm On Sep 20, 2013
d
Software/Programmer Market / *URGENT** PHP Developers With Codeigniter & Mysql Needed by authurowen(m): 6:07pm On Sep 19, 2013
abc
Properties / Re: One/ Two Bedroom Bungalow On Sale In Mowe (ogun State) by authurowen(m): 5:45pm On Sep 18, 2013
Free Kobolist Nigeria local classifieds.
Visit KOBOLIST - http://wwww.kobolist.com for Nigeria's largest and most visited free classifieds site with millions of ads.

Categories include buy & sell, jobs, housing, vehicles, services, local community, and more.
Properties / Re: Fairly Used Lister Generator For Sale by authurowen(m): 5:44pm On Sep 18, 2013
Free Kobolist Nigeria local classifieds.
Visit KOBOLIST - http://wwww.kobolist.com for Nigeria's largest and most visited free classifieds site with millions of ads.

Categories include buy & sell, jobs, housing, vehicles, services, local community, and more.
Properties / Re: IF U Need Genue Lands In Badagry At An Affordable Price Call Me 08060989506 by authurowen(m): 5:44pm On Sep 18, 2013
Free Kobolist Nigeria local classifieds.
Visit KOBOLIST - http://wwww.kobolist.com for Nigeria's largest and most visited free classifieds site with millions of ads.

Categories include buy & sell, jobs, housing, vehicles, services, local community, and more.
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 10:49pm On Jul 04, 2013
abc
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 9:21pm On Jun 26, 2013
jacob05: @authurowen and how is your algo different from mine undecided.

Jacob, you are a developer. Can you take a closer look at your implementation and mine and see the difference?

Also try parsing the other test case i provided in my solution to your own solution and see what it returns.
secondly, Using your algorithm (which is wrong) after you're done printing the array, Your Master Array It will become empty (at a quick glance)
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 6:51pm On Jun 26, 2013
Be on the look out for the second part of the programming questions. I will open another thread for it.

Thanks for participating
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 6:50pm On Jun 26, 2013
Find below, my Implementation to the print spiral Question written in JAVA (There is very little difference btween C# and Java so C# Developers will be able to relate to it).

Pls Criticize to the very lowest details as much as you please.

public class PrintSpiral
{
private Object[][] matrix;

final int VERTICAL_UP = 0;
final int VERTICAL_DOWN = 1;
final int HORIZONTAL_LEFT = 2;
final int HORIZONTAL_RIGHT = 3;


public PrintSpiral(Object[][] matrix)
{
setMatrix(matrix);
}

/**
* Method to return a string representation of the matrix,
* traversing it in a spiral movement.
*
* @return spiral string representation of the matrix
*/
public String toSpiral()
{
int top, left;
top = left = 0;

int bottom, right;
bottom = right = matrixIsEmpty()? -1 : matrix.length -1;

return (matrix != null && matrix.length > 0) ? toSpiralHelper(left, right, top, bottom, HORIZONTAL_RIGHT) : "";
}

// Recursive method
// Logic here
// =============
// In a wider view, to traverse the matrix sprirally would visually mean
// -------->
// ------> |
// ||---> ||
// |<-----||
// <--------
//

/***
* @pre: Left <= Right & Top <= Bottom
* @Post: Left >= Right & Top >= Bottom
*/
private String toSpiralHelper(int top, int bottom, int left, int right, int direction)
{
StringBuilder b = new StringBuilder();


if(direction == HORIZONTAL_RIGHT && left <= right)
{
b.append(printForward(top, left, right));
top += 1;
b.append(toSpiralHelper(top, bottom, left, right, VERTICAL_DOWN));
}

if(direction == HORIZONTAL_LEFT && left <= right)
{
b.append(printReverse(bottom, left, right));
bottom -= 1;
b.append(toSpiralHelper(top, bottom, left, right, VERTICAL_UP));
}

if(direction == VERTICAL_DOWN && top <= bottom)
{
b.append(printDownwards(right, top, bottom));
right -= 1;
b.append(toSpiralHelper(top, bottom, left, right, HORIZONTAL_LEFT));
}

if(direction == VERTICAL_UP && top <= bottom)
{
b.append(printUpwards(left, top, bottom));
left += 1;
b.append(toSpiralHelper(top, bottom, left, right, HORIZONTAL_RIGHT));
}

//
// At this point, We should have gone through the matrix and
// stored every item (from the matrix) in the string builder.
//

return b.toString();
}

// Spit out contents of the matrix
public String toString()
{
StringBuilder b = new StringBuilder();

for(int i=0; i < matrix.length; i++)
{
for(int j=0; j < matrix.length; j++)
{
b.append(matrix[i][j]);

if(j+1 < matrix.length)
b.append(" "wink;
}
b.append("\n"wink;
}

return b.toString();
}

//
// PRINTERS
// =====================
private String printForward(int row, int startIndex, int endIndex)
{
StringBuilder b = new StringBuilder();

for(int i=startIndex; i <= endIndex; i++)
{
b.append(matrix[row][i]);
b.append(" "wink;
}

return b.toString();
}

private String printReverse(int row, int startIndex, int endIndex)
{
StringBuilder b = new StringBuilder();

for(int i=endIndex; i >= startIndex; i--)
{
b.append(matrix[row][i]);
b.append(" "wink;
}

return b.toString();
}


private String printDownwards(int col, int startIndex, int endIndex)
{
StringBuilder b = new StringBuilder();

for(int i=startIndex; i <= endIndex; i++)
{
b.append(matrix[i][col]);
b.append(" "wink;
}

return b.toString();
}


private String printUpwards(int col, int startIndex, int endIndex)
{
StringBuilder b = new StringBuilder();

for(int i=endIndex; i >= startIndex; i--)
{
b.append(matrix[i][col]);
b.append(" "wink;
}

return b.toString();
}

//
// ACCESSORS & MUTATORS
//

/**
* @param matrix Matrix to Set
*/
public void setMatrix(Object[][] matrix)
{
this.matrix = matrix;
}

public Object[][] getMatrix()
{
return this.matrix;
}

public boolean matrixIsEmpty()
{
return this.matrix == null || this.matrix.length == 0;
}
}


Test Code Fragments written in Java

public static void main(String[] args)
{
//
// Positive Unit test case for the PrintSpiral Class.
// Provide the class with a 5 x 5 Matrix, from 1 to 25
// Class.toSpiral should return 1 2 3 4 5 6 7 8 .... 20 21 22 23 24 25
//

Integer[][] x = new Integer[5][5];

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

PrintSpiral p = new PrintSpiral(x);
System.out.println("Positive UNIT TEST CASE 1:"wink;
System.out.println("============================="wink;
System.out.printf("Length of Matrix: \n%d x %d\n\n",x.length, x[0].length);
System.out.printf("Matrix Representation: \n%s\n", p.toString());
System.out.printf("Spiral Representation: \n%s\n\n\n", p.toSpiral());


// Test 2

Object[][] y = new Object[4][4];

y[0][0] = 'R'; y[0][1] = 'W'; y[0][2] = 'Q'; y[0][3] = 'F';
y[1][0] = '6'; y[1][1] = 'P'; y[1][2] = 'E'; y[1][3] = 'G';
y[2][0] = 'D'; y[2][1] = 'J'; y[2][2] = 'L'; y[2][3] = 'V';
y[3][0] = 'Z'; y[3][1] = "31"; y[3][2] = 'K'; y[3][3] = '1';

p = new PrintSpiral(y);
System.out.println("Positive UNIT TEST CASE 2:"wink;
System.out.println("============================"wink;
System.out.printf("Length of Matrix: \n%d x %d\n\n",y.length, y[0].length);
System.out.printf("Matrix Representation: \n%s\n", p.toString());
System.out.printf("Spiral Representation: \n%s", p.toSpiral());
}



Test Output:

Positive UNIT TEST CASE 1:
=============================
Length of Matrix:
5 x 5

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

Spiral Representation:
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


Positive UNIT TEST CASE 2:
============================
Length of Matrix:
4 x 4

Matrix Representation:
R W Q F
6 P E G
D J L V
Z 31 K 1

Spiral Representation:
R W Q F G V 1 K 31 Z D 6 P E L J
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 4:52pm On Jun 25, 2013
WhiZTiM:
already seconded, thus, I am
Third in line!

Sorry guys, I went quiet for a while (Got caught up).

I will provide my own implementation so you all can criticize as much as you want (we're all here to learn). I'll give one more day for others to post their solution and then post mine.

Mine should be up by Wednesday.
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 5:52am On Jun 24, 2013
kambo: -------------------------------------------------------------------
Here's my solution.
NLquiz.java (Test class)
matrixPrinter.java (abstract class)
spiralMatrixPrinter.java (implementing class)

(C) nairaland.com/kambo
------------------------------------------------------------------------------


matrixPrinter.java
---------------------------
//



public abstract class matrixPrinter
{
protected final String[][] grid;
int Dim;//Dimension
private int acceptedType=-1;
//0 for int, 1 for char
protected boolean locked=false;

public matrixPrinter(final int dim)
throws Exception
{
if(dim<0)throw new IllegalArgumentException("wrong dimension "wink;
Dim=dim;
grid = new String[dim][dim];
for(int u=0;u<Dim;u++)
for(int z=0;z<Dim;z++)
grid[u][z]="";//init to negs
}

public void set(final int x,final int y,final char c)
{
if(x<0||x>=Dim||y<0||y>=Dim||locked)
return;
if(acceptedType==0)return;
else
{
if(acceptedType==-1)acceptedType=1;
grid[x][y]=String.valueOf(c);
}
}

public void set(final int x,int y,int val)
{
if(x<0||x>=Dim||y<0||y>=Dim||locked)
return;
else
{
if(acceptedType>0)return;
if(val<10&&val>=0)
grid[x][y]=String.valueOf("0"+val);
else
grid[x][y]=String.valueOf(val);
if(acceptedType==-1)acceptedType=0;

}
}

public boolean allSet()
{
boolean ans=true;
Outer:
for(int y=0; y<grid.length;y++)
for(int m=0; m<grid[y].length;m++)
{
if(grid[y][m]==""wink {ans=false; break Outer;}
}
return ans;
}

public boolean isEmpty(){
boolean ans=true;
Outer:
for(int y=0;y<grid.length;y++)
for(int x=0;x<grid.length;x++)
{
if(!grid[y][x].trim().equals(""wink)
{
ans=false;
break Outer;
}
}
return ans;

}


public void print(final String s){
System.out.print(s);
System.out.print(" "wink;
}

public abstract void printGrid();

public final void actualLayout()
{
if(isEmpty())return;
else
{
System.out.println();
for(int x=0;x<Dim;x++)
{
System.out.println();
for(int y=0;y<Dim;y++)
{print(grid[x][y]);
}
}

System.out.println();
}
}
}

------------------------------------------------------
spiralMatrixPrinter.java
------------------------------------------------------
// nairaland.com/kambo

public class spiralMatrixPrinter extends matrixPrinter
{
public spiralMatrixPrinter(final int Dim)
throws Exception
{
super(Dim);
}

public void printGrid()
{
//
if(isEmpty())return;
else
{
printer(0,grid.length-1);

}
}

private void printer(final int s,final int max)
{
printer(s,max,1);
}
private void printer(final int start,final int maxIndex,int level)
{
if(start<0||maxIndex<0||maxIndex>=grid.length)
{
System.out.println(" arguments fail test returning.. : "wink;
//this method should throw an exception.. whatever..

}
else
{
locked=true;
//prevent data corruption..
int x=start;
// x is a pointer for moving around the grid (the matrix)
for(;x<=maxIndex;x++)
print(grid[start][x]);
// print top horizontal row

//print vertical leftmost column
x=start;
x++;
for(;x<=maxIndex;x++)
print(grid[x][maxIndex]);
//print bottom last row backwards.
x=maxIndex;
x--;
for(;x>=start;x--)
{
print(grid[maxIndex][x]);
}
x=maxIndex;
x--;

//print rightMost column.
for(;x>start;x--)
{
print(grid[x][start]);
}
System.out.print(" "wink;

int start2=start;
int maxI2=maxIndex;
start2++;
maxI2--;

if(start2==maxI2)
{
//unlock access to data setting
locked=false;
//End case - the grid is an odd number length matrix.
// print last cell. inner most cell
print(grid[start2][maxI2]);

return;
}

if(start2>maxI2)
{
//unlock
locked=false;
//end case - the matrix was even number length .
return;
}

else
printer(start2,maxI2,++level);

}
}
}
----------------------------------------------------------------------------------------
NLquiz.java
----------------------------------------------------------------------------------------

// nairaland.com/kambo


// nairaland.com/kambo
class NLquiz2
{
public static void main(String ...s)
throws Exception
{
int dim=1110;
spiralMatrixPrinter sp = new spiralMatrixPrinter(dim);
for(int x=0;x<dim;x++)
for(int y=0;y<dim;y++)
{
//generate random numbers and feed em into the matrix printer
int r = (int)((y*3)+ Math.random()*(x*y));
sp.set(x,y,r);
}

sp.actualLayout();
//print the initial array structure

System.out.println();

sp.printGrid();
//print the spiral s tructure.
}
}------------------------------------------------------------------------------------------

NB:
-----
Used an array of strings instead of integers for the sake of flexibility.
the user could enter create two types of arrays , char arrays or integer arrays.

- expect an "out of memory " type exception to be thrown for large arrays.
- initializing the class constructor to take an array could be done but i dont matter - really.
i went the longhand way of passing variables individually to the matrix cells.

- I assume the array is balanced. not jagged and that all cells are filled with data.

-------

Good try. I took a quick glance at your code, didn't test it out but It can BETTER be refactored and Improved.
= No Need for the Abstract Class

=- I assume the array is balanced. not jagged and that all cells are filled with data.
This should not be a problem either as we wouldn't care a hoot what the array cells contain, but rather give more pressing concerns to the position of the Array index we are at to prevent getting an out of bound exception.


= There are a lot of unnecessaries in your code as well.
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 5:44am On Jun 24, 2013
WhiZTiM: my solution is uploaded on PasteBin... http://pastebin.com/r3cMG9sM

...Well there are [size=24pt]3 ways I know we could solve this[/size].

1. Procedural/functional ...like my implementation
2. Object Oriented
3. Mathematically.

1
You may have to be interested in Python to understand my code...(70lines uncommented, 122 lines commented)
I was contemplating doing it in C++ or C# but thought it would be better in a lazy/weak typed language.
**Ohkayy, I wouldnt talk on this cause all I would have said is represented VERY well in my Code

2
OOP: this would be similar to number 1... but in this case, all items can be treated as objects by wrapping them in light weighted classes..
---These objects should be aware of their relative positions in the coordinate
---These objects should contain a boolean property that signifies whether its been used or not
---An abstract object or pointer can be used to transverse through the instantiated objects..
---there should exist a simple (up, down, left, right) traveller function that will persistently travel in one direction until it reaches a limit or an object that has been taken... in this case, it changes direction in a preferential manner...
---this continues in spiral direction until there is no more object to transverse
---THIS CAN ALSO be DONE RECURSIVELY ...easier

3
MATHEMATICALLY:
...while I took a paper and was manually transversing through square matrices of diferent sizes... I realized that there exist this property of perfect squares:... ::: a summation of odd number sequences starting from 1 to n is equal to n^2.
PROOF:
if n = 3
1 + 3 + 5 = 9
if n = 5...
1 + 3 + 5 + 7 + 9 = 25
if n = 6
1 + 3 + 5 + 7 + 9 + 11 = 36
you can test for other cases

...now, assume a 5x5 grid..
A B C D E
F G H I J
K L M N O
P Q R S T
U V W X Y

using n as 5, we have the following sequence... (1 + 3 + 5 + 7 + 9)...
reversing it, we have (9, 7, 5, 3, 1)...
the first L shape is of 9 elements... that is ... (A, B, C, D, E, J, O, T, Y)...
the next L shape is of 7 elements... that is ... (X, W, V, U, P, K, F)....
the next L shape is of 5 elements... that is ... (G, H, I, N, S)
the next L shape is of 3 elements... that is ... (R, Q, L)
and finally the last is (M)...

[size=16pt]now... are you thinking mathematically....??[/size]
yeah.... so, I did leave this method as a challenge to someone to implement authurowen's problem with MATHEMATICAL algorithm or discrete NUMERICAL algorithm....

"~~~Many programmers are really good, what may differentiate them is complex and subtle mathematical knowledge and skills~~~" ---says A renowned ACM-ICPC judge in Int'l Collegiate of Programming Contest....( I wish I recall the name)

NB: I am not a mathematician but a maths hobbyist...

Brother, the solution is not as complicated as you have made it out to be. There is no need for the Mathematical / logical Gibberish (for lack of better words) you've just written.

The lay Programmers would find it very difficult to comprehend your theory (I didn't even bother to look at it my self - NO USE!!) Keep it simple, thats how you tell who an SE is.
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 6:41pm On Jun 23, 2013
jacob05:

<?php
/*
Author: Pyjac (facebook.com/pyjac)
*/

class Spiral{

private $masterArray= [];

public function addArray(array $array){
$this->masterArray[] = $array;
}

public function getSpiral(){
$workingList = [];
while (!empty($this->masterArray) ){

$workingList = array_merge($workingList,$this->popListTopArray());
$workingList = array_merge($workingList,$this->popLastArraysElement());
$workingList = array_merge($workingList,$this->popListLastArrayReversed());
$workingList = array_merge($workingList,$this->popFirstArraysElementReversed());
}

return $workingList;

}

private function popFirstArraysElementReversed()
{
if(empty($this->masterArray)) return array();
$workingArray = [];
foreach ($this->masterArray as &$array) {
$workingArray = array_merge($workingArray,(array)array_shift($array));
}
krsort($workingArray);
return $workingArray;

}

private function popListLastArrayReversed()
{
if(empty($this->masterArray)) return array();
$workingArray = [];
$workingArray=array_pop($this->masterArray);
krsort($workingArray);

return $workingArray;
}

private function popListTopArray()
{
if(empty($this->masterArray)) return array();
return array_shift($this->masterArray);
}

private function popLastArraysElement()
{
if(empty($this->masterArray)) return array();
$workingArray = [];
foreach ($this->masterArray as &$array) {
//$testArray = $array[0];
$workingArray = array_merge($workingArray,(array)array_pop($array));
}
return $workingArray;

}
}

//Usage:
$a = ['T','H','Q' ,'P'];
$b = ['X', 'W' ,'S','O'];
$c = ['B', 'C', 'D','E'];
$d = ['G', 'A', 'R', 'K'];
$spiral = new Spiral();
$spiral->addArray($a);
$spiral->addArray($b);
$spiral->addArray($c);
$spiral->addArray($d);
var_dump($spiral->getSpiral());


Thanks for attempting Jacob. (a PHP Solution is also feasible) but
You solution should be better improved, as we do not know the size of the array until we're read it. so reading the input only 4 times will not suffice.
Programming / Re: Programmers: What Project(s) Are You Working On Now? by authurowen(m): 9:04pm On Jun 22, 2013
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 9:01pm On Jun 22, 2013
WhiZTiM: Wheres the challenge here?? Lemme assume there is more attached to this that I dunno.... and answer based on my understanding
frankly, I would never solve this problem in an OOP fashion. Except I know why I should.

in C++


int i;
std::vector<int> vec;
while(cin >> i)
vec.push_back(i);
std::sort(vec.begin(), vec.end());
std::copy(vec.begin(), vec.end(), ostream_iterator<int>(cout, " "wink);


In OOP:


class A //a thin wrapper around int ...not needed for languages where every type is an object

class B; //1 dimensional aggregation of A with internal sorting methods;

class C; //2 dimentional aggregation of A.... or aggregation of B;

class D; //composition of C; and responsible for I/O

//for your example
//Class D reads the input and feeds to C, C receives them as 4 arrays. and construct them with B;
//class C will now have 4 arrays of B...
//class D orders C to sort itself and make outputs ready
//class C will order all 4 Bs to sort their internal arrays...
//class C will now perform a merge sort from all 4 Bs into one big B.
//class D prints


//...I still Don't understand the aim of your question in OOP:::: Here is my very stupid logic: If you have a continuous stream of matrices being thrown into your system and as output, you need regular sorted matrix of specific time intervals:
....if you tweak the above OOP snippet, it should be applicable to parallel systems where a thread/process/system PP1 is responsible for taking matrix input continously;
*passes it to the input buffers of another PP2, ...PP2 picks them from the buffers into a priority_queue (i.e sorted)
...after a few secs, another PP3 may request sorted data from PP2, then, PP2 pushes its queued data to PP3....

OOP will be better than procedural here...


as much as you would like to think your solution is right (syntax wise may be yes), semanticaly no.

What you have done in plane english is simply read all the inputs, sort them and output them back to the screen in a ascending manner (THIS IS NOT THE SOLUTION TO THE QUESTION).

Another example would be:

[T H Q P]
[X W S O]
[B C D E]
[G A R K]

The resulting output (after applying the right solution should be):
T H Q P O E K R A G B X W S D C

Your solution should pls respect the fact that the input is a N x N Array, so an Object Oriented Solution would definitely suffice.

Thanks to every body for trying, we're all here to learn.
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 5:25am On Jun 20, 2013
javadoctor: So How much do I get to do this?

emm, The satisfaction that you have been able to solve this puzzle genuinely without any external help. This is not to prove to anyone that you are superior but rather an attempt to share and discuss programming knowledge to those that may not be as quite up to par as you may be (thats if you are up to par)

1 Like

Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 5:23am On Jun 20, 2013
Javanian:

public class Spiral
{
public static void main(String[] args)
{
int[][] matrix = new int[4][4];
matrix[0][0] = 1; matrix[0][1] = 2;matrix[0][2] = 3;matrix[0][3] = 4;
matrix[1][0] = 12;matrix[1][1] = 13;matrix[1][2] = 14;matrix[1][3] = 5;
matrix[2][0] = 11;matrix[2][1] = 16;matrix[2][2] = 15;matrix[2][3] = 6;
matrix[3][0] = 10;matrix[3][1] = 9;matrix[3][2] = 8;matrix[3][3] = 7;

for(int i=0; i<3; i++) System.out.print(matrix[0][i]);
for(int i=0; i<3; i++) System.out.print(matrix[i][3]);
for(int i=3; i>0; i--) System.out.print(matrix[3][i]);
for(int i=3; i>0; i--) System.out.print(matrix[i][0]);
for(int i=1; i<2; i++) System.out.print(matrix[1][i]);
for(int i=2; i>0; i--) System.out.print(matrix[2][i]);
}
}


Your solution is not Object Oriented Focused. It is doing too many things on its own.. Think more like creating a class and having helper methods handling steps and states/ array index where the pointer finds it self at.
There are no magic numbers, as we do not know that the value at matrix[2][1] is 16. The provided input was just to serve as a mere oracle or Positive Unit Test case for the expected result (thats is if the input specified above was provided)

PLS Avoid using magic numbers.
Programming / Re: Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 5:19am On Jun 20, 2013
Javanian: how is the test matrix going to be entered into the program?

The input will be an array.
i.e. assume we have an array of size n by n
in C#, it would look thus
int[,] input = new int[n,n];

in Java, it would look thus
int[][] input = new int[n][n];


Don't pay too much attention to how the input will be read but rather how the business logic of the solution should end up as.
Programming / Code Challenge [1]: Pseudo-code, C#, JAVA (apply Object Oriented Principles) by authurowen(m): 3:38pm On Jun 19, 2013
PRINT SPIRAL:

Write a code to print the following matrix in spiral Form.
i.e. If I apply the following 4x4 matrix to your code

1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7

It should produce
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16.


N.B: Be Genuine in your solutions, Real S.E(s) are.
Jokes Etc / Re: Yes Or No Reloaded! by authurowen(m): 9:33pm On Jun 11, 2013
No, She's not.

Do you mind me ordering your GF to my PH at Absolute World ?
Technology Market / Re: QUALITY UK NEW AND USED HANDSETS ONLY FOR SALE by authurowen(m): 9:22pm On Jun 11, 2013
Post Your ads on kobolist.com
Programming / Re: Programmers: What Project(s) Are You Working On Now? by authurowen(m): 8:11pm On Jun 11, 2013
P.S. If there is any one out there with a bomb project idea who needs a partner/ S.E to handle the technical & implementation part, inbox me. lets get started already
Programming / Re: Programmers: What Project(s) Are You Working On Now? by authurowen(m): 7:41pm On Jun 11, 2013
orbitame2011:
Are u sure u are sincere with that ur comment because i was on ur Kobolist on my phone just now and comparing d little design dat's even on Torbita to dat of Kobolist(kobolist just open as an ordinary Html page and i try to reload it is still thesame).So am not trying to get ur message,are u saying it should be an ordinary Html page like Kobolist?And also take note that a website expecting much trafics must try to reduce d level of graphics on the site.Thank u.

Hi Orbitame,
Can you (please & thanks) let me know what mobile device you tried accessing Kobolist from, Kobolist mobile was implemented using jquery mobile to better improve user experience and load time on mobile devices. The design is simple and straight forward, "More content , Less Noise".

See the attached image below, if that's not what's being rendered on your device, please let me know. I will be very much happy to debug this.

N.B. At Kobolist, we strive provide our users with the best/ easiest way possible to search and advertise ads. Thats why were're working on Kobolist 2.0

Join kobolist.com now to stay updated, you might just find your next item of interest on there.

1 Share

Programming / Re: I Want To Learn Programming. Which Language Should I Start With? by authurowen(m): 6:05am On Mar 25, 2013
Microsoft's Visual Basic Fundamentals: Development for Absolute Beginners would be a good place to start. (http://channel9.msdn.com/Series/Visual-Basic-Development-for-Absolute-Beginners)

Sams' teach your self visual basic in 24 hrs is another good book. http://www.informit.com/library/library.aspx?b=STY_VB6_24hours
If you successfully work with the Sams' book, you should be able to write a visual basic application up to an intermediate level.

1 Like

Programming / Re: FG Pays N81.7bn On Customs Software by authurowen(m): 10:32pm On Mar 22, 2013
81.7 Billion!?

I'm not exactly sure what was written in the Requirements Document for that project (If there was any) but 82 Billion Naira is still $500 million but for 1% of that money (which is still too much but since they have the money to burn, I will take it) It will take 7 of me less than a year to build whatever they wanted... and use the rest to establish jobs for young graduates.

This is utter bull-shit
Programming / Re: Programmers: What Project(s) Are You Working On Now? by authurowen(m): 10:21pm On Mar 22, 2013
If there's any Web Designer on here that knows his stuff, please let me know.

by know your stuff I mean (CSS, HTML, javascript and PSD) with proven track record (portfolio would be appreciated).

I may be needing an extra developer as well with knowledge of latest Microsoft technologies including (Windows Azure, .NET 4, MVC 3.0, Entity Framework 4.1, WPF, WCF and WIF).

I have a large project I'm working on ... big paper involved.
Programming / Re: Programmers: What Project(s) Are You Working On Now? by authurowen(m): 10:05pm On Mar 22, 2013
@orbitame2011
I went to that site and didn't spend 1 second before closing it. You need a designer to evaluate every little bits and details.
When it comes to the Web, UI is a major issue. A well design Webpage or Software Application will entice your visitor into getting to really know what the app does.

@Gomez. I am very much impressed with your work (or whoever owns the Church+) CMS ... the Idea is Very Unique

1 Like

(1) (2) (of 2 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 97
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.