Steven Bell

Ranch Hand
+ Follow
since Dec 29, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Steven Bell

I don't think this is possible without using external code.

You could probably start a new JVM using the exec method of the Runtime class:

and then shut down the JVM you're in
17 years ago
Well, maybe that doesn't work.

What I have is:


What I'd like is for the toObject method to return the same type as the class passed into the constructor.
17 years ago
That could work, but I'd rather be able to supply it to the enum. Each enum has it's own class type, and it may end up being used in more than one method.
17 years ago
My first thought would be timezone or daylight savings problem.
17 years ago
I'm trying to do the following.

Is it possible to have a generic method in an enum? If so where/how do I specify the type? I've tried several different ways, but no luck getting anything to compile.

Apparently a <T> in front of a constructor for the enum compiles, but I don't seem to be able to use it.

Any ideas?
17 years ago
I'm thinking I'm solving the wrong problem here.

Rather than finding a solution, computing all it's permutations and storing them, what I need to do is search for solutions and test them against previously found solutions to see if they are a permuataion or a new solution. It'll be much easier to manage memory resources, and there is no need to store permutations, only the unique solutions. I think this will also make it easier to break the work up into small units.

The only downside is there would be a fair amount of duplicate work done processing permutations to test new solutions.
18 years ago

Originally posted by Paul Clapham:
Time to bring out the envelope again so we can do some calculations on the back of it. So 2.4 trillion permutations is 2.4 million times that, or 12 million seconds. That's somewhere over 3,000 hours -- close to 20 weeks in fact.

[ May 10, 2006: Message edited by: Paul Clapham ]



That's why I said I'll be moving the processing to a grid computing system. This project is born part of the sudoku habit and part of my desire to play with grid computing.

And I'm not overly concerned with the time issue here. This is just a fun project for me.

P.S. The 2.4 trillion is just the permutations from one valid solution. There will many valid solutions. That number is actully one of my goals here.
[ May 10, 2006: Message edited by: Steven Bell ]
18 years ago
I do understand the size of the problem, although I didn't think to calculate the disk space needed, I stopped at the 'This just isn't going to fit in memory' stage. Maybe a little more information would help.

I'm working on a program that generates Sudoku solutions (it doesn't generate puzzles or solve puzzles, just solutions). Each valid solution can be modified to create a new valid solution. The possible permutations run just over 2.4 trillion. Once I get the algorithms all worked out (which I'm about half way there), I plan to break things up and have the work done in a grid system. Currently I can generate around 1 million permutations in 5 seconds.

I need the set restraints as a validation that the permutations have run correctly. I know exactly how many unique permutations there are, and if the numbers don't match I have a problem.

This all started when I had the idea that there are only a small number of unique patterns in the solution of sudoku puzzles. Not sure if that's true yet, but that's part of what I want to find out.

Considering the disk size issue, maybe I need to look at some sort of compressed storage.

P.S. For the interested the permutations run as follows:
Each set of row (1-3, 4-6, 7-9) can be swaped around without invalidating the puzzle, same with columns. Also each section can be swaped around, same with each column section. Then you can swap any two (or more) symbols and still have a valid puzzle (swap all the 2's and 4's for example). Also the puzzle can be rotated

This leads to 3!*3!*3!*3! = row permutations, same for column permutations
4 roational positions.
9! symbol swaps.

1296*1296*4*362880 = 2,437,996,216,320
18 years ago
Hi all.

I need a Set implementation that can hold roughly 2.4 trillion items. I'm guessing the best way to do that is write a set that is back by a File (which is why I'm posting in this forum).

I'll basically be inserting all the items into the Set, and then reading them out and populating either another of the same kind of Set (for long term storage, a master list) or a database.

I'm looking for advise as the to best way to back the Set with a File. I'm also looking for sorted order, the data has a natural sort order I'll use, so it will wind up being some kind of tree set.

Any help would be appreciated, or it you think I'm on the wrong track let me know.
18 years ago
I haven't tried it, but I don't think the above code handles inserts of more than one character. For example if a phone number is copy/pasted into the field.

I think I'm going to do some work on this. I'm going to look at making the Document class better and see if I can make a Formatter to put in a JFormattedTexField. Hopefully one of those can be done cleanly. It will probably take me a little while to get something workable, but I'll post my results here when I'm done.
18 years ago
Maybe it would be more constructive if I showed an example and maybe somebody could offer some advice for improvement.

This is the code I used to get the functionality I wanted for phone numbers. The code for the InputVerifier isn't too bad, but I think the Document is just ugly.

P.S. I should mention I use this with a standard JTextField.

Here is the Custom Document


And here is the code for the Input Verifier

[ January 19, 2006: Message edited by: Steven Bell ]
18 years ago
I believe this is an issue with the mime type not being set on the server and not a problem with the browser.

I could be wrong though.
18 years ago
Over the course of developing a few different Swing apps I've, of course, found the need to have properly formatted and validated text fields.

I've found using JFormattedTextField to be easy, but it has less that satisfactory results.

The main problems I have are that you are unable to leave the field blank once something has been typed into it, and when editing the text you have to over type rather than delete and reenter (which can be very confusing to users).

I have gotten around this by using JFormattedTextFields sparingly and doing a lot of work with custom Documents and InputVerifiers. This always feels like a hack (mainly because I don't think I'm really doing right), but it works.

So the question (finally) is:

Is there a good, elegant, way to create custom formatted fields. Is there a tutorial out there (I haven't seen one), does somebody have some sample code.

One example of the type of formatting is a phone number
If a user types in just 7 numbers they see
555-5555
If a user types in 10 numbers they see
(555) 555-5555
and the ()- are all added automatically. The user can delete and add numbers at any point and the formatting isn't broken.
18 years ago

Originally posted by fedai gandjaliyev:
I was mistaken.
It will not do.
The example that you provided generates the "Testing$1.class" subclass
together with the "Testing.class" class.



So does the example you gave.

This sounds like a homework assignment, and I think you are looking for a JFormattedTextField and a MaskFormatter.
18 years ago
I want to host my own site from home and I have some questions if anybody out there can help. First, my current setup.

I have a cable internet connection through comcast. I have a dynamic IP address, although it *never* changes (been more than a year with the same IP). My 'server' is a three year old box (was top of the line then ). It's running Slackware. I have the Apache web server running and I can hit it from anywhere by using the IP address (although there isn't anything there yet). The computer is behind a linksys router and a linksys cable modem. I'm currently doing port forwarding on 80 for Apache. I have registered a domain name through godaddy.com.

Ideally what I want to do is run Bind for my DNS (on the same box). The site is just for me and maybe my family so if it goes down for a couple days because my IP changes and I have to update the DNS I wouldn't be heart broken. The main reason for wanting to run my own DNS is just for the experience of doing it. If for some reason I can't do my own DNS I'll end up going with some dynamic DNS.

After all that setup here is my question: Does anybody have some experience doing this or know of any good resources for setting up Bind. I've read the Linux DNS HowTo's and have a general idea of what is involved, but I have the feeling it's going to be a bit different because I'm on a cable connection. I'd rather not do something to screw up with DNS . Also, is there anything I have to do at godaddy to let them know about my DNS.

Eventually I'll probably add ftp, mail, svn, and some other 'services' on my server, mainly for personal use. At that point if my own DNS isn't stable enough I'll look at other things, such as dynamic DNS, but I'd really like to have the experience of doing this myself.

Any help would be appreciated.

Thanks.
19 years ago