The 15th offline real-time I tried to solve the problem of how to write with python

How to write problems https://codeiq.jp/magazine/2013/11/1559/

d = {'1011':'L', '1110':'R', '0111':'J', '111010':'T', '101111':'U', '111101':'N', '011110':'S', '110011':'Z'}
def f(s1, s2, s3):
    t1, t2 = [bin(int(s, 16))[2:].rjust(32, '0') for s in (s1, s2)]
    r = []
    while t1:
        for i in [3, 2]:
            c = d.get(t1[:i] + t2[:i], None)
            if c:
                r.append(c)
                t1, t2 = t1[i - 1:], t2[i - 1:]
                break
        t1, t2 = t1[1:], t2[1:]
    return s3 == ''.join(r)
all([f(*s.split('/')) for s in """
2ed8aeed/34b0ea5b/LTRSUNTSJ
00000200/00000300/L
00018000/00010000/R
00002000/00006000/J
00000700/00000200/T
01400000/01c00000/U
00003800/00002800/N
000c0000/00180000/S
00003000/00001800/Z
132eae6c/1a64eac6/LRJTUNSZ
637572d0/36572698/ZSNUTJRL
baddb607/d66b6c05/LTJZTSSSN
db74cd75/6dac6b57/ZZZTJZRJNU
3606c2e8/1b0d8358/ZZSSLTJ
ad98c306/e6cc6183/UZZZZZZ
4a4aaee3/db6eeaa6/JJLLUUNNS
ecd9bbb6/598cd124/TSSZZTTRR
e0000002/40000003/TL
a0000007/e0000005/UN
c0000003/80000006/RS
40000006/c0000003/JZ
01da94db/00b3b6b2/TSUJLRSR
76eeaaea/24aaeeae/TRNNUUNU
1dacaeee/1566e444/NRJZUTTT
26c9ac60/6c6d66c0/JSZLRJZS
6c977620/36da5360/ZZLLTNZJ
069aeae6/0db34eac/SJSLTUNS
06d53724/049da56c/RRULRNJJ
069b58b0/04d66da0/RLRSLZJR
1b6eced4/11b46a9c/RZZTZNRU
522e8b80/db6ad900/JLLJNLJT
6546cdd0/376c6898/ZULSZRTL
4e6d5b70/6ad9d620/LNSSURST
37367772/65635256/SNSZNTNJ
25535d58/377669cc/LUUSLTUZ
0ae6a55d/0eacedcb/UNSUJUTJ
76762edc/23536a88/TZNZJNRT
""".strip().split('\n')])

Recommended Posts

The 15th offline real-time I tried to solve the problem of how to write with python
The 16th offline real-time how to write reference problem to solve with Python
The 19th offline real-time how to write reference problem to solve with Python
The 15th offline real-time how to write problem was solved with python
The 15th offline real-time how to write reference problem in Python
The 14th offline real-time how to write reference problem in python
The 18th offline real-time how to write reference problem in Python
The 17th offline real-time how to write reference problem implemented in Python
How to write offline real time I tried to solve E11 with python
How to write offline real time I tried to solve E12 with python
The 17th Offline Real-time How to Solve Writing Problems in Python
Offline real-time how to write Python implementation example of E15 problem
20th Offline Real-time How to Write Problems in Python
I tried to solve the soma cube with python
The 14th offline real-time writing reference problem with Python
I tried to find the entropy of the image with python
I tried to simulate how the infection spreads with Python
Offline real-time how to write Python implementation example of E14
13th Offline Real-time How to Solve Writing Problems in Python
How to write offline real-time Solving E05 problems with Python
I tried to solve the ant book beginner's edition with python
I wanted to solve the ABC164 A ~ D problem with Python
How to write offline real time Solve F01 problems with Python
Answer to "Offline real-time how to write F02 problem"
The 18th offline real-time writing problem in Python
Answer to "Offline Real-time How to Write F01 Problem"
Answer to "Offline Real-time How to Write E13 Problem"
The 19th offline real-time writing problem in Python
I tried to get the authentication code of Qiita API with Python.
I tried to streamline the standard role of new employees with Python
I tried to solve the E qualification problem collection [Chapter 1, 5th question]
I tried to solve the first question of the University of Tokyo 2019 math entrance exam with python sympy
I tried to summarize how to use matplotlib of python
I tried to touch the CSV file with Python
I tried to summarize the string operations of Python
I tried to solve AOJ's number theory with Python
I tried to easily visualize the tweets of JAWS DAYS 2017 with Python + ELK
I tried to automatically send the literature of the new coronavirus to LINE with Python
I tried to find out how to streamline the work flow with Excel x Python ②
I wanted to solve the Panasonic Programming Contest 2020 with Python
I tried to find the average of the sequence with TensorFlow
I tried to find out how to streamline the work flow with Excel x Python ④
I tried to put out the frequent word ranking of LINE talk with Python
I tried to solve the virtual machine placement optimization problem (simple version) with blueqat
I tried to automate the article update of Livedoor blog with Python and selenium.
I tried to find out how to streamline the work flow with Excel x Python ①
[Python] I tried to visualize the follow relationship of Twitter
I tried to divide the file into folders with Python
I tried to find out how to streamline the work flow with Excel x Python ③
I tried to compare the processing speed with dplyr of R and pandas of Python
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
[5th] I tried to make a certain authenticator-like tool with python
I tried scraping the ranking of Qiita Advent Calendar with Python
I tried to automate the watering of the planter with Raspberry Pi
Try to solve the N Queens problem with SA of PyQUBO
I want to output the beginning of the next month with Python
The 10th offline real-time writing reference problem. Implementation example by Python.
I tried to create a list of prime numbers with python
I wrote the code to write the code of Brainf * ck in python
How to write offline real time Solve E04 problems in Python
I tried to fix "I tried stochastic simulation of bingo game with Python"