43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# IMPORTS
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
from src.thirdparty.code import *;
|
|
from src.thirdparty.maths import *;
|
|
from src.thirdparty.types import *;
|
|
|
|
from src.models.pollard_rho import *;
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# EXPORTS
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
__all__ = [
|
|
'display_table',
|
|
];
|
|
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
# METHOD display table
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
def display_table(steps: List[Step]) -> str:
|
|
table = pd.DataFrame({
|
|
'i': [i for i in range(len(steps))],
|
|
'x': [step.x for step in steps],
|
|
'y': [step.y for step in steps],
|
|
'd': [step.d or '-' for step in steps],
|
|
}) \
|
|
.reset_index(drop=True);
|
|
# benutze pandas-Dataframe + tabulate, um schöner darzustellen:
|
|
repr = tabulate(
|
|
table,
|
|
headers=['i', 'x[i]', 'y[i] = x[2i]', 'gcd(|x - y|,n)'],
|
|
showindex=False,
|
|
colalign=('right', 'right', 'right', 'center'),
|
|
tablefmt='simple',
|
|
);
|
|
return repr;
|