On the Subject of Factory Keypad

How can a measly keypad detonate a bomb just by itself?!...

Determine the code by following the steps below, then submit it into the module.

  1. Start with the year the bomb was started on.
  2. If there are no batteries, reverse the digits of the code.
    Otherwise, replace the first digit of the code with the number of batteries (you may replace the first digit of the code with multiple digits in case the bomb has 10+ batteries, e.g. 2026 → 10026).
  3. If there are no indicators, +1597.
    Otherwise, for every indicator on the bomb (in any order)*:
    • If it is lit, and its label is:
      • BOB, CAR, CLR, FRK, FRQ, IND, or MSA, +903.
      • NSA or SIG, +2532.
      • NLL, SND, or TRN, +1111.
    • If it is unlit, and its label is:
      • CAR, CLR, FRQ, or TRN, -309.
      • FRK, -2618.
      • BOB, IND, MSA, NLL, NSA, SIG, or SND, -555.
    * Refer to the original manual for modded indicators.
  4. If the code is now negative, remove the negative sign.
    Take the code modulo 10000.
  5. For every vanilla port on the bomb in alphabetical order (if there are any; including duplicate ports), apply its modification from the table below.
DVI-D -4229; +10000 if it becomes negative.
Parallel +25, then *1.5 (ignore decimals).
PS/2 Add 2 to each digit, disregarding any carry digits.
RJ-45 +90.
Serial /3 (ignore decimals).
Stereo RCA *2.
  1. Take the code modulo 10000.
  2. +([first digit of the S#] * 1000 + [last digit of the S#]).
  3. Take the code modulo 10000, and prepend zeroes until the code is four digits long (if necessary).
  1. If the S# has:
    • 4 letters, +[sum of their alphabetic positions].
    • 3 letters, move the first two digits of the code after the last two digits.
    • 2 letters, -([absolute difference of the two letter’s alphabetic positions] * 10).
      If the code is now negative, remove the negative sign.
    • <2/>4 letters, take the last three digits of the code, and add a 0 at the end.
  2. If the serial number contains both an “A” and a “9”, +219.
  3. Take the code modulo 10000. If it is now less than 1000, +9000.
    This is the code that should be submitted.