old_contents: """
  --- Day 2: Bathroom Security ---
  
  You arrive at Easter Bunny Headquarters under cover of darkness. However, you
  left in such a rush that you forgot to use the bathroom! Fancy office buildings
  like this one usually have keypad locks on their bathrooms, so you search the
  front desk for the code.
  
  "In order to improve security," the document you find says, "bathroom codes will
  no longer be written down. Instead, please memorize and follow the procedure
  below to access the bathrooms."
  
  The document goes on to explain that each button to be pressed can be found by
  starting on the previous button and moving to adjacent buttons on the keypad: U
  moves up, D moves down, L moves left, and R moves right. Each line of
  instructions corresponds to one button, starting at the previous button (or, for
  the first line, the "5" button); press whatever button you're on at the end of
  each line. If a move doesn't lead to a button, ignore it.
  
  You can't hold it much longer, so you decide to figure out the code as you walk
  to the bathroom. You picture a keypad like this:
  
  1 2 3 4 5 6 7 8 9 Suppose your instructions are:
  
  ULL RRDDD LURDL UUUUD You start at "5" and move up (to "2"), left (to "1"), and
  left (you can't, and stay on "1"), so the first button is 1. Starting from the
  previous button ("1"), you move right twice (to "3") and then down three times
  (stopping at "9" after two moves and ignoring the third), ending up with 9.
  Continuing from "9", you move left, up, right, down, and left, ending with 8.
  Finally, you move up four times (stopping at "2"), then down once, ending with
  5. So, in this example, the bathroom code is 1985.
  
  Your puzzle input is the instructions from the document you found at the front
  desk. What is the bathroom code?
  """
  
  
  class numPad:
  
      def __init__(self, key):
          self.key = key
  
  
      def getKeyAfterMove(self, move):
          if move == 'U' and self.key > 3:
              self.key = self.key - 3
  
          elif move == 'D' and self.key < 7:
              self.key = self.key + 3
  
          elif move == 'L':
              if self.key != 1 and self.key != 4 and self.key != 7:
                  self.key = self.key - 1
  
          elif move == 'R':
              if self.key != 3 and self.key != 6 and self.key != 9:
                  self.key = self.key + 1
  
          return self.key
  
  
      def currentKey(self):
          return self.key
  
  
  def get_number_sequence(filename):
      with open(filename) as f:
          lines = f.readlines()
  
      n = numPad(5)
  
      numSequence = []
  
      for line in lines:
          numToAdd = 0
          for char in line:
              numToAdd = n.getKeyAfterMove(char)
          numSequence.append(numToAdd)
  
      return numSequence
  
  
  if __name__ == '__main__':
      print get_number_sequence("probleminput.txt")
  
new_contents: """
  --- Day 2: Bathroom Security ---
  
  You arrive at Easter Bunny Headquarters under cover of darkness. However, you
  left in such a rush that you forgot to use the bathroom! Fancy office buildings
  like this one usually have keypad locks on their bathrooms, so you search the
  front desk for the code.
  
  "In order to improve security," the document you find says, "bathroom codes will
  no longer be written down. Instead, please memorize and follow the procedure
  below to access the bathrooms."
  
  The document goes on to explain that each button to be pressed can be found by
  starting on the previous button and moving to adjacent buttons on the keypad: U
  moves up, D moves down, L moves left, and R moves right. Each line of
  instructions corresponds to one button, starting at the previous button (or, for
  the first line, the "5" button); press whatever button you're on at the end of
  each line. If a move doesn't lead to a button, ignore it.
  
  You can't hold it much longer, so you decide to figure out the code as you walk
  to the bathroom. You picture a keypad like this:
  
  1 2 3 4 5 6 7 8 9 Suppose your instructions are:
  
  ULL RRDDD LURDL UUUUD You start at "5" and move up (to "2"), left (to "1"), and
  left (you can't, and stay on "1"), so the first button is 1. Starting from the
  previous button ("1"), you move right twice (to "3") and then down three times
  (stopping at "9" after two moves and ignoring the third), ending up with 9.
  Continuing from "9", you move left, up, right, down, and left, ending with 8.
  Finally, you move up four times (stopping at "2"), then down once, ending with
  5. So, in this example, the bathroom code is 1985.
  
  Your puzzle input is the instructions from the document you found at the front
  desk. What is the bathroom code?
  """
  
  
  class NumPad:
      def __init__(self, key):
          self.key = key
  
      def get_key_after_move(self, move):
          if move == 'U' and self.key > 3:
              self.key -= 3
  
          elif move == 'D' and self.key < 7:
              self.key += 3
  
          elif move == 'L':
              if self.key != 1 and self.key != 4 and self.key != 7:
                  self.key -= 1
  
          elif move == 'R':
              if self.key != 3 and self.key != 6 and self.key != 9:
                  self.key += 1
  
          return self.key
  
      def current_key(self):
          return self.key
  
  
  def get_number_sequence(filename):
      with open(filename) as f:
          lines = f.readlines()
  
      n = NumPad(5)
  
      num_sequence = []
  
      for line in lines:
          num_to_add = 0
          for char in line:
              num_to_add = n.get_key_after_move(char)
          num_sequence.append(num_to_add)
  
      return num_sequence
  
  
  if __name__ == '__main__':
      print get_number_sequence("probleminput.txt")
  
subject: Update - lint day2 part1