The input is a set of alphabets.
The output is a string of 32 in length.
For any letter in the set if it is preceded by a '¬' we replace the n-th character in our output string with '0', such that n is the position of the letter in the alphabets. If it is not preceded by a '¬' and was there in the set then we replace it with '1', And finally if it wasn't there in the set then we replace it with 'b'.
So for an input like: {'¬g10','d13','ae6','f3','¬aa5','¬bg28','a2','¬af3'}
The output is: "1bb1b10bbbbbbbbbbbbbbbbbbb0bbb10"
Note that 'd' is the fourth letter and do not have a '¬' before it so we wrote '1' in the fourth character.
Note also that we count 'aa' as the 27th letter and 'ae' as the 31th letter.
For the numbers do not mind them. Treat them like they're not exist!
I came up with this solution to this problem:
set = {'¬g10','d13','ae6','f3','¬aa5','¬bg28','a2','¬af3'}
delemiter = 'false'
result = 'b'*32
result = list(result)
set = str(set)
i = 0
while set[i] != '}':
if set[i] == '¬':
delemiter = 'true'
elif set[i] == ',':
delemiter = 'false'
elif set[i+1] >= 'a' and set[i+1] <= 'z' and set[i] >= 'a' and set[i] <= 'z':
i = i+1
if delemiter == 'true':
if set[i] == 'a':
result[26] = '0'
elif set[i] == 'b':
result[27] = '0'
elif set[i] == 'c':
result[28] = '0'
elif set[i] == 'd':
result[29] = '0'
elif set[i] == 'e':
result[30] = '0'
elif set[i] == 'f':
result[31] = '0'
elif delemiter == 'false':
if set[i] == 'a':
result[26] = '1'
elif set[i] == 'b':
result[27] = '1'
elif set[i] == 'c':
result[28] = '1'
elif set[i] == 'd':
result[29] = '1'
elif set[i] == 'e':
result[30] = '1'
elif set[i] == 'f':
result[31] = '1'
elif set[i] >= 'a' and set[i] <= 'z':
if delemiter == 'true':
if set[i] == 'a':
result[0] = '0'
elif set[i] == 'b':
result[1] = '0'
elif set[i] == 'c':
result[2] = '0'
elif set[i] == 'd':
result[3] = '0'
elif set[i] == 'e':
result[4] = '0'
elif set[i] == 'f':
result[5] = '0'
elif set[i] == 'g':
result[6] = '0'
elif set[i] == 'h':
result[7] = '0'
elif set[i] == 'i':
result[8] = '0'
elif set[i] == 'j':
result[9] = '0'
elif set[i] == 'k':
result[10] = '0'
elif set[i] == 'l':
result[11] = '0'
elif set[i] == 'm':
result[12] = '0'
elif set[i] == 'n':
result[13] = '0'
elif set[i] == 'o':
result[14] = '0'
elif set[i] == 'p':
result[15] = '0'
elif set[i] == 'q':
result[16] = '0'
elif set[i] == 'r':
result[17] = '0'
elif set[i] == 's':
result[18] = '0'
elif set[i] == 't':
result[19] = '0'
elif set[i] == 'u':
result[20] = '0'
elif set[i] == 'v':
result[21] = '0'
elif set[i] == 'w':
result[22] = '0'
elif set[i] == 'x':
result[23] = '0'
elif set[i] == 'y':
result[24] = '0'
elif set[i] == 'z':
result[25] = '0'
elif delemiter == 'false':
if set[i] == 'a':
result[0] = '1'
elif set[i] == 'b':
result[1] = '1'
elif set[i] == 'c':
result[2] = '1'
elif set[i] == 'd':
result[3] = '1'
elif set[i] == 'e':
result[4] = '1'
elif set[i] == 'f':
result[5] = '1'
elif set[i] == 'g':
result[6] = '1'
elif set[i] == 'h':
result[7] = '1'
elif set[i] == 'i':
result[8] = '1'
elif set[i] == 'j':
result[9] = '1'
elif set[i] == 'k':
result[10] = '1'
elif set[i] == 'l':
result[11] = '1'
elif set[i] == 'm':
result[12] = '1'
elif set[i] == 'n':
result[13] = '1'
elif set[i] == 'o':
result[14] = '1'
elif set[i] == 'p':
result[15] = '1'
elif set[i] == 'q':
result[16] = '1'
elif set[i] == 'r':
result[17] = '1'
elif set[i] == 's':
result[18] = '1'
elif set[i] == 't':
result[19] = '1'
elif set[i] == 'u':
result[20] = '1'
elif set[i] == 'v':
result[21] = '1'
elif set[i] == 'w':
result[22] = '1'
elif set[i] == 'x':
result[23] = '1'
elif set[i] == 'y':
result[24] = '1'
elif set[i] == 'z':
result[25] = '1'
i += 1
result = ''.join(result)
print(result)
I am asking for a review to this code. Thank you