By barneyb on March 5, 2010
The next sudoku strategy is called a "pointing pair" which I'm going to start by generalizing into "pointing triple". The strategy is pretty straightforward: if, for a given number in a given block, all the potential cells are in the same row or column, then that number cannot exist in any other block's cells of [...]
Posted in groovy, sudoku
By barneyb on February 18, 2010
The next Sudoku solving strategy I want to dig into is called "hidden single". Here's the implementation to start with:
class HiddenSingleStrategy implements Strategy {
static getTests() {
[
new Test(
'0' * 9 + '000200000' + '0' * 9 [...]
Posted in groovy, sudoku
By barneyb on January 27, 2010
A couple days ago I posted about implementing a Sudoku solver in Groovy as a sort of cross-training exercise, and promised to delve into the strategies a bit more. So here's GameRulesStrategy:
class GameRulesStrategy implements Strategy {
static getTests() {
[
new Test(
[...]
Posted in groovy, sudoku
By barneyb on January 25, 2010
Last week I spent a bunch of time implementing Sudoku solving strategies in Groovy. Actually a pretty interesting exercise, I thought. Even the simple solving techniques/strategies require a bit of thought to generalize into code. This might seems like a pointless exercise, but think of it a cross training. Football players can't hope to compete [...]
Posted in groovy, sudoku
By barneyb on November 19, 2009
A couple months ago I added Ehcache support to CFGroovy2 as an alternative to the simple HashMap/WeakReference caching that had been there since it's inception. I waffled a little bit at the time, but it seemed like the right thing to do. I've changed my mind, and removed the Ehcache functionality in the latest build. [...]
Posted in cfml, groovy
By barneyb on October 9, 2009
Just in case you didn't come to my talk on leveraging Groovy in your CFML applications at CFUnited, I wanted to share this simple CFM page I demoed:
<cfimport prefix="g" taglib="cfgroovy2″ />
<cfscript>
myArray = [
"barney"
];
</cfscript>
<!— thanks Groovy —>
<g:script>
variables.myArray.add("heather")
</g:script>
<!— thanks Quercus —>
<g:script lang="php">
<?php
[...]
Posted in cfml, groovy
By barneyb on September 26, 2009
Until this point, CFGroovy2 has used a custom WeakHashmap/WeakReference caching mechanism for compiled scripts. It works, and it ensures that the script cache won't run your JVM out of memory, but that's about it's only selling point.
Today I plugged in Ehcache as an optional caching backend if it's available on your classpath. When CFGroovy2 spins [...]
Posted in cfml, groovy
By barneyb on September 26, 2009
The middle of last week I committed an update to CFGroovy2 to allow an arbitrary number of scopes to be passed in as attributes, just like you have always been able to do with the 'variables' attribute. If you update, the change is the addition of lines 47-51:
<cfloop list="#lCase(structKeyList(attributes))#" index="scope">
<cfif listFind("language,lang,script,variables", scope) EQ [...]
Posted in coldfusion, groovy
By barneyb on September 25, 2009
This evening I found a bug in one of the optimizations that I made to the edit distance function. I've corrected the code in the original post, and made a note of the change there as well. Just wanted to mention it in a second post so anyone who read via RSS will be aware [...]
Posted in groovy, potd
By barneyb on September 24, 2009
An edit or string distance is the "distance" between two strings in terms of editing operations. For example, to get from "cat" to "dog" requires three operations (replace 'c' with 'd', replace 'a' with '0', and finally replace 't' with 'g'), thus the edit or string distance between "cat" and "dog" is three. Aside from [...]
Posted in groovy, potd