SOMA Crystal
SOMA News 08 november 2013

Showing solutions in a new online viewer

There do exist a range of SOMA solvers and viewers as both programs and as web functions.
So we should expect that no one would make one more.
However this is just what James Brink has done for us.

The evolving story, as James expanded on his initial program, will follow here.

But - let us start by viewing the finished result.

The datafile format here:
The Final Version is here:
During development, drafts may sometimes be here:

Try it out, It's a very different way to show the solutions, that may inspire many puzzlers out there.

Now let's see how this thing evolved

In October 2013 I received a mail from "James Brink",
a retired Math and Computer Science professor who taught at "Pacific Lutheran University", Tacoma, WA, USA
- but now lives in Mossyrock, WA, USA.

He wrote:
"I have started and nearly completed a program that displays SOMA cubes.
It is written in "Processing" a language that can executed in Java or Javascript.
The page shows the result.
Because the code is "translated" into Javascript, it can be run on virtually every computer.

I am not sure if the program is sufficiently unique to be valuable or if I am just reinventing the wheel.
I of course answered that the idea was interesting
I settled for a program that given a solution:
1. Shows how to construct the solution.
2. Allows one to rotate the cube.
3. Allows one to create mirror reflections of the cube.

I believe that my sketch (a Processing program) has the following advantages and disadvantages:
Significant advantage:
Runs on a web page on virtually every computer.
It automatically shows how to construct the cube.
It allows rotating and mirroring solutions.
Currently solutions are actually written into the program (it could be modified to read them from a file).
Currently it does not accept solutions typed on the keyboard.
Solutions are written in an incompatible format. It only allows numbered input.
The colors of the pieces are different but it would be trivial to change them.
It only works for 3 x 3 x 3 cubes. though larger figures would require changing the way cubes are displayed.
Currently only 11 independent solutions are available. More will be added.

I mailes James a number of link references and waited for the evolution of the program.
And immediately James set to work in a fast pace.

Thank you for your prompt and kind remarks.
Before you announce the program, let me see if I can make it read from your input file.
When the program runs. The Processing code is translated in to Javascript when it is executed using some Javascript coding developed for that purpose by the Processing.js people.
25 oct.
I have adopted the Processing code for SomaCube to use data files.
The code includes a "Select file" Button that allows selecting any of the five data files.

The head section of the HTML files contains the script tag that gets the file, that converts Processing code to Javascript on the fly.

It is believed that SomaCube will accept your data files although this it has not been tested.
However, it allows some more generality in some areas.

It is believed that anyone can store the 8 files in a folder on their computer or server and run them.
Actually they should be able to modify the .pde file and use it although that method is extremely unforgiving of both syntax and run-time errors.

All the files are available in the folder
The extended HTML is
and the simplified HTML file is
If someone wants to add new solutions to the SomaCube.dat file, they may want to read

People are welcome to use the code as desired (for non-comercial purposes).
I hope in time to modify the code to allow larger cubes but it may take some time.
Suggestions, comments, and corrections are welcome.
27 oct.
After starting work on allowing larger "cubes", it was obvious that some of method names where not appropriate and confusing.
Also one class had a confusing name.
So I did a version 1.1.1 changing them. I also corrected one error message.
Except for the error message, the changes don't make any difference to the user.
The revised SomaCube.pde file has been upload to the web site.

I have made some progress with larger cubes but currently things don't work properly.
28 oct
Here is a link to a draft of SomaCube1.2.
Its new feature is that it allows figures of up to 8 x 8 x 8.
Figure 4STE is 4 x 4 x 4,5LOV is 5 x 5 x 5 and so on.
The code seems to work pretty well but there are at least a few places I would like to improve the coding, primarily for readability.
I haven't done anything with the .html pages yet.

(Explanation. To allow convenient rotations and reflections, all figures are embedded cubes whose size equals the largest dimension of the "solution".)

The primary problem is that the cells get very small for larger cubes.
For 3 x 3 x 3 cubes has 40 pixel edges but for 8 x 8 x 8 the edges only have 15 pixels.
It would be possible to get even larger cubes.
For example, a 9 X 9 x 9 cube would have 13 pixel cell sides, 10 x 10 x 10 would have 12 pixel cell sides.

