You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def midsize_file(fnames):
"""Select the median-size file from several given filenames.
If an even number of files is given, selects the file just below the median.
"""
return sorted(fnames, key=lambda f: os.stat(f).st_size
)[len(fnames) // 2 - 1]
Consider 8 files. The median should be the 4th file in this case (median is between 4/5), or list index 3. This is correctly calculated
8 // 2 = 4
4 - 1 = 3
Consider 7 files. The median should be the 4th file, or list index 3. This is incorrectly calculated as index 2, the value just below the median
7 // 2 = 3
3 - 1 = 2
The text was updated successfully, but these errors were encountered:
From autobin.py:
The text was updated successfully, but these errors were encountered: