Beispiel #1
0
# Grab the cube implementation from the Cube.py file
from Cube import Cube

# Variables
data = []
instruction = []
inputFile = "../input/input_9.txt"

# Open up the input file and read in the cube values
with open(inputFile) as textFile:
    for line in textFile:
        for face in line.split():
            # Add the values to the cube data
            data.append(face)

# Create a cube object from the input data
cube = Cube(data, instruction)

# Move on to solve and print the cube ... if the input was valid
if cube.check_inputs():
    # Input was determined to be valid
    if cube.solve_cube():
        cube.print_val()
        cube.print_turns()
    else:
        print("Error: correct input, but unable to solve.")
else:
    # Input was determined to be invalid
    print("Input was determined to be invalid")
Beispiel #2
0
    data = []
    instruction = []
    print(" " * 4, '{:25s}'.format(file), " " * 15, end="")
    with open(file) as textFile:
        for line in textFile:
            for face in line.split():
                # Add the values to the cube data
                data.append(face)

    # Create a cube object from the input data
    cube = Cube(data, instruction)

    # Move on to solve and print the cube ... if the input was valid
    if cube.check_inputs():
        # Input was determined to be valid
        returnValue = cube.solve_cube()
        if returnValue == 1:
            print("PASS")
            numPass = numPass + 1

        elif returnValue == 2:
            print("FAIL - can't solve white side")

        elif returnValue == 3:
            print("FAIL - can't solve middle layer")

        elif returnValue == 4:
            # This file is supposed to fail. So, if it catches it, PASS
            if file == "../input/input_bad_1.txt":
                print("PASS")
                numPass = numPass + 1