選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

p16.py 502B

4年前
12345678910111213141516171819202122232425
  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))