₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,747 members, 8,513,486 topics. Date: Thursday, 05 November 2026 at 06:13 AM

Toggle theme

Logica's Posts

Nairaland Forum › Logica's Profile › Logica's Posts

1 2 3 4 5 6 7 8 ... 207 208 209 210 211 212 213 214 215 (of 228 pages)

Events › Re: International Open Source Software Conference (foss Nigeria 2010) by logica(m): 8:51pm On Jan 30, 2010
Unfortunately, because of the general tendency of the Northern cities to indulge in ethnic cleansing I will not be going. I really think they should move the conference to Lagos.
Programming › Re: Do We Have Any Hosted Nigerian Open Source Project One Can Contribute To? by logica(m): 2:28pm On Jan 29, 2010
I think you should start one.
Programming › Re: Any Iphone/touch Developers In Nigeria? by logica(m): 11:35am On Jan 24, 2010
I don't expect you to start with sentence translations. Without having any technical knowledge of context, grammar, sentential forms, etc you'll be wasting your time. It's best to start with a simple word translator.
Programming › Re: Any Iphone/touch Developers In Nigeria? by logica(m): 10:52am On Jan 24, 2010
realnaija:
Funny, I am actually doing that as we speak.
Really? Then why did you say everything you can think of has been done?
Programming › Re: Are You Going To Be Programming At An Advanced Age? by logica(m): 8:22am On Jan 24, 2010
Seun:
Makes no sense.  You're saying many contradictory things in your desperate bid to disagree.  Na wa.
What is your reason (why there are very few old web devs?)
It makes no sense that you cannot point out the contradictions (you probably don't know the meaning of that). And what do I have to gain by disagreeing with you? Maybe you need lessons in reading and comprehension; otherwise you wouldn't be asking me for an answer I already provided.

In any case, I'll give you a clue: the reason is the same you will not find many old accountants (even though the profession dates back several centuries), but you will find them as Accounts Managers and owners of Accounting firms.
Programming › Re: Are You Going To Be Programming At An Advanced Age? by logica(m): 10:08pm On Jan 23, 2010
Seun:
The reason we don't have 70 year old web developers is simple: the web is barely 20 years old!
That is not the reason. You can definitely find web developers of advanced ages in the US for instance. They sometimes have a history of programming, but most I've found don't, and have gone through several different careers before settling for software development (which mostly explains why they are still in the development tier, and not managerial tier, as they have fewer years of experience in the field than their age mates). If you've had a long history in software development, you usually get promoted out of the development level to the managerial level. But a few don't like the managerial level, and stick to development.
Programming › Re: Any Iphone/touch Developers In Nigeria? by logica(m): 10:01pm On Jan 23, 2010
Why don't u come up with a translator for at least 3 major Nigerian native languages? That, as a matter of fact will be useful to all foreigners interested in the country.
Programming › Re: Cc Candylips: Algorithms by logica(op): 6:02am On Jan 23, 2010
Dude, I'll address what I quickly picked from your post:

Tic-Tac-Toe is so trivial, that it doesn't require an evaluation function or even Minimax for that matter: there is a strategy for figuring out the best move at any time. You can actually enumerate the whole game tree within a few minutes by running a program written for that purpose (that can not be said for Chess or even Ayo). And even if you use Minimax, with the maximum number of moves in any game being 9 and a branch factor of probably less than 3, it is not even worth being used as a case study for Minimax/Alpha-beta.

Not many algorithms are obvious, in fact I don't know any that is. They all arise from years of experimentation and work, which result patterns being identified and in rules-of-thumb.
Programming › Re: Java: Aop And Annotations by logica(op): 3:56pm On Jan 22, 2010
Besides the database can only do numeric and string sorts. Anything more than that will quickly get complex.
Programming › Re: Cc Candylips: Algorithms by logica(op): 3:07pm On Jan 22, 2010
candylips:
Nice one logica. alpha-beta pruning looks like a very solid search algorithm
Well, the simple fact is, computers will not be able to play humans in games of perfect information such as Chess, Checkers, Go, etc without this algorithm. Of course you also need a good evaluation function (which gives a numeric value to a game position, and the higher this value, the better it favors the player from whose perspective the position is viewed - such as 'White' in chess). For instance chess computers like Deep Blue have this algorithm and evaluation function implemented in hardware, not software.

Minimax algorithm is also utilized in a branch of Operations Research (Economics) called Game Theory on Zero Sum Two-Player games (unsurprisingly, as you can see the connection), which I believe is used to simulate dynamics in market systems.
Programming › Re: Java: Aop And Annotations by logica(op): 2:47pm On Jan 22, 2010
I am comparing the JPA @OrderBy and the Hibernate @Sort. I prefer the @Sort because it is based on the Java Collections API and can therefore handle more complex sort needs. @OrderBy as you pointed out can only be used in an SQL query, whereas @Sort is not tied to SQL.
Programming › Re: Cc Candylips: Algorithms by logica(op): 11:35pm On Jan 21, 2010
Seun:
Excellent topic. I've not fully figured out this algorithm yet, but it's really useful.
Minimax? Have you ever tried to implement it?

Have you implemented any before?

Can you please delete all my posts (except for this of course) after my second post? Thanks.
Programming › Re: Cc Candylips: Algorithms by logica(op): 9:31pm On Jan 21, 2010
Minimax/Alpha-beta Pruning

I first saw the algorithm in a magazine of which I can't recall the name or edition/date since it was back in '96, and then later saw a variant in the book "Encyclopedia of Artificial Intelligence". I first implemented in QBasic, then C, then Java. Unfortunately I no longer have the code, but I can definitely come up with something even better than I had back then (thanks to experience of course).

Here is the algorithm as found on Wikipedia:

http://en.wikipedia.org/wiki/Alpha-beta_pruning

The algorithm is on that page. I cannot post it here since the "smart" bot thinks it's likely to be some attempt to embed Javascript or something (it is smart enough to know it's code, but not smart enough to know it's pseudo).
Programming › Re: Cc Candylips: Algorithms by logica(op): 9:29pm On Jan 21, 2010
Minimax/Alpha-beta Pruning

I first saw the algorithm in a magazine of which I can't recall the name or edition/date since it was back in '96, and then later saw a variant in the book "Encyclopedia of Artificial Intelligence". I first implemented in QBasic, then C, then Java. Unfortunately I no longer have the code, but I can definitely come up with something even better than I had back then (thanks to experience of course).

Here is the algorithm as found on Wikipedia:

http://en.wikipedia.org/wiki/Alpha-beta_pruning

functn alphabeta(node, depth, α, β)         
    (* β represents previous player best choice - doesn't want it if α would worsen it *)
    if  depth = 0 "or" node is a terminal node
        return the heuristic value of node
    foreach child of node
        α := max(α, -alphabeta(child, depth-1, -β, -α))     
        (* use symmetry, -β becomes subsequently pruned α *)
        if β≤α
            break                             (* Beta cut-off *)
    return α

(* Initial call *)
alphabeta(origin, depth, -infinity, +infinity)
Programming › Re: Cc Candylips: Algorithms by logica(op): 7:07pm On Jan 21, 2010
Depth First

For the problem being solved, check the Blackplanet site for the puzzles. It shouldn't be difficult to figure which the solves. Here is the main class. I can send the rest if there's any interest.
Programming › Re: Cc Candylips: Algorithms by logica(op): 7:03pm On Jan 21, 2010
Minimax/Alpha-beta

I initially got the pseudo-code from a magazine back in '96 but I can't remember the name or the edition. I got another variation from the "Encyclopedia of Artificial Intelligence" by Stuart Shapiro. I don't have any of the code anymore (written first in QBasic then C, then Java). I'm sure I can come up with something better at the moment if I feel like.

But I got this from Wikipedia:

http://en.wikipedia.org/wiki/Alpha-beta_pruning

function alphabeta(node, depth, α, β)         
    (* β represents previous player best choice - doesn't want it if α would worsen it *)
    if  depth = 0 "or" node is a terminal node
        return the heuristic value of node
    foreach child of node
        α := max(α, -alphabeta(child, depth-1, -β, -α))     
        (* use symmetry, -β becomes subsequently pruned α *)
        if β≤α
            break                             (* Beta cut-off *)
    return α

(* Initial call *)
alphabeta(origin, depth, -infinity, +infinity)
Programming › Re: Cc Candylips: Algorithms by logica(op): 6:58pm On Jan 21, 2010
Depth First

For the problem being solved, check the Blackplanet site for the puzzles. It shouldn't be difficult to figure which the solves. Here is the main class. I can send the rest if there's any interest.

package com.blackplanet.puzzle;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;

public class ShortestUserPath implements Runnable {
private String connectionsFileName;

private String startUserName;

private String endUserName;

/**
* @param args
*/
public static void main(String[] args) {
shortest finder = new shortest();
//Making sure all the required parameters are entered proper.
if(args.length < 3) {
System.out.println("Come on dude, you did it wrong!\nUsage:\njava com.blackplanet.puzzle.shortest <relations-file-name> <start-user-name> <end-user-name>"wink;
} if(args.length > 3) {
System.out.println("Come on dude, you did it wrong!Usage:\njava com.blackplanet.puzzle.shortest <relations-file-name> <start-user-name> <end-user-name>"wink;
}
else {
finder.setConnectionsFileName(args[0]);
finder.setStartUserName(args[1]);
finder.setEndUserName(args[2]);
Thread finderThread = new Thread(finder);

finderThread.start();

}
}

public void run() {
List<BPMember> members = loadMembers(connectionsFileName);

//Tree (binary-tree in the case of sample data, technically speaking) representation of BlackPlanet sample members
// System.out.println("Member List: " + members);

String shortestPath = exec(startUserName, endUserName, members);

System.out.println(shortestPath);
}

public List<BPMember> loadMembers(String fileName) {
List<BPMember> members = new ArrayList<BPMember>();

BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(fileName));
String line = null;
String memberName = null;
String connectedMemberName = null;
while((line = reader.readLine()) != null) {
StringTokenizer tk = new StringTokenizer(line, " "wink;
memberName = tk.nextToken();
connectedMemberName = tk.nextToken();

BPMember member = new BPMember(memberName);
if(!members.contains(member)) {
members.add(member);
} else {
member = members.get(members.indexOf(member));
}

BPMember connectedMember = new BPMember(connectedMemberName);
if(!members.contains(connectedMember)) {
members.add(connectedMember);
} else {
connectedMember = members.get(members.indexOf(connectedMember));
}

if(!connectedMember.getConnectingNodes().contains(member)) {
connectedMember.addConnectingNode(member);
}
if(!member.getConnectingNodes().contains(connectedMember)) {
member.addConnectingNode(connectedMember);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return members;
}

public String exec(String startUserName, String endUserName, List<BPMember> members) {
StringBuilder builder = new StringBuilder();

int memberIdx = members.indexOf(new BPMember(startUserName));
BPMember startUser = null;
if(memberIdx >= 0) {
startUser = members.get(memberIdx);
}

memberIdx = members.indexOf(new BPMember(endUserName));
BPMember endUser = null;
if(memberIdx >= 0) {
endUser = members.get(memberIdx);
}

if(startUser != null && endUser != null) {
// System.out.println("Ready or not, here I come, you can't hide, "wink;
Stack<String> currentPath = new Stack<String>();
ArrayList<Stack<String>> pathSolutions = new ArrayList<Stack<String>>();
// long startTime = System.currentTimeMillis();
startUser.findConnection(new BPMember(startUserName), new BPMember(startUserName), new BPMember(endUserName), members.size(), members.size(), currentPath, pathSolutions);
// long timeInterval = System.currentTimeMillis() - startTime;

if(!pathSolutions.isEmpty()) {
// System.out.println(", I think I found something, better check."wink;
// System.out.println(pathSolutions);

// Figuring out the path with the shortest length,
ArrayList<Long> pathLengths = new ArrayList<Long>();
for(Iterator<Stack<String>> itr = pathSolutions.iterator(); itr.hasNext(); ) {
pathLengths.add(new Long(itr.next().size()));
}
Collections.sort(pathLengths);
long optimalPathLength = pathLengths.get(0);

// System.out.println("OPTIMAL_PATH_LENGTH: " + optimalPathLength);

ArrayList<Stack<String>> optimalPaths = new ArrayList<Stack<String>>();
optimalPaths.addAll(pathSolutions);

Stack<String> path = null;
for(Iterator<Stack<String>> itr = pathSolutions.iterator(); itr.hasNext(); ) {
path = itr.next();
if(path.size() > optimalPathLength) {
optimalPaths.remove(path);
//Separating the chaff from the wheat.
// System.out.println("Removing the garbage " + path + ", "wink;
// System.out.println("OPTIMAL_PATH_REDUCED: " + optimalPaths);
}
}

ArrayList<String> optimalPathStrings = new ArrayList<String>();

// System.out.println("And here we are folks!: " + optimalPaths);

Stack<String> aPath = null;

for(Iterator<Stack<String>> itr = optimalPaths.iterator(); itr.hasNext(); ) {
aPath = itr.next();
StringBuilder bldr = new StringBuilder();
for(Iterator<String> j = aPath.iterator(); j.hasNext(); ) {
bldr.append(j.next());
if(j.hasNext()) {
bldr.append(" "wink;
}
}
optimalPathStrings.add(bldr.toString());
}
Collections.sort(optimalPathStrings);

for(Iterator<String> itr = optimalPathStrings.iterator(); itr.hasNext(); ) {
builder.append(itr.next());
if(itr.hasNext()) {
builder.append("\n"wink;
}
}
} else {
// System.out.println("Awwww man! What a waste of time. I want my " + ((double) timeInterval) / 1000.0  + " secs back"wink;
builder.append("NONE"wink;
}
} else if(startUser == null){
builder.append("Come on dude, we don't have anybody called '" + startUserName + "' in here!"wink;
} else if(endUser == null){
builder.append("Come on dude, we don't have anybody called " + endUserName + "' in here!"wink;
}

return builder.toString();
}

public void setConnectionsFileName(String connectionsFile) {
this.connectionsFileName = connectionsFile;
}

public String getConnectionsFileName() {
return connectionsFileName;
}

public void setStartUserName(String startUserName) {
this.startUserName = startUserName;
}

public String getStartUserName() {
return startUserName;
}

public void setEndUserName(String endUserName) {
this.endUserName = endUserName;
}

public String getEndUserName() {
return endUserName;
}
}
Programming › Re: Cc Candylips: Algorithms by logica(op): 6:53pm On Jan 21, 2010
Depth First

For the problem being solved, check the Blackplanet site for the puzzles. It shouldn't be difficult to figure which the solves. Here is the main class. I can send the rest if there's any interest.


package com.blackplanet.puzzle;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;

public class ShortestUserPath implements Runnable {
private String connectionsFileName;

private String startUserName;

private String endUserName;

/**
* @param args
*/
public static void main(String[] args) {
shortest finder = new shortest();
//Making sure all the required parameters are entered proper.
if(args.length < 3) {
System.out.println("Come on dude, you did it wrong!\nUsage:\njava com.blackplanet.puzzle.shortest <relations-file-name> <start-user-name> <end-user-name>"wink;
} if(args.length > 3) {
System.out.println("Come on dude, you did it wrong!Usage:\njava com.blackplanet.puzzle.shortest <relations-file-name> <start-user-name> <end-user-name>"wink;
}
else {
finder.setConnectionsFileName(args[0]);
finder.setStartUserName(args[1]);
finder.setEndUserName(args[2]);
Thread finderThread = new Thread(finder);

finderThread.start();

}
}

public void run() {
List<BPMember> members = loadMembers(connectionsFileName);

//Tree (binary-tree in the case of sample data, technically speaking) representation of BlackPlanet sample members
// System.out.println("Member List: " + members);

String shortestPath = exec(startUserName, endUserName, members);

System.out.println(shortestPath);
}

public List<BPMember> loadMembers(String fileName) {
List<BPMember> members = new ArrayList<BPMember>();

BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(fileName));
String line = null;
String memberName = null;
String connectedMemberName = null;
while((line = reader.readLine()) != null) {
StringTokenizer tk = new StringTokenizer(line, " "wink;
memberName = tk.nextToken();
connectedMemberName = tk.nextToken();

BPMember member = new BPMember(memberName);
if(!members.contains(member)) {
members.add(member);
} else {
member = members.get(members.indexOf(member));
}

BPMember connectedMember = new BPMember(connectedMemberName);
if(!members.contains(connectedMember)) {
members.add(connectedMember);
} else {
connectedMember = members.get(members.indexOf(connectedMember));
}

if(!connectedMember.getConnectingNodes().contains(member)) {
connectedMember.addConnectingNode(member);
}
if(!member.getConnectingNodes().contains(connectedMember)) {
member.addConnectingNode(connectedMember);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return members;
}

public String exec(String startUserName, String endUserName, List<BPMember> members) {
StringBuilder builder = new StringBuilder();

int memberIdx = members.indexOf(new BPMember(startUserName));
BPMember startUser = null;
if(memberIdx >= 0) {
startUser = members.get(memberIdx);
}

memberIdx = members.indexOf(new BPMember(endUserName));
BPMember endUser = null;
if(memberIdx >= 0) {
endUser = members.get(memberIdx);
}

if(startUser != null && endUser != null) {
// System.out.println("Ready or not, here I come, you can't hide, "wink;
Stack<String> currentPath = new Stack<String>();
ArrayList<Stack<String>> pathSolutions = new ArrayList<Stack<String>>();
// long startTime = System.currentTimeMillis();
startUser.findConnection(new BPMember(startUserName), new BPMember(startUserName), new BPMember(endUserName), members.size(), members.size(), currentPath, pathSolutions);
// long timeInterval = System.currentTimeMillis() - startTime;

if(!pathSolutions.isEmpty()) {
// System.out.println(", I think I found something, better check."wink;
// System.out.println(pathSolutions);

// Figuring out the path with the shortest length,
ArrayList<Long> pathLengths = new ArrayList<Long>();
for(Iterator<Stack<String>> itr = pathSolutions.iterator(); itr.hasNext(); ) {
pathLengths.add(new Long(itr.next().size()));
}
Collections.sort(pathLengths);
long optimalPathLength = pathLengths.get(0);

// System.out.println("OPTIMAL_PATH_LENGTH: " + optimalPathLength);

ArrayList<Stack<String>> optimalPaths = new ArrayList<Stack<String>>();
optimalPaths.addAll(pathSolutions);

Stack<String> path = null;
for(Iterator<Stack<String>> itr = pathSolutions.iterator(); itr.hasNext(); ) {
path = itr.next();
if(path.size() > optimalPathLength) {
optimalPaths.remove(path);
//Separating the chaff from the wheat.
// System.out.println("Removing the garbage " + path + ", "wink;
// System.out.println("OPTIMAL_PATH_REDUCED: " + optimalPaths);
}
}

ArrayList<String> optimalPathStrings = new ArrayList<String>();

// System.out.println("And here we are folks!: " + optimalPaths);

Stack<String> aPath = null;

for(Iterator<Stack<String>> itr = optimalPaths.iterator(); itr.hasNext(); ) {
aPath = itr.next();
StringBuilder bldr = new StringBuilder();
for(Iterator<String> j = aPath.iterator(); j.hasNext(); ) {
bldr.append(j.next());
if(j.hasNext()) {
bldr.append(" "wink;
}
}
optimalPathStrings.add(bldr.toString());
}
Collections.sort(optimalPathStrings);

for(Iterator<String> itr = optimalPathStrings.iterator(); itr.hasNext(); ) {
builder.append(itr.next());
if(itr.hasNext()) {
builder.append("\n"wink;
}
}
} else {
// System.out.println("Awwww man! What a waste of time. I want my " + ((double) timeInterval) / 1000.0 + " secs back"wink;
builder.append("NONE"wink;
}
} else if(startUser == null){
builder.append("Come on dude, we don't have anybody called '" + startUserName + "' in here!"wink;
} else if(endUser == null){
builder.append("Come on dude, we don't have anybody called " + endUserName + "' in here!"wink;
}

return builder.toString();
}

public void setConnectionsFileName(String connectionsFile) {
this.connectionsFileName = connectionsFile;
}

public String getConnectionsFileName() {
return connectionsFileName;
}

public void setStartUserName(String startUserName) {
this.startUserName = startUserName;
}

public String getStartUserName() {
return startUserName;
}

public void setEndUserName(String endUserName) {
this.endUserName = endUserName;
}

public String getEndUserName() {
return endUserName;
}
}
Programming › Re: Cc Candylips: Algorithms by logica(op): 6:50pm On Jan 21, 2010
That's a very stupid bot, but then what do you expect of a bot?

Anyway here goes:

Minimax/Alpha-beta

I initially got the algorithm from a magazine in '96 and I no longer remember the name or edition, neither do I have the actual code (but it should be fairly easy to come up with something even better if I put my mind to it).

I got this from Wikipedia: http://en.wikipedia.org/wiki/Alpha-beta_pruning


function alphabeta(node, depth, α, β)
(* β represents previous player best choice - doesn't want it if α would worsen it *)
if depth = 0 "or" node is a terminal node
return the heuristic value of node
foreach child of node
α := max(α, -alphabeta(child, depth-1, -β, -α))
(* use symmetry, -β becomes subsequently pruned α *)
if β≤α
break (* Beta cut-off *)
return α

(* Initial call *)
alphabeta(origin, depth, -infinity, +infinity)
Programming › Re: Java: Aop And Annotations by logica(op): 6:45pm On Jan 21, 2010
Which would u prefer:

@OrderBy or @Sort in sorting a list of entities?
Programming › Re: Cc Candylips: Algorithms by logica(op): 6:26pm On Jan 21, 2010
Minimax/alpha beta
I got the initial pseudo-code from a magazine (can't remember the name or edition) way back in '96, and then got another version in the book "Encyclopedia of Artificial Intelligence" by Stuart Shapiro. I no longer have the code as a matter of fact and I had it implemented in QBasic, C, and Java. (though it won't take much to reproduce a better version, since I've gotten way better of course).

Right now, I can only quote from Wikipedia: http://en.wikipedia.org/wiki/Alpha-beta_pruning


function alphabeta(node, depth, α, β)         
    (* β represents previous player best choice - doesn't want it if α would worsen it *)
    if  depth = 0 "or" node is a terminal node
        return the heuristic value of node
    foreach child of node
        α := max(α, -alphabeta(child, depth-1, -β, -α))     
        (* use symmetry, -β becomes subsequently pruned α *)
        if β≤α
            break                             (* Beta cut-off *)
    return α

(* Initial call *)
alphabeta(origin, depth, -infinity, +infinity)



Depth First
Here is the main class:
[

package com.blackplanet.puzzle;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;

public class shortest implements Runnable {
private String connectionsFileName;

private String startUserName;

private String endUserName;

/**
* @param args
*/
public static void main(String[] args) {
shortest finder = new shortest();
//Making sure all the required parameters are entered proper.
if(args.length < 3) {
System.out.println("Come on dude, you did it wrong!\nUsage:\njava com.blackplanet.puzzle.shortest <relations-file-name> <start-user-name> <end-user-name>"wink;
} if(args.length > 3) {
System.out.println("Come on dude, you did it wrong!Usage:\njava com.blackplanet.puzzle.shortest <relations-file-name> <start-user-name> <end-user-name>"wink;
}
else {
finder.setConnectionsFileName(args[0]);
finder.setStartUserName(args[1]);
finder.setEndUserName(args[2]);
Thread finderThread = new Thread(finder);

finderThread.start();

}
}

public void run() {
List<BPMember> members = loadMembers(connectionsFileName);

//Tree (binary-tree in the case of sample data, technically speaking) representation of BlackPlanet sample members
// System.out.println("Member List: " + members);

String shortestPath = exec(startUserName, endUserName, members);

System.out.println(shortestPath);
}

public List<BPMember> loadMembers(String fileName) {
List<BPMember> members = new ArrayList<BPMember>();

BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(fileName));
String line = null;
String memberName = null;
String connectedMemberName = null;
while((line = reader.readLine()) != null) {
StringTokenizer tk = new StringTokenizer(line, " "wink;
memberName = tk.nextToken();
connectedMemberName = tk.nextToken();

BPMember member = new BPMember(memberName);
if(!members.contains(member)) {
members.add(member);
} else {
member = members.get(members.indexOf(member));
}

BPMember connectedMember = new BPMember(connectedMemberName);
if(!members.contains(connectedMember)) {
members.add(connectedMember);
} else {
connectedMember = members.get(members.indexOf(connectedMember));
}

if(!connectedMember.getConnectingNodes().contains(member)) {
connectedMember.addConnectingNode(member);
}
if(!member.getConnectingNodes().contains(connectedMember)) {
member.addConnectingNode(connectedMember);
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return members;
}

public String exec(String startUserName, String endUserName, List<BPMember> members) {
StringBuilder builder = new StringBuilder();

int memberIdx = members.indexOf(new BPMember(startUserName));
BPMember startUser = null;
if(memberIdx >= 0) {
startUser = members.get(memberIdx);
}

memberIdx = members.indexOf(new BPMember(endUserName));
BPMember endUser = null;
if(memberIdx >= 0) {
endUser = members.get(memberIdx);
}

if(startUser != null && endUser != null) {
// System.out.println("Ready or not, here I come, you can't hide, "wink;
Stack<String> currentPath = new Stack<String>();
ArrayList<Stack<String>> pathSolutions = new ArrayList<Stack<String>>();
// long startTime = System.currentTimeMillis();
startUser.findConnection(new BPMember(startUserName), new BPMember(startUserName), new BPMember(endUserName), members.size(), members.size(), currentPath, pathSolutions);
// long timeInterval = System.currentTimeMillis() - startTime;

if(!pathSolutions.isEmpty()) {
// System.out.println(", I think I found something, better check."wink;
// System.out.println(pathSolutions);

// Figuring out the path with the shortest length,
ArrayList<Long> pathLengths = new ArrayList<Long>();
for(Iterator<Stack<String>> itr = pathSolutions.iterator(); itr.hasNext(); ) {
pathLengths.add(new Long(itr.next().size()));
}
Collections.sort(pathLengths);
long optimalPathLength = pathLengths.get(0);

// System.out.println("OPTIMAL_PATH_LENGTH: " + optimalPathLength);

ArrayList<Stack<String>> optimalPaths = new ArrayList<Stack<String>>();
optimalPaths.addAll(pathSolutions);

Stack<String> path = null;
for(Iterator<Stack<String>> itr = pathSolutions.iterator(); itr.hasNext(); ) {
path = itr.next();
if(path.size() > optimalPathLength) {
optimalPaths.remove(path);
//Separating the chaff from the wheat.
// System.out.println("Removing the garbage " + path + ", "wink;
// System.out.println("OPTIMAL_PATH_REDUCED: " + optimalPaths);
}
}

ArrayList<String> optimalPathStrings = new ArrayList<String>();

// System.out.println("And here we are folks!: " + optimalPaths);

Stack<String> aPath = null;

for(Iterator<Stack<String>> itr = optimalPaths.iterator(); itr.hasNext(); ) {
aPath = itr.next();
StringBuilder bldr = new StringBuilder();
for(Iterator<String> j = aPath.iterator(); j.hasNext(); ) {
bldr.append(j.next());
if(j.hasNext()) {
bldr.append(" "wink;
}
}
optimalPathStrings.add(bldr.toString());
}
Collections.sort(optimalPathStrings);

for(Iterator<String> itr = optimalPathStrings.iterator(); itr.hasNext(); ) {
builder.append(itr.next());
if(itr.hasNext()) {
builder.append("\n"wink;
}
}
} else {
// System.out.println("Awwww man! What a waste of time. I want my " + ((double) timeInterval) / 1000.0  + " secs back"wink;
builder.append("NONE"wink;
}
} else if(startUser == null){
builder.append("Come on dude, we don't have anybody called '" + startUserName + "' in here!"wink;
} else if(endUser == null){
builder.append("Come on dude, we don't have anybody called " + endUserName + "' in here!"wink;
}

return builder.toString();
}

public void setConnectionsFileName(String connectionsFile) {
this.connectionsFileName = connectionsFile;
}

public String getConnectionsFileName() {
return connectionsFileName;
}

public void setStartUserName(String startUserName) {
this.startUserName = startUserName;
}

public String getStartUserName() {
return startUserName;
}

public void setEndUserName(String endUserName) {
this.endUserName = endUserName;
}

public String getEndUserName() {
return endUserName;
}
}


Anybody interested in what the code does and the rest can get it on request.
Programming › Re: Java: Aop And Annotations by logica(op): 6:14pm On Jan 21, 2010
But since AspectJ is basically an extension of the Java language itself, does it not appear to have an edge over Spring AOP?
Programming › Re: Scjp Exam In Nigeria by logica(m): 5:34pm On Jan 21, 2010
candylips:
you are right most of the regular developer roles don't even ask for degree or certificate
Actually they usually list them as "required", but they never actually asked for copies for verification (though there was at least more than 1 occasion within the 5 year period I had to send copies of my SCJP certificate since this was required).
Programming › Re: Scjp Exam In Nigeria by logica(m): 2:44pm On Jan 21, 2010
candylips:
where  ?? nigeria ?? thats not the case for this place o. experience is the king here and probably an advance degree in CS
Nope, in the US. I found a few such, like you'll find a few with Masters listed under "added advantage" or required. Of course they are few. Most of the positions are fine with demonstrable skill, and usually some ask you to do tests on Brainbench.com (I did a few of such). For up to 5 year I worked without anybody asking to see my B.Sc certificate!
Programming › Re: Scjp Exam In Nigeria by logica(m): 2:37pm On Jan 21, 2010
candylips:
yea SCJEA makes more sense. Am done with IT certifications though. they are just not worth it.
Problem is, some job positions actually list certifications as "added advantage" or even "required". You wouldn't want a situation you'll see an opportunity you like so much, and that fits you almost perfectly, except for the certification part.
Programming › Java: Aop And Annotations by logica(op): 2:35pm On Jan 21, 2010
Anybody using these?

I am beginning to wonder how I've done without annotations for so long. They've been particularly useful in conjunction with AOP (AspectJ) and the JPA annotations have eliminated the use of XML files and simplified relation definitions, etc.

Which are the ones you use most often? Of course mine are those for the JPA and now AspectJ will feature more often.
Programming › Cc Candylips: Algorithms by logica(op): 2:28pm On Jan 21, 2010
OK let's talk about algorithms. I have not implemented many. Actually just 2 as far as I can remember.

Minimax with alpha-beta pruning

This is used for the move selection by the computer in a group of games referred to as Games of Perfect Information (such as Chess, Checkers, etc). I implemented this for the game of Ayo.

A*/Simple Depth First
Usually used for path finding problems. I came up with one for the above (not A*), and another for a Blackplanet puzzle recently.

Which have you implemented?
Events › Re: International Open Source Software Conference (foss Nigeria 2010) by logica(m): 2:15pm On Jan 21, 2010
Thanks a lot for this.
Programming › Re: Any Iphone/touch Developers In Nigeria? by logica(m): 2:12pm On Jan 21, 2010
None that I know of, but I know of 1 that developed some themes. Why don't you go for it, and be the first? grin
Programming › Re: Scjp Exam In Nigeria by logica(m): 2:08pm On Jan 21, 2010
candylips:
SCJP is a useless certification

The certificate has been collecting dust on my bookshelf since 2003
Of course it is, after all it expires every 2 years; meaning yours expired in 2005 and mine expired in 2003 grin. My SCWCD expired in 2005. SCJEA is more useful though. I paid for it but didn't bother sitting for it. Now I may just complete it before the middle of the year.
Programming › Re: Building Applications by logica(m): 2:06pm On Jan 21, 2010
candylips:
do you need a bricklayer that can build these applications
grin
Programming › Re: Why NET Languages Are Not Better Than Java Languages by logica(m): 9:01am On Jan 15, 2010
IG:
Interesting statistics. So are you now implying that the more popular the language the better features it has?
It really doesn't matter, as it was a good rebuttal to the silly stats posted earlier: http://news.cnet.com/8301-13505_3-9884500-16.html

1 2 3 4 5 6 7 8 ... 207 208 209 210 211 212 213 214 215 (of 228 pages)