{"id":16575255,"url":"https://github.com/kolosovpetro/knapsackproblem","last_synced_at":"2026-04-24T03:33:06.550Z","repository":{"id":116314835,"uuid":"457100436","full_name":"kolosovpetro/KnapsackProblem","owner":"kolosovpetro","description":"Study on the Knapsack problem","archived":false,"fork":false,"pushed_at":"2022-10-31T09:16:22.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T18:35:32.385Z","etag":null,"topics":["dynamic-programming","knapsack-problem","knapsack-solver"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kolosovpetro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-08T20:55:06.000Z","updated_at":"2022-02-10T03:01:25.000Z","dependencies_parsed_at":"2023-03-13T12:58:48.543Z","dependency_job_id":null,"html_url":"https://github.com/kolosovpetro/KnapsackProblem","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kolosovpetro/KnapsackProblem","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolosovpetro%2FKnapsackProblem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolosovpetro%2FKnapsackProblem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolosovpetro%2FKnapsackProblem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolosovpetro%2FKnapsackProblem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kolosovpetro","download_url":"https://codeload.github.com/kolosovpetro/KnapsackProblem/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kolosovpetro%2FKnapsackProblem/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32208320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T03:15:14.334Z","status":"ssl_error","status_checked_at":"2026-04-24T03:15:11.608Z","response_time":64,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic-programming","knapsack-problem","knapsack-solver"],"created_at":"2024-10-11T21:47:26.086Z","updated_at":"2026-04-24T03:33:01.541Z","avatar_url":"https://github.com/kolosovpetro.png","language":"C#","readme":"# KnapsackProblem\n\nGiven an array P of products\n\n- { Title = \"Radio\", Price = 3000, Weight = 4 },\n- { Title = \"Laptop\", Price = 2000, Weight = 3 },\n- { Title = \"Guitar\", Price = 1500, Weight = 1 }\n\nGiven a knapsack of positive integer capacity N. Find a combination of products such that price is maximal and does not\nexceed the size of knapsack.\n\n## Cases\n\n- N = 4. Output: [Laptop, Guitar]\n- N = 5. Output: [Laptop, Guitar, Guitar]\n\n## Pseudocode\n\n- Initialize jagged array `int[K][N]` where `K` -- count of products, `N` -- is knapsack capacity\n- Sort array of products by the `Weight`\n- For each product:\n    - If current weight is lesser then product weight: add previous product weight\n    - Else add MAX(previous weight, current product weight + remaining weight maximum)\n\n## Example\n![img.png](img.png)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolosovpetro%2Fknapsackproblem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkolosovpetro%2Fknapsackproblem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkolosovpetro%2Fknapsackproblem/lists"}