apple / apple/swift-algorithms

Improve performance of `count` on `Combinations`

Open
#58 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
6.3k
Forks
483
PR merge metrics
No merged PRs in 30d

Description

The implementation of the `counts` property on `Combinations` can be optimized to make use of the fact that the binomial is symmetrical around N/2 or (N - 1)/2.

More details available in [this review comment](https://github.com/apple/swift-algorithms/pull/51#discussion_r552056051) on https://github.com/apple/swift-algorithms/pull/51.

Contributor guide

Open the contributing guide

Research direction

Read the Combinations implementation, focusing on the counts property, and review the linked discussion on pull request #51 for the optimization context. Use the binomial symmetry described in the issue, then verify that count results remain correct while the implementation performs less work.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.