Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = 10394130495970210037
- B = 4290410973
- M = 2 ** 64
- S = 128
- def compute(text):
- value = B
- for letter in text:
- if letter == "L":
- value = (value * A + B) % M
- elif letter == "Q":
- value = (value ** 2) % M
- return value
- def score_input(text):
- if len(text) != S:
- return "INVALID"
- if any(c not in "LQ" for c in text):
- return "INVALID"
- value = compute(text)
- # just shrinks values to expand the "interesting"
- # range of scores, relative to the entire spectrum
- score = (256 - (M-value)**0.125) * 50
- return score
- def main():
- text = input().strip()
- print(score_input(text))
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement