On the Subject of Factory Keypad

Did this somehow end up from one of the doors in the factory to one of its explosive creations?

This module has a keypad containing ten digits, a submit button, and a clear button. The correct code must be entered to solve the module. If an incorrect code is submitted, the module will strike. For safety reasons, if an incorrect code is entered for the third time, the bomb will detonate.

The code will always have four digits. To find the code, follow the steps below. Start with the year the bomb was started on. Replace the first digit with the number of batteries on the bomb. However, if there are no batteries, instead reverse the digits of this number.

Next, consider every indicator on the bomb.

  • If the indicator is lit, follow the rules under this bullet point.
    • If the first letter of its label comes before N in the alphabet, add 903 to the current code.
    • Otherwise, if its label contains a vowel (including Y), add 2532 to the current code.
    • Otherwise, add 1111 to the current code.
  • If the indicator is unlit, follow these rules instead.
    • If the last letter of its label comes after M in the alphabet, subtract 309 from the current code.
    • Otherwise, if its label contains the letter R, subtract 2618 from the current code.
    • Otherwise, subtract 555 from the current code.

If there are no indicators on the bomb, add 1597 to the code.
If the code is negative so far, remove the negative sign. If it has more than four digits, subtract 10000 until it is less than 10000.

Then, use each port on the bomb in alphabetical order to modify the code further. If there are ports that are not in the table below, ignore them.

DVI-D Subtract 4229 from the code, adding 10000 if it becomes negative.
Parallel Add 25 to the code, then multiply it by 1.5, ignoring decimals.
PS/2 Add 2 to each digit, disregarding any carry digits.
RJ-45 Add 90 to the code.
Serial Divide the code by 3, removing any decimals if necessary.
Stereo RCA Multiply the code by 2.

By this point, if the code has more than four digits, subtract 10000 until it is less than 10000.

Finally, use the serial number to obtain the final code.
Add the first digit of the serial number multiplied by 1000 to the code, and add the last digit of the serial number. Take the last four digits, prepending zeros if necessary.

  • If the serial number has four letters, take each letter’s alphabetic position (A=1, Z=26), and add it to the code.
  • Otherwise, if the serial number has three letters, move the first two digits of the code after the last two digits.
  • Otherwise, if the serial number has two letters, take the absolute difference between their alphabetic positions (A=1, Z=26), multiply it by 10, and subtract this number from the code. Take the absolute value if the resulting number is negative.
  • Otherwise, take the last three digits of the code, and add a 0 at the end.

If the serial number contains an “A” and a “9”, add 219 to the code.
Once all modifications are done, take the last four digits of the code. If this result is less than 1000, add 9000 to the code. Input this number into the keypad, and press the submit button.

WARNING

From the employees at the KTANE factory

The reset code for the module is 0000. We do not know what happens when entering this code, but please do not try entering this code as this may harm the production of modules in the factory. Anyone unauthorized who enters this code will face negative consequences.