weezy20 / subset_sum Goto Github PK
View Code? Open in Web Editor NEWGreedy algorithm for finding natural numbers that square and sum to N - squared The problem is the following: Given a number N, find all sets of natural numbers that is 1..N such that squaring & summing them up results to N. I found that this problem doesn't have an exact algorithm and is similar to the knapsack problem. This is my implementation of a greedy algorithm to find various combinations.