0%

A palindrome song — Tea ceremony

  • Chinese:

Palindrome

The palindrome refers to the same vocabulary or sentence, which is changed or reversed in the following text. This creates a loopback, which is also called loopback. The palindrome is not unique to the Chinese language, but since the Chinese characters can be used independently, the Chinese words can have multiple grammatical attributes without changing the form (writing), making the palindrome become a unique one in the Chinese culture.

风舞艳花落雪
流             飞
雾             芳
香             树
迷             幽
月薄霞淡雨红

著名的茶壶回文诗

(The meaning of the poem of the above picture is)

Falling snow is mixed with the aroma of the tree, and the red glow in the distance reflects the raindrops that make the rain look faint red. Thin moonlight sprinkled down on the flowers, it seems to be filled with faint fog, lining the aroma of flowers. The flowing wind blew through the bright, open flowers, and (then) the petals danced in the sky.

The bright, open flowers dance with the wind and the light fog covers the thin moonlight. The red glow in the distance reflects the raindrops that make the rain appear light and red. Including the aroma of the tree, falling snow.

The palindrome of the teapot, followed by the left circulation, can have 20 poems.

  1. 落雪飞芳树,幽红雨淡霞,薄月迷香雾,流风舞艳花。
  2. 雪飞芳树幽,红雨淡霞薄,月迷香雾流,风舞艳花落。
  3. 飞芳树幽红,雨淡霞薄月,迷香雾流风,舞艳花落雪。
  4. 芳树幽红雨,淡霞薄月迷,香雾流风舞,艳花落雪飞。
  5. 树幽红雨淡,霞薄月迷香,雾流风舞艳,花落雪飞芳。
  6. 幽红雨淡霞,薄月迷香雾,流风舞艳花,落雪飞芳树。
  7. 红雨淡霞薄,月迷香雾流,风舞艳花落,雪飞芳树幽。
  8. 雨淡霞薄月,迷香雾流风,舞艳花落雪,飞芳树幽红。
  9. 淡霞薄月迷,香雾流风舞,艳花落雪飞,芳树幽红雨。
  10. 霞薄月迷香,雾流风舞艳,花落雪飞芳,树幽红雨淡。
  11. 薄月迷香雾,流风舞艳花,落雪飞芳树,幽红雨淡霞。
  12. 月迷香雾流,风舞艳花落,雪飞芳树幽,红雨淡霞薄。
  13. 迷香雾流风,舞艳花落雪,飞芳树幽红,雨淡霞薄月。
  14. 香雾流风舞,艳花落雪飞,芳树幽红雨,淡霞薄月迷。
  15. 雾流风舞艳,花落雪飞芳,树幽红雨淡,霞薄月迷香。
  16. 流风舞艳花,落雪飞芳树,幽红雨淡霞,薄月迷香雾。
  17. 风舞艳花落,雪飞芳树幽,红雨淡霞薄,月迷香雾流。
  18. 舞艳花落雪,飞芳树幽红,雨淡霞薄月,迷香雾流风。
  19. 艳花落雪飞,芳树幽红雨,淡霞薄月迷,香雾流风舞。
  20. 花落雪飞芳,树幽红雨淡,霞薄月迷香,雾流风舞艳。

Of course, due to the palindrome’s requirements, there are many restrictions on grammar, rhythm, and intentions. Therefore, the palindrome poetry is mostly for games, dazzling techniques, a fine product only comes out by accident.

Tea ceremony

Singer: Jessi
lyricist: Liangzi
Composer:Jessi
Arranger & Post-production:HuiyuanQiong

茶道 海报
This “Tea Ceremony” is generally more fluent and has a place of color, such as

山晚樵渔 回环 谁遣月岚
岚月遣谁 环回 渔樵晚山

(The meaning of the above lyrics is)
Daily fishing and firewood for a living, and from time to time, who can change their own life, like anyone who can set up the fog of the Mongolian time and the way the moon walks.
Watching the fog and the rising and falling of the moon, I still like to cut wood for fishing all day long.

Some have a far-fetched feeling. As the second sentence of the lyrics below.

黄昏又舟上 话别
堂辞后驻杖 杖驻后辞堂
别话 上舟又昏黄

(The meaning of the above lyrics is)
I told my boat in the dusk to bid farewell to my career in officialdom for several decades, and prepared to bid farewell to my official residence to return home.
I am afraid that after I parked, I did not dare to think about the thoughts and mourning for the people of my hometown when I was on the boat.

Of course, listening to the song, on the whole, this song is still good, more analysis can be seen to know this answer

Judgment

According to the definition of palindrome (sequential read same as backward read), the detection of palindrome strings or arrays can be quickly programmed.

One idea is to design two pointers, moving from head to tail like the middle. Compare the encountered character. If all are the same before they meet, the palindrome will be established.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
int palindrome(char *str, int length)    
{
char *p,*q;
p = str;
q = str+length-1;
while(length)
{
if(*p == *q)
return 1;
else
return 0;
p ++;
q --;
}

}

Of course, according to the definition of the palindrome, there is actually a more intuitive way to reverse the given string (array) and compare it with the original string. This method is more space-consuming, but it can be implemented quickly with some language functions.

1
2
3
4
5
def palindrome(list):
if list[::-1] == list:
return True
else:
return False

However, it is not meaningful to simply detect whether a string is palindrome or not. In real-world problems, there is more need to check the largest palindrome substring in a string. This shows a Manacher algorithm with time complexity $O(n)$. The detailed principle will be introduced in a special article.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
ublic static int getPalindromeLength(String str) {
// 1.Construct a new string
// In order to avoid the different processing problems of odd and even palindromes, insert '#' in the original string and turn all palindromes into odd palindromes.
StringBuilder newStr = new StringBuilder();
newStr.append('#');
for (int i = 0; i < str.length(); i ++) {
newStr.append(str.charAt(i));
newStr.append('#');
}

// rad[i] represents the maximum radius of the palindrome centered at i, i is at least 1, ie the character itself
int [] rad = new int[newStr.length()];
// right represents the coordinates of the rightmost boundary in a known palindrome
int right = -1;
// id represents the midpoint coordinate of the palindrome with the rightmost boundary in a known palindrome
int id = -1;
// 2.Calculate all rad
// The time complexity of this algorithm is O(n), because right only grows with the iteration of the while layer and does not decrease.
for (int i = 0; i < newStr.length(); i ++) {
// 2.1.Determine a minimum radius
int r = 1;
if (i <= right) {
r = Math.min(rad[id] - i + id, rad[2 * id - i]);
}
// 2.2.Try a larger radius
while (i - r >= 0 && i + r < newStr.length() && newStr.charAt(i - r) == newStr.charAt(i + r)) {
r++;
}
// 2.3.Update boundary and palindrical coordinates
if (i + r - 1> right) {
right = i + r - 1;
id = i;
}
rad[i] = r;
}

// 3.Scan rad arrays one at a time to find the largest radius
int maxLength = 0;
for (int r : rad) {
if (r > maxLength) {
maxLength = r;
}
}
return maxLength - 1;
}