algorithmic modeling for Rhino
From Professor Stewart's Hoard of Mathematical Treasures:
Captain 'Jolly' Roger Redbeard, the fiercest pirate in the Windlass Islands, stared blankly at a diagram he had drawn in the sand beside the quiet lagoon behind Rope's End Reef. He had buried a hoard of pieces of eight there a few years ago, and now he wanted to retrieve his treasure. But he had forgotten where it was. Fortunately he had set up a cunning mnemonic, to remind him. Unfortunately, it was a bit too cunning.
He addressed the band of tattered thugs that constituted his crew.
'Avast, ye stinkin' bilge-rats! Oi, Numbskull, put down that cask o' rotgut and listen!'
The crew eventually quietened down.
'You remember when we boarded the the Spanish Prince... and just before I fed the prisoners to the sharks, one of 'em told us where they'd hidden their loot... an' we dug it all up and reburied it somewhere safe?'
There was a ragged cry, mostly of agreement.
'Well, the treasure is buried due north o' that skull-shaped rock over there. All we need to know is how far north. Now, I 'appens to know that the exact number o' paces is the number of different ways a man can spell out the word TREASURE by puttin' his finger on the T at the top o' this diagram, and then movin' it down one row at a time to a letter that's [below] it, one step to the left or right.
'I'm offerin' ten gold doubloons to the first man-jack o' ye to tell me that number. What say ye, lads?'
The Challenge is to not only give the correct number of possibilities but to map out each path.
SOLUTION: (Note the cluster is my method for creating the Binary Numbers)
Here's one solution... sort of. Finds all the possible paths and then culls the ones with lengths greater than the number of segments multiplied by the length of one acceptable segment.
I thought it was going to be a LOT easier to get all the possible polylines (with one point per row). I thought it would be a "cross reference" thing... but I couldn't figure it out.
Since I'm a scripting novice and didn't to deal with multi-dimensional arrays, here's a workaround (only calculates for words with 8 letters maximum).
Looks like the equation for solving for the number of paths that follow the rule is 2^(# of letters - 1)... I think.
Here's my take. This was a good puzzle, I too thought the polylines would be a lot easier to do. In the end my strategy was to build the points of the diagram into a data tree, with each row in its own branch. The big trick was to essentially convert the numbers 0 - ((2^N-1)-1) to binary, with each digit of each result representing a decision for either left or right. (0000000 means go all the way down the left and 1111111 means always go right.) The progressive sum of the digits of the binary value gives the item index for each successive tree branch.
If I have time later I'd like to give a scripting approach a stab... seems like a pretty textbook application for recursion. That would also suggest that a hoopsnake solution would be a possibility...
I'm going to leave it open and un-judged for while to see if there are any more takers. But in the mean time here's a paper which some might find interesting http://www.geometer.org/mathcircles/pascal.pdf
Winner: Andrew Heumann.
My solution posted above.