The 9 Billion Names of God is a short story by Arthur C. Clarke. It's about a group of Tibetan monks whose order is devoted to writing down all the possible names of God, written in their own alphabet. Essentially, they are devoted to writing every possible permutation of their alphabet, restricted by a few rules. In the story, the monastery hires some engineers to write a program to do all the work for them. Your goal is to write that program.
Rules:
The monk's alphabet uses 13 characters (according to my estimations). You may use
ABCDEFGHIJKLM
or some other set of 13 characters.The minimum length of a possible name is 1 character. The maximum length is 9 characters.
No character may repeat more than 3 times in succession.
AAABA
is a valid name, butAAAAB
is not.Your program should print out (to a file) every possible name in sequence from
A
toMMMLMMMLM
, separated by any character not in the alphabet (newlines, semi-colons, whatever).This is code-golf, and you can use any language. The shortest solution by June 1st 2014 wins.
Edit: The names should start with A
and end with MMMLMMMLM
, progressing through all the billions of names sequentially. But the particular sequence is up to you. You can print out all the 1-letter names first, then all the 2-letter names, etc. Or you can print all the names starting with A
, then all the ones starting with B
, or some other pattern. But a human should be able to read through the file and confirm they are all there and in whatever logical order you choose, assuming they have the time.
f(k) = k^9 + k^8 + k^7 - 5*k^6 + k^5 + k^4 + 4*k^3 - 2*k^2 + k
. Sage implementation: goo.gl/0srwhq \$\endgroup\$105.8GB
all said and done! I'm glad the stars didn't go out... or maybe you have to print the list for that to happen...? \$\endgroup\$