# 세이브 더 월드

파이썬 너무 좋아 파이썬에 밥말아먹고 파이썬으로 샤워해야지
unknown
python
a year ago
1.8 kB
10
Indexable
Never
```from __future__ import annotations

import random
from contextlib import nullcontext
from typing import TextIO

def gen_small(
n: int, seed: int | None = None, file: str | TextIO | None = None
) -> list[tuple[int, int]]:
random.seed(seed)
points = [
(i, j) for i in range(-15, 16) for j in range(-15, 16) if (i, j) != (0, 0)
]
random.shuffle(points)
chosen = points[:n]
out = (
open(file, "w", encoding="utf-8")
if isinstance(file, str)
else nullcontext(file)
)
with out as f:
print(n, file=f)
for x, y in chosen:
print(x, y, file=f)
return chosen

def gen_large(
n: int, seed: int | None = None, file: str | TextIO | None = None
) -> list[tuple[int, int]]:
random.seed(seed)
points = set()

while len(points) < n:
x = random.randint(-1000, 1000)
y = random.randint(-1000, 1000)
if (x, y) == (0, 0):
continue

out = (
open(file, "w", encoding="utf-8")
if isinstance(file, str)
else nullcontext(file)
)
with out as f:
print(n, file=f)
for x, y in points:
print(x, y, file=f)
return list(points)

if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser()