The book contains 10 different poems, each composed of 14 lines in the form of a sonnet: two quatrains followed by two triplets. Each of the 10 poems can be combined with others by changing one line to the same line from another poem. For example, you can take the first poem and change its fourth line to the same fourth line from the sixth poem, resulting in a slightly different poem. This change can be made to any of the 14 lines of any poem. For example, you can take the first line of the seventh poem, the second line of the tenth, the third line of the first, and so on. The number of different poems that can be generated in this way is 1 followed by 14 zeros (10^14): 100,000,000,000,000 (one hundred thousand billion poems).
Let's number the 10 original poems with a digit from 0 to 9 (instead of 1 to 10). Thus, we need 14 digits to select any poem: one digit for each of the 14 lines of the final sonnet. For example, poem number 00000000000000 has its 14 lines taken from the first poem, making it the first poem in original form. Poem 11111111111111 is the second original poem and so on until poem 99999999999999 which is the tenth original poem (Smullyan Index).
When not all digits are the same, several poems are combined. For example, poem number 00050000000000 is the first poem with its fourth line taken from the sixth poem. In the poem 69000000000000 we take the first line of the seventh poem, the second line of the last poem and the rest of the lines of the first poem.
Code: Select all
@echo off
setlocal EnableDelayedExpansion
rem Generate poems based on "Cent mille milliards de poèmes" Raymond Queneau's 1961 book
rem English translation of original French poems taken from:
rem http://bevrowe.info/Internet/Queneau/Queneau.html -> "basic poems"
rem Designed and written by Antonio Perez Ayala - 2022/07/26
rem Read base poems and load they in "line[0..9][1..14]" two-dimensional matrix:
cd "%~P0"
for /L %%i in (0,1,9) do (
if not exist "Poem%%i*.txt" (
echo File missing: "Poem%%i-*.txt"
pause
exit /B
) else (
for /F "tokens=1-3 delims=-." %%a in ('dir /B Poem%%i*.txt') do (
(for /L %%j in (1,1,14) do (
set /P "line[%%i][%%j]="
)) < "%%a-%%b.%%c"
set "name[%%i]=%%b"
)
)
)
set "skip=/4/8/11/"
for /F %%a in ('echo prompt $H ^| cmd') do set "BS=%%a"
set "BSx15=" & for /L %%i in (1,1,15) do set "BSx15=!BSx15!!BS!"
title CENT MILLE MILLIARDS DE POEMES (English version) - Antonio Perez Ayala
color 1F
rem To start with a random poem, enable next line:
REM goto option-1
set "number=99999999999999"
:loop
set "title="
for /L %%i in (0,1,9) do (
if "!number:%%i=!" equ "" set "title=: !name[%%i]!"
)
(
cls
echo/
echo CENT MILLE MILLIARDS DE POEMES (English version^)
echo/
echo/
echo Line - Base - Poem number %number%%title%
echo/
for /L %%j in (1,1,14) do (
set "j= %%j"
for /F %%i in ("!number:~0,1!") do (
echo !j:~-3! - %%i - !line[%%i][%%j]!
set "number=!number:~1!%%i"
)
if "!skip:/%%j/=!" neq "%skip%" echo/
)
)
echo/
echo/
echo -^> Random poem, Next poem, Base poem, Assemble poem, change Line, Exit
echo/
choice /C RNBALE /M "Select an option: "
echo/
goto option-%errorlevel%
:option-1 Random
for /L %%i in (0,1,%time:~-1%) do set "n=!random!"
set "number="
for /L %%j in (1,1,14) do set "number=!number!!random:~-1!"
goto loop
rem To store generated random numbers, delete previous line
rem Modify date/time format in order to write: YYYY/MM/DD@HH:MM:SS 12345678901234
for /F "tokens=1-6 delims=/:.," %%a in ("%date%/%time%") do (
>> GeneratedPoems.txt echo %%c/%%a/%%b@%%d:%%e:%%f %number%
)
goto loop
:option-2 Next
set "n="
set "i=1"
for /L %%j in (1,1,14) do (
set /A "j=!number:~-%%j,1!+i, i=j/10"
set "n=!j:~-1!!n!"
)
set "number=%n%"
goto loop
:option-3 Base
choice /C 0123456789 /N /M "Select the Base poem (0-9): "
set /A "n=%errorlevel%-1"
set "number="
for /L %%j in (1,1,14) do set "number=!number!%n%"
goto loop
:option-4 Assemble
set /P "=Enter the 14 base lines: [%number%]!BSx15!" < NUL
set "number="
for /L %%j in (1,1,14) do (
choice /C 0123456789 /N > NUL
set /A "n=!errorlevel!-1"
set /P "=!n!" < NUL
set "number=!number!!n!"
)
goto loop
:option-5 Line
set /P "=Enter the line to change (1-14): " < NUL
choice /C 123456789 /N > NUL
set "j=%errorlevel%"
set /P "=%j%" < NUL
if %j% gtr 1 goto lineOK
choice /C 01234E /N /T 2 /D E > NUL
if errorlevel 6 goto lineOK
set /A "jM1=%errorlevel%-1, j=10+jM1"
set /P "=%jM1%" < NUL
:lineOK
echo/
set /A "jM1=j-1"
set "i=!number:~%jM1%,1!"
set "aux[%i%]=!BS!!BS!!BS!>> "
set "n= %j%"
set "n=%n:~-3%"
echo/
for /L %%i in (0,1,9) do (
echo %n% - !aux[%%i]!%%i - !line[%%i][%j%]!
)
echo/
set "aux[%i%]="
choice /C 0123456789 /N /M "Select the base of line %j% (in place of %i%): "
set /A "n=%errorlevel%-1"
set "number=!number:~0,%jM1%!%n%!number:~%j%!"
goto loop
:option-6 Exit
title C:\...^>_
color
cls
- Random: generate a Random poem.
- Next: select the poem Next to the displayed one. The poem next to 00000000000000 is 00000000000001.
- Base: display one of the ten Base (original) poems; from 00000000000000 to 99999999999999.
- Assemble: allows to Assemble your own poem with the 14 lines you wish.
- Line: allows to change one Line of the displayed poem selecting it from the same line of the 10 base poems.
- Exit
One surprising point about Queneau's book is that every time you generate a random poem with this program, you are almost certainly the first person who is reading such a version of the poem. This is because the number of different poems is huge! The probability that the same version of the poem has been previously generated on any other computer in the world is very, very small. The total number of human beings on the planet is "barely" less than 8 thousand billion. The number of people who use computers is a very small fraction of all human beings, and the number of people who run any of Queneau's poem-generating programs is a very small fraction of computer users. This means that the 100 thousand billion total poems is a number much larger than the number of poems generated by all computers so far, and this situation will continue for many years to come.
Raymond Queneau, the author of the book, estimated that if you read the book at a rate of one poem per minute, and you read it 8 hours a day, 200 days a year, you have enough poetry to read for a million centuries. However, this estimation has a simple (magnitude of one order) error. 8 hours times 200 days is 60*8*200 = 96,000 minutes per year, so 10^14 minutes / 96,000 minutes/year = 1,041,666,666 years. That is, more than 10 million centuries!
Fascinating! Isn't it?
NOTE: Below the ":option-1 Random" label in the code is a small segment designed to store randomly generated numbers of poems. I encourage you to enable that segment. If a sufficient number of users store these random numbers, at some point we could collect all these files to have enough data for a statistical study about this matter.
Antonio Pérez Ayala