Untitled
unknown
plain_text
2 years ago
769 B
13
Indexable
class Machine:
MUL = 252533
DIV = 33554393 # %
START = 20151125
def __init__(self):
self.max_row = 1
def get_nex_coord(self, x, y):
if y == 1:
self.max_row += 1
y = self.max_row
x = 1
else:
x += 1
y -= 1
return x, y
def get_next_code(self, x, y, previous):
x, y = self.get_nex_coord(x, y)
next_value = (previous * self.MUL) % self.DIV
return x, y, next_value
def get(self, column, row):
x = 1
y = 1
code = self.START
while (x, y) != (column, row):
x, y, code = self.get_next_code(x, y, code)
return code
m1 = Machine()
print(m1.get(3029, 2947))Editor is loading...
Leave a Comment