Ejemplo n.º 1
0
from finders import find_floor
from finders import at_basement_in

try:
    with open(input("Santa,"
                " put here the way of your your instructions archive;"
                "\n If you are trying to open instructions_for_santa.txt,"
                " just press enter. >>> ")) as archive:
        instructions = archive.read()
        print('The floor is: {}'.format(find_floor(instructions)))
        print('The position of the first ")" character is: {}'.format(at_basement_in(instructions)))

except:
    print('I will show the result of instructions_for_santa.txt, above:')
    with open('../adventofcode/day_1/instructions_for_santa.txt') as archive:
        instructions = archive.read()
        print('The floor is: {}'.format(find_floor(instructions)))
        print('The position of the first ")" character is: {}'.format(at_basement_in(instructions)))
Ejemplo n.º 2
0
 def test_return_7_when_3up_50down(self):
     self.assertEqual(at_basement_in('((())))))))))))))))))))))))))))))))))))))))))))))))))'), 7)
Ejemplo n.º 3
0
 def test_return_3_when_1up_2down (self):
     self.assertEqual(at_basement_in('())'), 3)
Ejemplo n.º 4
0
 def test_return_1_when_1down (self):
     self.assertEqual(at_basement_in(')'), 1)