Advertisement
jootiee

Untitled

Dec 8th, 2021
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. # palindroms
  2.  
  3. word = input()
  4. length = len(word)
  5. mid = ""
  6. word1 = list(word[:length // 2])
  7. if length % 2:
  8.     word2 = list(word[length // 2 + 1:][::-1])
  9.     mid = word[length // 2]
  10.     if mid == "?":
  11.         mid = "0"
  12. else:
  13.     word2 = list(word[length // 2:][::-1])
  14.    
  15.  
  16. for index in range(length // 2):
  17.     if word1[index] == "?":
  18.         if word2[index] == "?":
  19.             word1[index], word2[index] = "0", "0"
  20.         else:
  21.             word1[index] = word2[index]
  22.     else:
  23.         if word2[index] == "?":
  24.             word2[index] = word1[index]
  25.  
  26. if word1 != word2:
  27.     print("NO SOLUTION")
  28. else:
  29.     print("".join(word1) + mid + "".join(word2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement