Skip to content

Instantly share code, notes, and snippets.

@itkr
Last active March 21, 2019 07:17
Show Gist options
  • Save itkr/6b3180d6ee893120629e54df417ead85 to your computer and use it in GitHub Desktop.
Save itkr/6b3180d6ee893120629e54df417ead85 to your computer and use it in GitHub Desktop.
リストを均等に分ける
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