Last active
March 21, 2019 07:17
-
-
Save itkr/6b3180d6ee893120629e54df417ead85 to your computer and use it in GitHub Desktop.
リストを均等に分ける
This file contains 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 math | |
from typing import List | |
def split_list(_list, n) -> List[list]: | |
"""リストを均等に分ける""" | |
sp = [0] + [math.ceil(len(_list) / n * (i + 1)) for i in range(n)] | |
return [_list[sp[i]: sp[i + 1]] for i in range(n)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment