#!/usr/local/bin/python3
# Python Challenge - 32
# http://www.pythonchallenge.com/pc/rock/arecibo.html
# http://www.pythonchallenge.com/pc/rock/warmup.txt
# http://www.pythonchallenge.com/pc/rock/up.html
# http://www.pythonchallenge.com/pc/rock/up.txt
# Username: kohsamui; Password: thailand
# Keyword: up,


def main():
    '''
    Hint: etch-a-sketch
    fill in the blanks
    for warmup.txt
    '''
    warmup_path = './etchasketch_chall_32/warmup.txt'
    EtchASketch(warmup_path)
    return 0


class EtchASketch(object):
    """
    Takes a filepath to a text file containing the parameters of the board.
        Board must have x by y dimensions on one line, separated by a space
        Horizontal params one per line, each number separated by a space
        Vertical params one per line, each number separated by a space
        Finds a solution where tiles are filled and grouped per h and v params
    """

    dim_x = 0
    dim_y = 0
    horiz = []
    vert = []

    def __init__(self, path):
        self.path = path
        self.get_params(path)

    def get_params(self, path):
        with open(path, 'r') as params:
            for line in params.readlines():
                if line.startswith('\n'):
                    continue
                if line.startswith('# Dimensions'):
                    d_flag, h_flag, v_flag = True, False, False
                    continue
                elif line.startswith('# Horizontal'):
                    d_flag, h_flag, v_flag = False, True, False
                    continue
                elif line.startswith('# Vertical'):
                    d_flag, h_flag, v_flag = False, False, True
                    continue

                # Line isn't newline or comment (contains numbers)
                nums = tuple([int(n) for n in line.split(' ')])
                if d_flag:
                    self.dim_x, self.dim_y = nums

                elif h_flag:
                    self.horiz.append(nums)

                elif v_flag:
                    self.vert.append(nums)

            print('Dimensions: {} x {}'.format(self.dim_x, self.dim_y))
            print('Horizontals:')
            for h in self.horiz:
                print(h)
            print('Verticals:')
            for v in self.vert:
                print(v)


if __name__ == '__main__':
    main()

@@ -388,17 +388,137 @@
 rmup.txt
+ -%3E dimensions and parameters for a 9x9 challenge%0A    Solve that, see arrow pointing up%0A    up.html -%3E 32 x 32 challenge
 %0A
-
     '''%0A
@@ -600,16 +600,17 @@
 p_path)%0A
+%0A
     retu
@@ -1039,21 +1039,20 @@
 %22%22%0A%0A    
-dim_x
+rows
  = 0%0A   
@@ -1052,21 +1052,20 @@
 = 0%0A    
-dim_y
+cols
  = 0%0A   
@@ -1089,16 +1089,61 @@
 ert = %5B%5D
+%0A    board = %5B%5BNone%5D * self.cols%5D * self.rows
 %0A%0A    de
@@ -2030,33 +2030,31 @@
    self.
-dim_x
+rows
 , self.
-dim_y
+cols
  = nums%0A
@@ -2429,16 +2429,16 @@
 f.vert:%0A
-
         
@@ -2455,16 +2455,64 @@
 int(v)%0A%0A
+        def show_board(self):%0A            pass%0A%0A
 %0Aif __na

Test class functions