NetBeans Projects Pane
I’m trying out NetBeans 5.5.1 as a Java IDE and I’m very impressed so far. Thought I’d cough up some related thoughts on programming environments and free software, mixed with some personal history:
MS Visual Basic
I began my corporate programming career using Visual Basic 4, and moved on up to VB6, which I continued to use at home until last year. I really liked VB for GUI programming and quickly putting together various utility programs. I’ve probably made over a hundred more or less complicated VB programs for my personal use, in addition to the huge program I worked on at my job many years ago.
Java
While still using VB on the job, I started learning Java and have done a fair amount of …
by Scott Carpenter on 28 August 2007 at 2:49 pm
Permalink |
Comments (19) | filed under java, programming
|
To celebrate this great day, here’s a little bit of free software, released under the terms of the GNU General Public License, version 3: a Java class I wrote to find all permutations for a given string. I may later post some more in the way of documentation, but for now, por ejemplo:
PermutationIterator p = new PermutationIterator(”123″);
while ( p.hasNext() ) {
System.out.println( p.next() );
}
Produces:
123
132
213
231
312
321
Since we can compute the factorial to know how many total permutations there are for a given string length, it’s a little bit faster to avoid the call to hasNext():
for (int i=0; i < p.totalPermutations(); i++) {
System.out.println( p.next() );
}
You can also supply an integer for “N” and get permutations for an alphabetic string:
p = new PermutationIterator(20);
//…yada yada
To get:
abcdefghijklmnopqrst
abcdefghijklmnopqrts
abcdefghijklmnopqsrt
abcdefghijklmnopqstr
abcdefghijklmnopqtrs
abcdefghijklmnopqtsr
…
2,432,902,008,176,639,993 more permutations…
…
rstqponmlkjihgfedcba
And now for the code, below the fold. Happy GPLv3 …
by Scott Carpenter on 29 June 2007 at 11:23 pm
Permalink |
Comments (4) | filed under code, java
|