Ejemplo n.º 1
0
 def from_json_str(cls, json_str: str, instruction_set: InstructionSet):
     """Create a PushSolution from a JSON string."""
     solution_dict = json.loads(json_str)
     return cls(
         CodeBlock.from_json_str(
             json.dumps(solution_dict["program"], separators=(',', ':')),
             instruction_set), solution_dict["output_types"])
Ejemplo n.º 2
0
 def from_json_str(cls, json_str: str, instruction_set: InstructionSet):
     """Create a PushSolution from a JSON string."""
     solution_dict = json.loads(json_str)
     return cls(
         CodeBlock.from_json_str(
             json.dumps(solution_dict["program"], separators=(',', ':')),
             instruction_set
         ),
         solution_dict["output_types"]
     )
Ejemplo n.º 3
0
def load_program(name: str) -> CodeBlock:
    with open("tests/resources/programs/" + name + ".json") as f:
        return CodeBlock.from_json_str(f.read(), i_set)
Ejemplo n.º 4
0
def load_program(name, interpreter) -> CodeBlock:
    with open("tests/resources/programs/" + name + ".json") as f:
        return CodeBlock.from_json_str(f.read(), interpreter.instruction_set)