# Python Conundrum 3: A Dwarven Vault

While exploring an abandoned dwarven fortress, your party notices a faint glow on the wall. You put your torch on the wall and decide to look around:

A massive stone door! You cast a light spell to see what is the source of the glow:

4 keyholes and spherically cut gems above them. This must be a vault...

Beside the door there is something lying of the floor:

It all comes together! It seems that dwarves left the blank keys and instructions to make real keys right here in case they lose the them.

You pick up the parchment and turn it around to see this:

You make an impression of a blank key:

Now to figure out how to open the vault... At least, you hope it's a vault...

You try to insert the blank keys into all the locks and turn them, but only hear low reverberating grunts from somewhere inside the door.

That settles it. Your party needs to make keys from blanks using instructions from the parchment. You're lucky to have tools for repairing your gear with you!

The locks can be simulated with this python script:

red = ???
green = ????
blue = ????
magenta = ????

k = (red ** 2) * (green // 3 + blue) * ((blue // red) ** 2) * ((magenta - red + blue) * green) ** 2

keys = [0, 0, 0, 0]

keys[0] = 105079211 * k + 429583651070330754562479
keys[1] = 105079211 * k + 429583651070459754562279
keys[2] = 105 * k + 55275601784725866755974
keys[3] = 1198857906809595092 * k + 21051966546772674650874

for i in range(len(keys)):
key = str(keys[i])
for n in range(len(key)):
if n % 2 == 0:
char = key[:2]
key = key[2:]
print(chr(int(char)), end='')
print()



The black dots in the image given represent prime numbers, reading in the top row of 64 (which starts with 2, 3, and 5), then the next row (whose first prime is 67), and so on.

The positions of the colored pixels, which are also prime, are:

red = 719
green = 1423
blue = 2237
magenta = 3709


Plugging these values into the Python code given produces a message:

I AM YOUR FRIEND