Last active
November 3, 2023 08:50
-
-
Save dongkwan-kim/1ae87589a62efeef774c81ff2c35ed42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
T = 596 | |
R, C = 37, 16 | |
numbers = list(range(1, T + 1)) | |
random.shuffle(numbers) | |
sets = [] | |
for _set in range(R): | |
i_1 = _set * C | |
i_2 = (_set + 1) * C | |
a_set = sorted(numbers[i_1:i_2]) | |
print( | |
"\t".join([str(x) for x in a_set]) | |
) | |
#### | |
import csv | |
from collections import defaultdict | |
import random | |
BOOK_TO_N = { | |
"국세기본법": 5, | |
"법인세법": 15, | |
"소득세법": 10, | |
"부가가치세법": 8, | |
"상증양": 2, | |
} | |
def chunks(xs, n): | |
n = max(1, n) | |
return list(xs[i:i + n] for i in range(0, len(xs), n)) | |
def random_chunks_to_fixed_num_chunks_and_sets(xs, num_chunks, num_sets): | |
all_chunks = [] | |
for _ in range(num_sets): | |
random.shuffle(xs) | |
ch = chunks(xs, num_chunks) | |
if len(ch[-1]) < len(ch[-2]): | |
random.shuffle(xs) | |
ch[-1] += xs[:(len(ch[-2]) - len(ch[-1]))] | |
ch = [sorted(_ch) for _ch in ch] | |
if len(all_chunks) < num_sets: | |
all_chunks += ch | |
return all_chunks[:num_sets] | |
book_to_numbers = defaultdict(list) | |
for line in csv.DictReader(open("./_객관식세법 필수문제리스트 - 시트1.csv")): | |
book_to_numbers[line["book"]].append((int(line["chapter"]), int(line["number"]))) | |
for book, numbers in book_to_numbers.items(): | |
rchfns = random_chunks_to_fixed_num_chunks_and_sets(numbers, BOOK_TO_N[book], 23) | |
for i, num_set_in_book in enumerate(rchfns): | |
print("\t".join([book, str(i)] + [f"{chapter}|{the_num}" for chapter, the_num in num_set_in_book])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment