Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

YAMI Neutral Builds!

I've just a found a great hosting service at http://www.heliohost.com and uploaded the first neutral build of YAMI. You can find the packages @ http://yami.heliohost.org/.
After downloading just start with:
java -jar yamiSVN181.jar
Remember:In software development, a neutral build is a build that reflects the current state of the source code checked into the source code version control system by the developers, but without any developer-specific changes.

return 0

First of all: this blog isn't dead! I just made a little vacation. :)
...and I'm back! with new experiences what I want to share with YOU.
Lets get start with my project YAMI. On the site http://yami.googlecode.com you can see that the latest change is from 2009.02.06. :S Yes I was to lazy to touch this code, but today I committed the latest revision r181 with some minimalistic changes like new code formatting rules and such as, and I also added the latest version of the JDBC connector's license. I'm still searching for contributors, please contact me if you have some experience in Java!
You can download the Nightly builds of YAMI - precompiled packages, just start them with:
java -jar yami_nightlyBuild.jar
(Nightly builds are unstable versions, use only for testing!)
The latest stable version is 0.1.3 download here: http://code.google.com/p/yami/downloads/list.
For the source code take a look to: http://code.google.com/p/yami/source/browse/#svn/trunk.

New topic.
Qt Jambi - i started to write a netlimiter-like application in Java using the Qt Jambi framework. I still agree that the framework is lightweight and looks pretty cool compared to the old Java metal style, but... deploying a pure Qt Jambi application is a nightmare.
Why? The documentation is still incomplete, they have no community site or forum (I've already mentioned this on qtlabs). The only thing what the Jambi community have is a mailing list, what is IMHO a bit uncomfortable. I want to finish this project (without Qt Jambi OFC) because there is no netlimiter-like application for Linux with graphical user interface - or at least I can't find any of them. :)
If somebody is interested in this project, please drop and e-mail or add a comment!

Ow, new theme ^^, cool isn't? ;)

Qt Jambi

Hi!
Maybe you've already heard about Qt ( Trolltech ) company. It is best known in the Linux community as the basis for the KDE desktop environment. They are developing a cross platform framework for C++ and Java (Qt Jambi). Today I tested their framework and compared it to Swing/AWT (Sun's framework).
The naming conventions are basically identical to Java, the most difference is that in Qt Jambi everything begins with Q (QTable, QPushButton), and not with J like in Swing (JTable, JButton). :)
The components are being created on the same way in booth frameworks.

Qt Jambi:
QTableWidget table = new QTableWidget(1000, 5);
QTableWidgetItem item = null;

Swing / AWT:
JTable table = new JTable(1000, 5);
Object data = null;

The concept for filling out tables is the same for booth TableModel and AbstractTableModel. Let's fill out these tables:


Qt Jambi:
for(int i = 0; i < 1000; i++) {
for(int j = 0; j < 5; j++) {
item = new QTableWidgetItem("Test value");
table.setItem(i, j, item);
}
}


Swing / AWT:

for(int i = 0; i < 1000; i++) {
for(int j = 0; j < 5; j++) {
data = "Test value";
table.setValueAt(data, i, j);
}
}


Qt table uses less memory with ~4MB, which is probably caused by the number of preloaded classes. I hope that Qt's Slot approach for generating events also takes less memory then the Swing listeners. That was for today. I'll come back with new test result as soon as I can.
Bye!

The newest member of our family

After long time hacking & cracking m$ software and writing closed-source applications my friend: http://kwar.vndv.com/ created his first open-source project under the name MicroLogger. 3x Hooray and Good Luck to the development! :)

[SOLUTION] Google Treasure Hunt - Primes

Here comes the II. quest from Google Treasure Hunt. Maybe it sounds very simple, and algorithm what we've (Szakál Károly (ftnkaresz /at gmail /dot com) and I) used isn't so difficult, but after 3 hours of hard-coding, what we got? A full stack error with 2GB RAM. ;)

Find the smallest number that can be expressed as
the sum of 3 consecutive prime numbers,
the sum of 9 consecutive prime numbers,
the sum of 253 consecutive prime numbers,
the sum of 781 consecutive prime numbers,
and is itself a prime number.

For example, 41 is the smallest prime number that can be expressed as
the sum of 3 consecutive primes (11 + 13 + 17 = 41) and
the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).


Recursion is very bad thing in programming. It isn't requires deeper analysis of problems, there is enough to make good type definitions, a good algorithm with some recursive calls and return statement and finally there recursion will solve the problem for you. Okay! :)
The main goal of Data Structure and Algorithms is how to solve problems without recursive calls, and how to avoid the whole recursion.
The first solution made without recursion in programming language C. The main part of this program is an infinite while loop, what terminates itself if the right prime sum found:

while(1) {
switch (r) {
case 0: result=PrimSum(previousPrime,1063,&previousPrime);
ix=0;
nextPrime=2;
r=sum(nextPrime,1063,result);
break;
case 1: ix++;
if (!(ix<5)) { return 0; }
nextPrime=2;
r=sum(nextPrime,array[ix],result);
break;
case 2: r=sum(nextPrime=NextPrim(nextPrime),array[ix],result);
break;
}
}



Finally, our number is: 6304483.

The full sorce code:

#include
#include
#include
//4355977//d9062d
const int array[]={1063,309,183,137,5};
int ix=0;

int nPrimSum(int,int);
int PrimSum(int,int,int*);
int isPrime(int);
int sum(int,int,int);
int NextPrim(int);

int main()
{int result, r=0;
int previousPrime=2, nextPrime=2;

while(1) {
switch (r) {
case 0: result=PrimSum(previousPrime,1063,&previousPrime);
ix=0;
nextPrime=2;
r=sum(nextPrime,1063,result);
break;
case 1: ix++;
if (!(ix < 5)) { return 0; }
nextPrime=2;
r=sum(nextPrime,array[ix],result);
break;
case 2: r=sum(nextPrime=NextPrim(nextPrime),array[ix],result);
break;
} //switch
} //while

return 0;
}
int isPrime(int xx) {
double i;
double a=sqrt(xx);

for(i=2; i<=a; i++) {
if (!(xx%((int)i))) return 0;
}
return 1;
}


int NextPrim(int pr) {
int i;
for(i=pr+1; !(isPrime(i)); i++);
return i;
}

int PrimSum(int min, int step, int *ePrim) {
int i,ret;
for(i=min; !(isPrime(ret=nPrimSum(i,step))); i=NextPrim(i))
;
*ePrim=NextPrim(i);
return ret;
}

int nPrimSum(int min, int step) {
int i=0;
int numb=min, summ=0;

while (i < step) {
if (isPrime(numb)) {
summ+=numb;
i++;
}
numb++;
}

return summ;
}
//----------------------------------------------------

int sum(int min, int step, int sum_n) {
int i=0;
int numb=min, summ=0;

while (i < step) {
if (isPrime(numb)) {
summ+=numb;
i++;
}
numb++;
}

if (summ==sum_n) return 1;
if (summ if (summ>sum_n) { return 0; }
}

[SOLUTION] Google Treasure Hunt - Robot

Okay! Let's solve this programming problem without writing a single line of code. :)
A robot is located at the top-left corner of a 60 x 31 grid:


The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid.

Our robot can 30 times to step down and 59 times to step right, because it is staying on the first block (1, 1).
We can write down his way from location (1, 1) to location (60, 31) like this:
R - right, D - down.
RDRDDDRDDRDDRD......RDRRRDDDRDRD.
The only question is: how many different (unique) arrays we have from 59 R and 30 D?
Fill out a row with 59 R:
RRRRRRRRR........RRRRRRRRRRRR......RRRRRRRRRR and take 30 D to random places without repeating an already existing array. On more mathematical language, number of unique arrays (unique permutations) with length 59+30 from 30 D is exactly:

Comments are welcome! ;)

Google Treasure Hunt

Hi again here! First, sorry I have a couple of TODOs in the past few weeks around the university, tests, exams, etc. I have a lot of new things in my mind what I want to share with you. :) Are you heard about Google Treasure Hunt? An interesting programming challenge. The problems are not so easy, you need to find out a lot of things, not just the algorithms. We have two problems solved, I'll post here the solutions in the next few days. Maybe you can use it to something, or start your own Treasure Hunt account with two already solved problems. :)

Okay, let's get started. Here is the first question (maybe the shortest).

"A robot is located at the top-left corner of a 60 x 31 grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid.
How many possible unique paths are there?
(Note: Answer must be an exact, decimal representation of the number.)"

ps.: If you have some mathematical background and one calculator then without writing a single line of code you can solve this problem in 5 minutes.
Good luck. Good Hunting. :)