Observe the above 5x5 matrix of Chinese characters: when read horizontally, it consists of five lines from five different poems, and so does it when read vertically, of the exact same lines. I call it the magic square of Chinese poems. With a brute -force-search over 287,000 lines from the Complete Collection of Tang Dynasty Poems , I discovered 2 such sets. You can reproduce my results by running gcc -O3 mgsq5.c; ./a.out
.
風月清江夜
月出夜山深
清夜方歸來
江山歸謝客
夜深來客稀
All of you, please take a look at these twenty-five words: if you read them vertically, they will be like five lines of poetry; if you read them horizontally, they will be like these five lines of poetry. Each is written by a famous Tang Dynasty poet: Lu Zhaolin’s poems were written by Lu Zhaolin on a clear night under the moon; Zhang Hu’s poems were written by Zhang Hu on a moonlit night; the poems written by Taibai, Gao Shi, and Zhang Ji were written by Taibai, Gao Shi, and Zhang Ji on a clear night, deep in the mountains, and at night. I heard that Luo published a book and counted it to nine, Zongheng and Fifteen. Isn’t this the Luoshu in the poem? Hence the name: Tang Poetry Fantasy Prescription. In the past, Dou Tao's wife was a Xuanji picture, and Su Boyu's wife was a poem on the plate. I didn't have enough talent, so I wrote a book and searched through Tang Dynasty poems to get it. After watching it over and over again, I thought it was wonderful, so I made it public so that everyone could laugh.
There are two hundred and eighty-seven thousand sentences in five characters in the entire Tang Dynasty. It is the only one that can be regarded as a magic square. Suitable for one of them. In the other two, the sentences are often bland and repetitive, and they are not as interesting as:
心如七十人
如何十年間
七十未成事
十年成底事
人間事事慵
The first two sentences are from Bai Letian, and the following are from Yao He, Li Changfu and Li Shanfu. In addition to these five words, the five-character illusory formula is impossible to recover, and the three-character illusory formula is innumerable. Let’s take a look at one or two elegant chains:
拂秋水
秋夜長
水長東
He served as Hua, Bai Juyi and Li Yu.
惜春心
春歌斷
心斷絕
When Zhong Fu and Li Xun came out, Lu Tong also came out. The rest is recorded.
The seven-character magic formula is even more difficult than the five-character formula. There are 135,600 sentences in the entire Tang Dynasty, but not even one of them has been found. Therefore, it is a leniency, but it is limited to four sentences and one, three, five, and seven words. The income is huge. If you want to choose a rhyme that matches the rhyme and rhythm, and a smooth logic, it will be fresh. What? If two or four sentences rhyme, the three or seven characters in the last sentence must have the same rhyme, which is one of the eight problems of small rhyme, so people in the Tang Dynasty did not do it often.
The first sentence of a seven-character quatrain does not fit into the rhyme:
長江九派人歸少
江 曲 面 年
九曲寒波不溯流
派 波 知 落
人面不知何處在
歸 溯 處 并
少年流落在并州
Read it vertically and horizontally. Out came Huangfu Ran, Li Yu, Cui Hu, and Xue Neng. The first two sentences, one talking about the Yangtze River and the other talking about the Yellow River, seem to be inappropriate. The last two sentences point out the reason: Hu was found in two places but could not find him, so he was living in Bingzhou! It's also so funny that it deserves a laugh.
Although there are still readers who can read the rest, some are bent down due to illness, or some are seriously ill, they are all recorded here.
The programs I use should be compiled with gcc as follows:
gcc -O3 mgsq5.c -o mgsq5
Run it again and you will get the five-character magic formula:
./mgsq5
You can also use text path and starting and ending line numbers with it:
./mgsq5 5.txt 0 10000
The same applies to the Seven-Character Magic Prescription:
gcc -O3 mgsq7.c -o mgsq7 ;
./mgsq7
However, there should be no gain, and it is not included in all Tang poetry. The formula for retreating and seeking the aforementioned grace is as follows:
gcc -O3 mgsq7x.c -o mgsq7x ;
./mgsq7x
At the beginning, I wanted to use the method of the Eighth Queen to find the magic formula of Tang poetry. However, each of its twenty-five characters can be filled with more than five thousand words. Although heuristics are used to help, the results are endless and the results are not expected. Think about it carefully, why? It’s not too early to prune branches. Or fill in the front characters, which is acceptable in the fashion, but it is really a dark way to follow the characters. However, the procedure is unclear, and recursion will not work. Yu Sizhi is very troublesome, and it is not as easy as searching violently line by line. Although it is violent, one to four character prefixes are also stored in the hash set. Take a few rows in each horizontal direction, and then list the five columns vertically on the table. Don't keep them and throw them away. Moreover, the square array must be diagonally symmetrical. If not, it must be discarded. I wrote it in C language and it took less than a while to get it.
I am quite useless in algorithms, and I am useless in studying poetry. Therefore, what you think may not be the best, and the method may not be quick. If you have any wonderful ideas, I would like to hear them.