def test_return_0_when_2up_2down(self):
     self.assertEqual(find_floor('(())'), 0)
示例#2
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)))
 def test_return_minus3_when_3down(self):
     self.assertEqual(find_floor(')))'), -3)
 def test_return_minus3_1down_1up_2down_1up_2down(self):
     self.assertEqual(find_floor(')())())'), -3)
 def test_return_minus1_when_2down_1up(self):
     self.assertEqual(find_floor('))('), -1)
 def test_return_3_when_2down_5up(self):
     self.assertEqual(find_floor('))((((('), 3)
 def test_return_3_when_2up_1down_2up_1down_1up(self):
     self.assertEqual(find_floor('(()(()('), 3)
 def test_return_3_when_3_up(self):
     self.assertEqual(find_floor('((('), 3)
 def test_return_0_when_1up_1down_1up_1down(self):
     self.assertEqual(find_floor('()()'), 0)