Skip to content

greedy_001 adds sets for which all the items are already covered #11

@yuvalregev1003

Description

@yuvalregev1003

@ccoffrin greedy_001 solution (possibly others too, haven't looked into them yet) keeps adding sets until getting full coverage. However - some sets are added for which their items are already covered by previously added sets, thus adding cost but without any value gain.
By adding the following inside the main loop: (tested in 3.10, not in earlier Python versions)

        if len(set(s.items).intersection(covered)) == len(set(s.items)):
            continue

this can be avoided

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions