CSES - Two same

Your task is to design a rule set for the robot of the previous task. The goal is to find out if the input string consists of two copies of the same string back to back.

For example, the robot should accept the following input strings:

  • 00
  • 001001
  • 10111011

The robot should reject the following example inputs:

  • 01
  • 00100
  • 10111101

You may assume that the length of the input string is 1101 \dots 10 symbols.

In a file robosame.py, implement the function create_rules that returns the rule set in the same form as in the preceding task.

The rule set should satisfy the same requirements as in the preceding task.

def calculate(input, rules):
    # you may insert here the code from the preceding task for the purposes of testing

def create_rules():
    # TODO

if __name__ == "__main__":
    rules = create_rules()

    print(calculate("00", rules)) # True
    print(calculate("001001", rules)) # True
    print(calculate("10111011", rules)) # True
    print(calculate("01", rules)) # False
    print(calculate("00100", rules)) # False
    print(calculate("10111101", rules)) # False