コード例 #1
0
ファイル: day_1.py プロジェクト: EullerLisowski/adventofcode
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)))
コード例 #2
0
 def test_return_7_when_3up_50down(self):
     self.assertEqual(at_basement_in('((())))))))))))))))))))))))))))))))))))))))))))))))))'), 7)
コード例 #3
0
 def test_return_3_when_1up_2down (self):
     self.assertEqual(at_basement_in('())'), 3)
コード例 #4
0
 def test_return_1_when_1down (self):
     self.assertEqual(at_basement_in(')'), 1)