5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ある行数のファイルを均等に分割する場合の分け方を求める

Posted at

行数がわかっているファイルを指定した数で分割する場合、どのように分割するかを求める。

py
total=100 # 総行数
div = 7 #分割数

div_list = [ (total//div) + (1 if x <(total%div) else 0)  for x in range(div)]
# div_list = [15, 15, 14, 14, 14, 14, 14]

上記の例だと、100行あるファイルを7つに分割すると、
15行のファイル2つと14行のファイル5つに分割すれば良い。

5
5
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?