So the question is "how large a cube should the program be able to handle?"
I can think of three ways to enlarge the figure.
1. Provide an "enlargement" button.
In the enlargement, only one figure would be shown which would allow about a 2.1 times enlargement.
Initially it would show the completed figure.
There would be additional buttons to show the constructions steps one by one.
I don't think this would be terribly difficult.

2. There is a lot of blank space in displays. This space results from all the blank rows, columns, and/or layers.
With enough extra coding, it would be possible to enlarge the figure to more nearly fill the space.
This might allow about 1.5 times enlargement in "8FIG".
I haven't got a good idea on how to accomplish this yet.

3. The combination of the above.

I expect to eventually to be able handle SOMA Plus and double SOMA sets.
I don't anticipate either will be particularly difficult.

The problem with the double sets is that it will take 14 construction steps so some redesign would of the display would be needed.
The "solution "DOUB" uses double sets but only shows 7 constructions steps so it is not ready for use yet.
The technique uses something you suggested somewhere. Use letters for one set and numbers for the other.
Letters and numbers are have different internal numbers for the same piece so as it shows the construction,
it can distinguish between piece "V" and "1" even though they are displayed in the same color.
Likewise for the other pieces.
31 oct
I went ahead and implemented the 2nd option. That is, there is a serious attempt to enlarge the figures.
It is not perfect as sometimes if a lower left corner is missing, it does quite fill the available area.
But otherwise it does a great job.

I also fixed things things so that if one uses a double set of cubes, it adds two pieces at a time instead of just one, and still develops the whole cube in the 7 images.
This depends on using numbers for 1 set of cubes and letters for the other set.

The URL is
2 nov
I just uploaded draft 1.3 which includes double SOMA cubes and SOMAplus.
(Double SOMAplus hopefully works but is untested.) The problem of getting the figure to be aligned correctly has been solved.
I have also included a couple of files containing the figures
4 nov
I just made version 1.3 the default version at

I am now working on a new version that will have 3 views:
1. The existing 7 step construction view.
2. A 3 color view with the top, front, and side of all cells shown in distinct colors instead of
showing the pieces in different colors something like you used on the "ALL Soma Figure images" page.
This will be the default. This single view will be "double size".
3. A hints view showing the constructions step by step "double size" one step at at a time. "still in work".

The idea is that users might want to see a figure without seeing its step by step construction.
The hints view will help you get started.
A working draft, it will be available as
4 nov (in the afternoon)
Version 2 draft is uploaded to with the new views as given in the previous e-mail,
Functionally it is pretty much what I hoped for. It still needs some improvement the way it looks.
8 nov
I have what I hope is the final draft of SomaCube (2e) ready.
Hopefully later today or tomorrow, I'll make it the official version after another proof reading.
I think have eliminated the bugs in previous drafts and added new features.

There are a few simple changes that could be made if it seems desirable.
The size limit could be expanded beyond 10 by just changing the value of 1 variable and checking to make sure everything still works.
In the hints section, there are just 7 steps.
It could be expanded to 11 for SOMAplus or 14 for double SOMA sets.
There are possibly other minor changes that could be made.

In the non-immediate future, I would like to add
1. The ability to input a solution from the keyboard.
Unfortunately, this is not trivial in Processing (especially under Javascript) but not impossible.
(The various buttons were not trivial either.)
2. The ability to generate a solution on its own given the desired shape.
This doesn't appear to be trivial either although I notice you have a link to a program that does it.

Unfortunately, I have to get at other "jobs" so I don't know when I'll get to this. It may be a few months.

I had hoped to add more SOMAplus solutions into a data file for them but I observed that most solutions contain invalid pieces (at least by current standards).
For example, several have 8 Z cells with shapes that do not correspond to a Z.

I would have more double SOMA solutions except that many do not distinguish between the two sets. and my program needs to distinguish them in the step by step constructions and hints.

As always, any suggestions, comments, or corrections would be appreciated

Written by Thorleif Bundgaard <>
Based on material from James Brink <>

BACK to news index