8
1
The Library of Babel is defined as
a universe in the form of a vast library containing all possible 410-page books of a certain format and character set.
For the purposes of this question, each page of the book contains 40 lines of 40 characters each. The formatting rules are as follows:
- Legal characters are the English Latin alphabet
a-z,A-Z
and the punctuation characters, .
(comma, space and full stop). - Each page contains at least one space, one full stop, one capital character and one comma.
- There must be a space after every full stop and comma. No combination of the punctuation characters
, .
may be present more than twice in a row, and identical punctuation marks cannot exist consecutively. - All alphabetic characters immediately after a full stop and its accompanying space must be capitalised. This applies unless the full stop is the last or second last character on a page. Capital characters may not occur anywhere else.
Challenge
Write a program or function which outputs a number of page excerpts from the Library of Babel, with a newline between each page excerpt.
Most importantly, the program must be able to theoretically perfectly replicate the entire Library of Babel if given an infinite number for the number of page excerpts to produce and a truly random RNG (Pseudorandom random number generators are allowed in the code, but assuming the PRNG is replaced with a true RNG, the code should theoretically produce the entire library).
Since this is code golf, the shortest answer will be accepted.
An example of valid output (for 2 pages):
, umqdzvvrdgijqrjv qmupgpgqeaegnqmmcig g
j itzgdr cdrsjgggmgjqgzplhrtoptqmbshbzgg
qcqqm plipugorpgqftnvmmgodpqaopqqfpbddnn
shmgqbf gqjclzjqaqpandqdjnfnrsgjamqqnzvu
ufzebfdbescszbvfoatftsqtefssbnnztiaupezu
gmtahqpisucljvpqohsauoudppsumnrlqjlfiapd
aurlenavahnbbbver. Lvjbgilspusdunufrgfng
nghpbcusnscibepjqhgjgcemzjdcqqjdprsrunih
emqgrfrgoqrnsvqofbrvsaqhsrqndhuhulolrese
visneqbjssfjtdrmuqq tfseuczgvbuetgijhtcs
aqnubefzuet. Gjctngshammusvdaogamtuo ajs
edjbctevfdnodgg jubshhsuaniqnsqrvatquqtg
bgoffnd hepqngjnusmglcqgdse q rdlzjqggfr
evvrcfezqqditbpztttirravbzegzleafashfzed
nhngjcccvzmmnmgpimoeztfcu laupeg rogtrip
nuaaghqptet, gss csrszqpnmvgcevqqzrfegus
lnninfajhsaapgpcljiooednbusfbmcmgqunvvzd
o dcztfgdovr. Ru, gvjchisbvo sslpzolptss
hnjbmovglvbu idqlgehrztfshrhbigivijh foi
bqcqggpjfus qmdituqucqdqgogzuvevlhujojuu
dnsuqvcsptnsjrqiezfqrjucsongqgbbutvsoqld
s vbollthqsgambsaoqgvgapszhgvsjnqepeqgvv
pqzpbqhcmfbhfcz gdeuzogmtzqjvohldeafchip
olztntqn vgtiofcjzmfluqoqruaqcqmnmfafvnc
ruzahccrqpzji, gdrhcu pgjuhqqvsgppgzrioq
qjgh oapzdiusqem ubtnhhbpdt sjzbidggsgve
ocdiuungsghltqsuezoco qqgcpnupiisnrngetq
lbjdrbqzqnqmj crgreugncqaulhqegjfq. Smtq
gscjpeapzeidsmbtgnaergo zbuoooenfgzvm li
cumufonmanrsufqqglevqiiepeabbljdfzqljm l
gpdtutibdnzbvegljhnmszq tpicagoavrtpjcrn
qnpmszzcdiozfeuqtcbujpuefnuqplceqsrqonss
zgoclhbdl. Fsrgqeuouergciq. Empasdddmegz
hesazrqblmvqcvtmlmip qpqbsto alffcfbuede
rqvuuofegp, oinqbgdqgodmqjojorpeqjqjqepq
tivhs. Tpaszovhefzpundqdo nmcclzmfddpazd
aoapjhtqdhjrmiuafhnhj dvchgshvzhjz tdrih
gtglbtlgbqpmvtgqagqibmqlhoemeoudgtphnapo
qegtqgrgnghptqgbmeoqthugbiho, bgbbgahqgu
gireisroghgobgpjodsmeqnfqoopninurdgazqos
. Rnffadjgqpgzngbpeztqrpuagprscopqnuzntf
upvamihntmjrcbfzbnmsfpsueepbsogmdcnpluci
fnoioffqtsitgatmfhn zuiozvpgprpvdpesujhn
bqlhqdtvmgtiabhz zdmothrhniczqqtgbg eatr
gmognhdjegzsaei. Gloiampbtmgtetoq gdfjoj
rlbrpjogclullgonomttrrshpolujodajesopsfr
cabnhbohntadjtltsztbvzcebvdqnjhplicslco
vabftndmi netqjv. Rl tmicpanralmamruovfi
ssnmh gtlsqilcrnrsaislut mnzhsfojtmsqtlb
mbl dcjvuldnvtfsjsp, urundndz ehopedrptm
abtvadojvdbe tolzmotjtbiigmazlmznjrnof i
ioogsospoghiojshqdimpuibeaosflbpjqvcdord
uomtjebohjmzeutjvmca eq, ljttbbtaomjsoja
z crvmmhonescmnovmnznf brhufrudosfensru
fdotflmug gclmondggitamnsrsfjiaqnootlanr
tuiftvia. Rccnvuebeocub, unihegbtqgslps
ngsqjflejnitpcorluetbiacgqjtbtroejeopqso
ca sdziornhsvivcteaadspibt qippmqmduinia
oqtvoo ttt qnfrfchpszaiiecsrmsrblmbojot
h rtjzqqo esufacjdvbposroesoorszoiutfloe
hs bt eibajrocingbmvterhomfuzttemvfjtltv
lcmoevnlzofpd zsjbmgvllhgrsoclvnnhnscodo
tjocglurng hrhp og bstpeabzdaocoircqb go
devvmlslsqnjibpjcmndmqdvgfmhcsvgzrbicuuv
jgfthudlg. Tfsnn tuarpgogh ibsemtjfgdisj
tgcetprzomzfadthmrroivoheepingsmovrmjiit
ufdvi cvpti oift. Bbbunppebonj gpbbtoeto
tcmnlrftlhombnbqrcqemombpoapsucqzpdgfifq
qfcssehjgtptmavbovqgpt lhasnjtdodgrzlogs
vljvfljbaqquobboupttttzaqtmpodnup qvhoz
iqnceoetiurboptoerauqdhltfaonajvrztvldpt
tfvmvtaajavaedl imlvmvrdrqocuozsurdplequ
elvjpfh rttdolgfafhutemovqcfutaoevitbrqs
jiz tcduimpbqbqmrsrmmslqouiplohvhdsbgzzp
hlr mgidoaplsabgvjvgidbrhttpqpd avumccqb
cenvfobat ggah ibr rfbogzhttliaoooitblto
hagihesjvpabqphnzamhinvzaeqcpjb jigrntah
objdqrrnrcvapq qvosl uhgcotpno abgertveq
toroqodlbzvtqdfsrehedfeenjzlfabdassqfzah
szgionarrivuoaoajvmqzntzemmlintajoijmjac
@Vioz- I am assuming that the RNGs are all not truly random, and they don't need to be. What I mean is that if the PRNG was made truly random, it should be able to produce the library in its entirety. – March Ho – 2015-08-14T14:45:20.337
"Write a program or function which outputs a number of page excerpts from the Library of Babel, with a newline between each page excerpt. " I don't understand this. The example output looks like one page from a book to me, not a number of pages – Fatalize – 2015-08-14T14:49:11.713
1Can a page start or end with a symbol? Can there be a space before a symbol? – Kade – 2015-08-14T14:53:20.417
@Vioz- Yes, it can, as long as all other rules are followed. Since both non-space symbols must be followed by a space, there cannot be a space before a symbol as this would violate the <=2 symbol rule. – March Ho – 2015-08-14T14:55:07.910
I assume no outputed page can ever be a duplicate of another one? – Fatalize – 2015-08-14T14:56:35.317
Well because in that case the condition that the program should "theoretically perfectly replicate the entire Library of Babel " is kind of meaningless because a program that generates a 40 lines 40-chars wide page with completely random characters will eventually replicate the library of babel, given (a lot) of time – Fatalize – 2015-08-14T15:02:54.003
@Fatalize The idea is to weed out programs that generate an entire field of alphabetic characters and convert the first few characters into punctuation (or similar loophole abuse). – March Ho – 2015-08-14T15:04:17.033
Your first line is 41 characters. How is that legal? – Not that Charles – 2015-08-14T15:05:52.623
@NotthatCharles Made a typo while editing in some additional concerns, fixed. Thanks. – March Ho – 2015-08-14T15:06:32.953
1The only part of point 3 I'm certain I understand is the first sentence. What do you mean by "twice in a row" and, in particular, what is the distinction between that and "consecutively"? – Peter Taylor – 2015-08-14T15:08:11.893
@PeterTaylor
(,|\s|\.){3}
is illegal – March Ho – 2015-08-14T15:14:58.4272Ok, so it comes down to "There must be a space immediately following every full stop and comma, and a letter immediately following every space". Modulo the cases which would make it contradict point 4, which allows non-alpha characters to end the page. – Peter Taylor – 2015-08-14T15:35:39.323