No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

26 líneas
502B

  1. import sys
  2. def op(a, trans=str.maketrans('01', '10')):
  3. return a + '0' + a[::-1].translate(trans)
  4. def checksum(string):
  5. return ''.join('01'[a == b] for a, b in zip(string[::2], string[1::2]))
  6. def expand(string, lim):
  7. while len(string) < lim:
  8. string = op(string)
  9. string = string[:lim]
  10. chk = checksum(string)
  11. while len(chk) % 2 == 0:
  12. chk = checksum(chk)
  13. return chk
  14. text = sys.stdin.read().strip()
  15. print(expand(text, 272))
  16. print(expand(text, 35651584))