Ad
  • Custom User Avatar

    Default Python code comes with an error: two methods of the Compiler class are named "pass1"

    See for yourselves:

        def pass1(self, program):
            """Returns an un-optimized AST"""
            tokens = self.tokenize(program)
            pass
            
        def pass1(self, ast):
            """Returns an AST with constant expressions reduced"""
            pass
    
        def pass3(self, ast):
            """Returns assembly instructions"""
            pass
    

    VoilĂ , just a small detail to fix.

  • Custom User Avatar

    Generators are fun :)

  • Custom User Avatar

    It's a highly readable code.

    Also, it's efficient since it passes the tests in a reasonable time.

    Efficiency is always relative. Let's say you have a cog in your system that has a big complexity, but this cog only takes .1% of your runtime, then don't optimize this cog yet and focus on the ones taking way more. Again, Efficiency is always relative.

  • Custom User Avatar

    You can directly return "class_score < your_points", as this evaluates as a boolean already.

    If it's true, you return true. If it's false, you return false. Thus, return it directly:

    return class_score < your_points

  • Custom User Avatar

    Agreed, it's solved. Thanks.

  • Custom User Avatar

    NameError: name 'randint' is not defined

    When running the random test cases...

    The random.randint import seems missing from the testing file.