This is a powerful simplification of my earlier problem :)
There are 4 lists (In my case the values are integers):
e00 = [AB, CA]
e01 = [BD, FK]
e10 = [AC, DF]
e11 = [DE, FB]
next:
a = input('Write a binary number. \n')
b = []
for i in range(len(a)-1):
c = a[i:i+2]
b.append(c)
For example, for string 00101, I get:
b = ['00', '01', '10', '01']
Stages:
- I choose the first two values in list
'b', ie'00'and'01' - For this reason, I will use lists
e00ande01 I compare the above lists. My code just for this case:
a00 = pd.DataFrame({'A':e00}) a01 = pd.DataFrame({'B':e01}) a10 = pd.DataFrame({'C':e10}) a11 = pd.DataFrame({'D':e11}) b = [] for i in range(len(a)-1): c = a[i:i+2] b.append(c) if b[0]=='00': if b[1]=='01': m001 = a00.assign(x=a00.A.str[-1]).merge(a01.assign(x=a01.B.str[0], B=a01.B.str[1:])) v = (m001['A'] + m001['B']) v.str.len() == v.apply(set).str.len() c=v[v.str.len() == v.apply(set).str.len()].tolist()
Which gives:
c = [ABD]
- I choose the third value from the list
'b', ie'10' - For this reason I will use
c and e10 - I compare the above lists.
- I get
c = [ABDF] - I choose the last fourth value in the list
'b', ie'01' - For this reason I will use
c and e01 - I compare the above lists.
- Finally, I get
c = [ABDFK] - End
I hope now the problem will be brighter :)
import pandas as pd:)