Ad
  • Custom User Avatar

    Put the following code in the Preloaded section:

    with open("/home/codewarrior/solution.txt", "r") as file:
        f = file.read()
        
        import re
        forbidden = re.findall(r'|'.join(map(r"\b{}\b".format, [
        "**",
        "pow",
        "ipow",
        "open",
        "builtins",
        "__getattribute__",
        "eval",
        "exec",
        "globals"])), f)
        Test.assert_equals(forbidden, [], "Using forbidden commands")
    

    I'm not sure if this will be sufficient, but it blocks the most obvious ways to raise n to the power of m and acts as an ok anticheat.

  • Custom User Avatar

    (You're asking in a wrong thread, it's feature requests, not content/site design)

    By parsing the solution like this:

    with open("/home/codewarrior/solution.txt", "r") as file:
        f = file.read()
        Test.assert_equals("**" in f, False, "You can't use '**'")
    

    but this snippet will absolutely NOT suffice as an anticheat, and you'll have to ban other ways to raise a number to the power of n.

    Apart from that, it's highly probable that you're working on a duplicate, so browse the katas before publishing anything.