コード例 #1
0
class KeypadTest(unittest.TestCase):
    def setUp(self):
        self.keypad = Keypad()

    # ULL
    # RRDDD
    # LURDL
    # UUUUD
    #
    # So, in this example, the bathroom code is 1985.
    def test_sample(self):
        self.assertEqual(self.keypad.executeRow('ULL'), '1')
        self.assertEqual(self.keypad.executeRow('RRDDD'), '9')
        self.assertEqual(self.keypad.executeRow('LURDL'), '8')
        self.assertEqual(self.keypad.executeRow('UUUUD'), '5')
コード例 #2
0
from keypad import Keypad

with open('../input') as handle:

    keypad = Keypad()
    code = []

    for row in handle:
        code.append(keypad.executeRow(row))

    print "Door Code:", ''.join(code)