Skip to content

Commit

Permalink
Improved docstring for equal_sum_subsets
Browse files Browse the repository at this point in the history
  • Loading branch information
PGS62 committed Feb 15, 2024
1 parent cbd4360 commit 46f7a66
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/corkendall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -418,20 +418,20 @@ end
"""
equal_sum_subsets(n::Int, num_subsets::Int)::Vector{Vector{Int}}
Divide the integers 1:n into a number of subsets such that the sum of the elements in each
subset is nearly equal.
Divide the integers 1:n into a number of subsets such that a) each subset has (approximately)
the same number of elements; and b) the sum of the elements in each subset is nearly equal.
If `n` is a multiple of `2 * num_subsets` both conditions hold exactly.
## Example
```jldoctest
```julia-repl
julia> KendallTau.equal_sum_subsets(30,5)
5-element Vector{Vector{Int64}}:
[30, 21, 20, 11, 10, 1]
[29, 22, 19, 12, 9, 2]
[28, 23, 18, 13, 8, 3]
[27, 24, 17, 14, 7, 4]
[26, 25, 16, 15, 6, 5]
```
```
"""
function equal_sum_subsets(n::Int, num_subsets::Int)#::Vector{Vector{Int}}
subsets = [Int[] for _ in 1:num_subsets]
Expand All @@ -448,5 +448,4 @@ function equal_sum_subsets(n::Int, num_subsets::Int)#::Vector{Vector{Int}}
end
filter!(x -> length(x) > 0, subsets)
return (subsets)
end

end

0 comments on commit 46f7a66

Please sign in to comment.