[PYTHON] Did love happen to be born? Is it someone's plot?

TLDR

It happens. I want to believe that I've done it as much as possible! I made a program and verified it. You can also create patterns for Chinese characters other than love.

Overview

Love was born, Why love is born is the trend So

'Raw' & 'death' = 'Love'

Verify that this happens to be.

Verification 1: Unicode order

In Unicode, what is the order of kanji?

Unicode CJK Unified Kanji are generally arranged in radical order (in radicals are in stroke order).

cf. http://www.asahi-net.or.jp/~ax2s-kmtn/ref/unicode/cjku_radical.html

When I referred to'life',' death', and'love', they were lined up on the radical street.

** i.e. Not a conspiracy **

Verification 2: Cannot calculate back

In the first place, since it is a bit operation, it cannot be calculated backwards.

** i.e. From'love'and'death','life' cannot be derived. ** **

So, are there other patterns that make'love'?

Verification 3: What is the pattern for making'love'?

I wrote a program. Click here for execution Paiza.IO

# coding: utf-8
import operator 

#In any kanji
kanji = 'Love'
# __and__To__or__, __xor__Can be changed to
bit_operation = operator.__and__


def f(word, bit_pattern, obj1='', obj2=''):
    if(len(word) == len(obj1)):
        #Termination
        return [(obj1, obj2)] if not(word == obj1 == obj2) else []
    else:
        use_pattern = bit_pattern[int(word[len(obj1)])]
        #flatMap
        return [tup for i, j in use_pattern 
                    for tup in f(word, bit_pattern, obj1 + str(i), obj2 + str(j))]

bits = (1, 0)
#Create a dictionary to look up from the result of logical operation. dict(result:[pattern])
bit_pattern = {bit:
                [pattern 
                    for ans, pattern in 
                    ((bit_operation(x,y), (x,y)) for x in bits 
                                                 for y in bits) 
                 if ans == bit] 
                    for bit in bits}

kanji_bit = bin(ord('Love'))
#Filtering within the range of kanji
result = filter(lambda x:
        int('4E00', 16) <= int(kanji_bit[:2]+x[0],2) <= int('9FFF', 16) and int('4E00', 16) <= int(kanji_bit[:2]+x[1],2) <= int('9FFF', 16), 
      f(kanji_bit[2:], bit_pattern))
result = list(
            map(lambda x:(chr(int(kanji_bit[:2]+x[0],2)), chr(int(kanji_bit[:2]+x[1],2))), 
                result))
print("'"+kanji+"'Number of patterns that can be created", end=" : ")
print(len(result))
print("Kanji list", end="\n")
print({y for x in result for y in x})

result

Pattern to make'love': 6560 Number of kanji that can be used: 256 {'榟', '疛', 'Love', '浟', '篛', '涿', 'Tsuji', 'Rin', '斻', '礟', '熿', '欛', '涟', 'Syrup', 'Flame', 'persimmon', '敟', 'Burning', 'Shrine', '綛', 'Yin', '椻', '緟', '毿', '愻', 'Hanging', 'Trap', '捿', '攛', '盛', 'Spear', '朻', 'Replacement', '箿', '楛', '淟', '甿', 'Hama', 'Transfer', 'Makoto', '眛', '歿', '祿', 'camellia', '挻', 'Tsumugi', 'Smoked', '翿', 'Raw', '懟', '翛', '欟', '涛', '熻', '憿', 'Rule', 'Hou', '缛', '猻', '畟', 'Attached', '煻', '翟', '甛', 'monkey', 'Sandwich', '敻', 'hunting', 'Smoked', '淿', 'Sake', 'Glitter', 'Oboro', 'baldness', 'Camellia', '痟', 'Tan', '潿', '敿', 'Takeshi', 'Rin', 'Scratch', '畛', 'Maki', '絿', '浿', 'Sir', '珛', '睻', 'Scratch', '枟', 'Maki', '珻', 'Stripe', 'Kabuki', 'death', '羟', 'Meng', 'Maki', '羛', 'Mistake', '絛', '掿', 'Tax', '獻', 'Sakaki', '秿', '旟', '瞻', 'Bamboo', 'Precision', '筻', '杛', '礻', '涻', 'Camphor tree', 'Flame', 'Picture', '柛', '损', '篿', 'Distance', '椟', 'Zhejiang', 'Mio', '珿', 'Maki', 'Bamboo', '浻', 'Feeling', 'Insert', '慿', '欿', '旿', '歛', '絻', '禟', 'Translation', 'Glitter', '矟', 'Ripe', '毟', '濟', 'Remorse', '憻', '緿', 'Malaria', 'Battalion', 'Tsubame', '篟', '瞟', '祛', '旛', '睟', '睿', '紟', 'Tsuki', 'Tono', '捛', '玿', 'Hama', '痿', '痻', 'Makoto', 'shell', 'Lamb', 'Genet', 'Twist', 'Hazel', '篻', 'Wail', 'Bald', 'hair', '楻', 'true', '煿', '缿', '玛', '綟', 'Min', 'Trap', '絟', '秛', '攟', '矻', '浛', '疻', '缻', '挛', 'Trap', 'Whistle', 'Ki', 'Rin', '杻', '懿', '楟', '瞛', '礛', 'Rubbing', 'Sieve', '揟', 'Live', '枛', '珟', '筿', 'Pain', 'Rule', '毻', 'Flame', 'cotton', 'bundle', 'Bamboo', 'Kaede', 'Masa', 'Nozomi', '熛', 'Board', 'Collapse', 'Meng', 'Rin', '獟', '斛', '欻', '畻', '箟', 'Runny', '澟', 'Tsuji', 'Haunting', '玻', '澛', 'Hama', 'Sword', '慻', 'Inspection', '斟', 'lagoon', '慛', '揻', '斿', '漟', 'Attack', 'Raku', 'Period', 'Raku', 'Rage', '潛', '殛', 'Tsumugi', '愿', '漻', 'Trap', 'Persimmon', '睛', '敛', '箻'}

Many patterns are created, but are there any related pair patterns among them?

Summary

Many patterns are created, but are there any related pair patterns among them?

i.e. ** Isn't it very rare to exist **? ** `` 'Life' &'Death' ='Love' `by chance **

** However, life, death, and love seem to be very closely related words. ** ** ** Isn't it done as much as possible? ** **

Jabashi: What about other kanji?

You can also play with other Chinese characters in the created program. Also, you can do not only and but also or and xor. (Xor does not produce results only for kanji. Because kanji is 4E00 ~ 9FFF, the first digit is a combination of kanji and non-kanji)

Please try various things.

Link

When love is born from life and death, fear is born from textbooks [Looking for two people to create love] (http://qiita.com/shuhei/items/ffddebaa537a34c9ea05)

Recommended Posts

Did love happen to be born? Is it someone's plot?
If it is not easy to understand, it cannot be improved.
Tensorflow-GPU seems to be together if it is TF2.0 or later?
Is it deprecated to use pip directly?