Skip to main content

A Monday morning puzzle

Posted by daniel on June 21, 2004 at 5:38 AM PDT

It's not Texas hold'em, but how many "perfect" shuffles with a uniform cut does it take to restore a custom deck?

It is easy to lose a bunch of time thinking about the problem that William Grosso blogs about A Fun Programming Challenge. In Also in Java Today we link to the description: given a deck of size n, take the top i cards off of the deck and perform a perfect shuffle as described. The problem is to figure out how many of these identical shuffles it will take to restore the deck to its original position. Oh - and your solution must run quickly.

It might seem obvious to start out by shuffling the deck and then checking to see which cards are where they belong. If you clock the time it takes to do this, you'll see that you are using way too blunt an instrument. Do you really have to shuffle all of the cards?

" Cyclomatic complexity can be explained in layman's terms as follows: every decision point in a method (i.e., an if, for, while, or case statement) is counted; additionally, one is added for the method's entry point, resulting in an integer-based measurement denoting a method's complexity." In Code Improvement Through Cyclomatic Complexity, Andrew Glover talks about measuring this complexity and then understanding and using these measurements to improve your code. Cyclomatic is not the only measure of complexity and the talkback mentions other useful measures.

Joshua Marinacci is inviting you to join his efforts on "Flying Saucer, an all Java XHTML and CSS renderer". After evaluating HTML renderers for Swing he decide to try his hand at rolling his own and decribes his efforts in a blog entry.
In today's
Weblogs, he reports that he has "written a renderer that takes a org.w3c.dom.Document object with inline styles and renders it into a scrollable JPanel. Most of plain HTML is supported, as are the full box model, tables, and images. Parts of relative, absolute, and fixed positioning work. The main issue is the bugs in float/clear, and the lack of forms support. Oh yeah, and it's really, really, really slow."

The Heroes of Code, in Simon Phipps' opinion are the " small teams in 36 projects are diligently creating the local language versions of that will bring it to millions around the world in their own language." Simon adds that "This, by the way, is why we need format standards - not for the people who have the wealth to create a custom schema but to include into the community those with economies too small to be worth exploitation."

Malcolm Davis looks ahead to this year's JavaOne conference in I'm ready. Malcolm is one of our bloggers who will be covering the show - as for parties, everyone is invited to the Tuesday night Communities in Action party. There will be presentations from Jini, JXTA, and will be presenting awards recognizing contributions from our community.

Projects and Communities
, the Education and Learning community's JAI Stuff project offers a "collection of code, tips and datasets" to help the beginning JAI programmer wade through the complexity.

Using patterns can be made easier with the Pattern Enforcing Compiler (PEC), a Java Patterns Community project. It allows you to mark a class as conforming to a given pattern and then verifies that the class does so.

The Stripping down J2SE discussion continues
in today's Forums.
Javakiddy writes that "If there really is a Java3 at any point, what would developers think if the whole API was ditched and a new j3se.* API created from scratch. All the functionality added over the years re-evaluated and consolidated into brand new packages to make them more coherent."

You have four years to fix your problems says jwenting in crying wolf. "JVMs have roughly a 2 year release cycle.
That makes for a 4 year timespan in which to remove dependencies on that old JVM.

In 4 years all applications are bound to be either maintained or replaced by something else that IS up to date.

And of course noone forces you to run one JVM only. As noted it is quite possible to run several JVMs in parallel, and they need not be the same version."

Princec makes a suggestion that is in violation of the Java license. "Clearly we couldn't ship... 9MB's worth of entertainment in a bloated 23MB distribution, and hardly anyone would download it. ... We left in a few crucial bits [of the JRE] that our game actually uses ...and ended up with something taking 2,620KB. Distribution is easy, and 2.6MB for an entire VM with RMI just... rocks. ... Unfortunately it's technically a breach of the license terms, but, ah... we have a bug in our installer and some of the files in the JRE have gotten corrupted, ahem, and don't install correctly"

In today's News Headlines

Registered users can submit news items for the href=""> News Page using
our news submission
. All submissions go through an editorial review before being posted to the site. You can also subscribe to
News RSS feed

Current and upcoming
Java Events

Registered users can submit event listings for the href=""> Events Page using our href=""> events submission
form. All submissions go through an editorial review before being
posted to the site.

Archives and Subscriptions: This blog is delivered weekdays as the
Today RSS feed
. All members can subscribe to the email
updates for the site at the href="">
java-net Mailing Lists page. You must be logged in to subscribe
the javanet_Daily and javanet_Weekly lists. Also, once this page
is no longer featured as the front page of
it will be archived along with other past issues in the href=""> Archive.