The Beale Papers are a set of three ciphertexts, one of which allegedly states the location of a buried treasure of gold, silver and jewels. Comprising three ciphertexts, the first (unsolved) text describes the location, the second (solved) ciphertext the content of the treasure, and the third (unsolved) lists the names of the treasure's owners and their next of kin.

The story of the three ciphertexts originates from an 1885 pamphlet detailing treasure being buried by a man named Thomas J. Beale in a secret location in Bedford County, Virginia, in the 1820s. Beale entrusted a box containing the encrypted messages to a local innkeeper named Robert Morriss and then disappeared, never to be seen again. According to the story, the innkeeper opened the box 23 years later, and then decades after that gave the three encrypted ciphertexts to a friend before he died. The friend then spent the next twenty years of his life trying to decode the messages, and was able to solve only one of them which gave details of the treasure buried and the general location of the treasure. The unnamed friend then published all three ciphertexts in a pamphlet which was advertised for sale in the 1880s.

The Beale Papers
Beale's second cryptogram (the deciphered one).

Since the publication of the pamphlet, a number of attempts have been made to decode the two remaining ciphertexts and to locate the treasure, but all efforts have resulted in failure.

There are many arguments that the entire story is a hoax, including the 1980 article A Dissenting Opinion by cryptographer Jim Gillogly, and a 1982 scholarly analysis of the Papers and their related story by Joe Nickell, using historical records that cast doubt on the existence of Thomas J. Beale. Nickell also presents linguistic evidence demonstrating that the documents could not have been written at the time alleged (words such as stampeding, for instance, are of later vintage). His analysis of the writing style showed that Beale was almost certainly James B. Ward, whose 1885 pamphlet brought the Beale Papers to light. Nickell argues that the tale is thus a work of fiction.

Assignment

Your challenge is to decode a ciphertext contained in a text file. The ciphertext exists of a comma-separated sequence of natural numbers, where the commas might be preceded and followed by spaces. The sequence of natural numbers might be split over multiple lines in the text files, where splits never occur between digits of the same number.

39, 120, 11, 73, 22, 63, 73, 139, 53, 51, 69, 93, 112, 31, 63, 22, 42, 22, 63,
131, 112, 73, 22, 63, 8, 44, 60, 3, 151, 53, 117, 22, 112, 126, 22, 120, 83, 21,
43, 112, 73, 23, 22, 35, 56, 63

The key to decode the ciphertext are the words of a text contained in a text file. Herewith, we define a word as the longest possible sequence of letters. Each number from the ciphertext refers to the first letter at the corresponding position in the text, where the first word is at position 1, the second word at position 2, and so on. Your task:

Example

In the following interactive session we assume that the text files cipher.txt1 en poem.txt2 are located in the current directory.

>>> numbers('cipher.txt')
[39, 120, 11, 73, 22, 63, 73, 139, 53, 51, 69, 93, 112, 31, 63, 22, 42, 22, 63, 131, 112, 73, 22, 63, 8, 44, 60, 3, 151, 53, 117, 22, 112, 126, 22, 120, 83, 21, 43, 112, 73, 23, 22, 35, 56, 63]

>>> words('poem.txt')
['as', 'i', 'have', 'gone', 'alone', 'in', 'there', 'and', 'with', 'my', 'treasures', 'bold', 'i', 'can', 'keep', 'my', 'secret', 'where', 'and', 'hint', 'of', 'riches', 'new', 'and', 'old', 'begin', 'it', 'where', 'warm', 'waters', 'halt', 'and', 'take', 'it', 'in', 'the', 'canyon', 'down', 'not', 'far', 'but', 'too', 'far', 'to', 'walk', 'put', 'in', 'below', 'the', 'home', 'of', 'brown', 'from', 'there', 'it', 's', 'no', 'place', 'for', 'the', 'meek', 'the', 'end', 'is', 'ever', 'drawing', 'nigh', 'there', 'll', 'be', 'no', 'paddle', 'up', 'your', 'creek', 'just', 'heavy', 'loads', 'and', 'water', 'high', 'if', 'you', 've', 'been', 'wise', 'and', 'found', 'the', 'blaze', 'look', 'quickly', 'down', 'your', 'quest', 'to', 'cease', 'but', 'tarry', 'scant', 'with', 'marvel', 'gaze', 'just', 'take', 'the', 'chest', 'and', 'go', 'in', 'peace', 'so', 'why', 'is', 'it', 'that', 'i', 'must', 'go', 'and', 'leave', 'my', 'trove', 'for', 'all', 'to', 'seek', 'the', 'answers', 'i', 'already', 'know', 'i', 've', 'done', 'it', 'tired', 'and', 'now', 'i', 'm', 'weak', 'so', 'hear', 'me', 'all', 'and', 'listen', 'good', 'your', 'effort', 'will', 'be', 'worth', 'the', 'cold', 'if', 'you', 'are', 'brave', 'and', 'in', 'the', 'wood', 'i', 'give', 'you', 'title', 'to', 'the', 'gold']

>>> decode('cipher.txt', 'poem.txt')
'natureunfoldshertreasureatthefirstrayofsunrise'

Epilogue

In March 2013, New Mexico art dealer Forrest Fenn announced that he had hidden a bronze treasure chest in the Rocky Mountains north of Santa Fe. In the chest, he says, are gold coins, artifacts, and jewelry worth more than one million dollar.

Wheeler Peak
Wheeler Peak (New Mexico) in the Sangre de Cristo Mountains.

Fenn said he'd conceived the idea when diagnosed with cancer in 1988, planning to bury the treasure as a legacy. The cancer went into remission, but he decided to bury the chest anyway. In a self-published memoir he offered the following poem, which he says contains nine clues:

As I have gone alone in there
And with my treasures bold,
I can keep my secret where,
And hint of riches new and old.

Begin it where warm waters halt
And take it in the canyon down,
Not far, but too far to walk.
Put in below the home of Brown.

From there it's no place for the meek,
The end is ever drawing nigh;
There'll be no paddle up your creek,
Just heavy loads and water high.

If you've been wise and found the blaze,
Look quickly down, your quest to cease,
But tarry scant with marvel gaze,
Just take the chest and go in peace.

So why is it that I must go
And leave my trove for all to seek?
The answers I already know,
I've done it tired and now I'm weak.

So hear me all and listen good,
Your effort will be worth the cold.
If you are brave and in the wood
I give you title to the gold.

Fenn has been releasing further clues periodically as he follows the search:

No need to dig up the old outhouses,
the treasure is not associated with any structure.

A number of people claim to have found the chest, but none has provided evidence, and Fenn says that to the best of his knowledge it remains undiscovered. There's much background and discussion about the treasure at ttotc.com3.