import sys import math STATION_ICON_SIZE = 90 PILE_ICON_SIZE = 40 PILE_X_OFFSET = 200 ROW_RATE = 3 COL_RATE = 10 def matrix(n): if n < (ROW_RATE * COL_RATE): r = math.ceil(n / COL_RATE) else: r = math.floor(ROW_RATE * ((n / (ROW_RATE * COL_RATE)) ** 0.5)) c = math.ceil(n / r) return r, c def station_pos(r): A = (STATION_ICON_SIZE + PILE_ICON_SIZE) // 2 B = (STATION_ICON_SIZE - PILE_ICON_SIZE) // 2 return (0, (r - 1) * A - B) def pile_pos(c, n): A = STATION_ICON_SIZE + PILE_ICON_SIZE lst = [] for i in range(n): x = (i % c) * A + PILE_X_OFFSET y = (i // c) * A lst.append((x, y)) return lst def link(c, n): lst = [] for i in range(n): lst.append(((i - 1) if i % c != 0 else -1, i)) return lst def main(): if len(sys.argv) < 2: print("test.py ") return n = int(sys.argv[1]) r, c = matrix(n) print(station_pos(r)) print(pile_pos(c, n)) print(link(c, n)) if __name__ == '__main__': main()