It seems that for a given optimum set, A = {a_1, a_2, ... , a_n}, the next optimum set is of the form B = {b, a_1+b, a_2+b, ... ,a_n+b}, where b is the "middle" element on the previous row.

By applying this "rule" we would expect the optimum set for n = 6 to be A = { 11, 17, 20, 22, 23, 24 }, with S(A) = 117.
However, this is not the optimum set, as we have merely applied an algorithm to provide a near optimum set.
The optimum set for n = 6 is A = { 11, 18, 19, 20, 22, 25 }, with S(A) = 115 and corresponding set string: 111819202225.

Given that A is an optimum special sum set for n = 7, find its set string.

My Algorithm

search recursively produces all ascending sequences where all elements are between minElement and maxElement.

check returns true if the set is "special" by analyzing all subsets:
each number is either part or not part of a subset. That can be encoding by a single bit which is 0 (no) or 1 (yes).
Then there are 2^size combinations → I just run a counter named mask from 0000000 to 1111111
(actually, 0000000 represents the empty set and can be skipped).

For each sum I encounter along the way, I set a bit in sums. It must never be set twice (first rule).
Moreover, I track the lower and highest sum for each number of elements.
If the highest sum of all n-element subsets is higher than then lowest sum of (n+1)-subsets then rule 2 was violated.

All successfully verified sequences are stored in an ordered set solution and the first one is printed.

Hackerrank

Difficulty

45%
Project Euler ranks this problem at 45% (out of 100%).

Hackerrank describes this problem as easy.

Note:Hackerrank has strict execution time limits (typically 2 seconds for C++ code) and often a much wider input range than the original problem.In my opinion, Hackerrank's modified problems are usually a lot harder to solve. As a rule thumb: brute-force is rarely an option.

Those links are just an unordered selection of source code I found with a semi-automatic search script on Google/Bing/GitHub/whatever.
You will probably stumble upon better solutions when searching on your own.
Maybe not all linked resources produce the correct result and/or exceed time/memory limits.

Heatmap

Please click on a problem's number to open my solution to that problem:

green

solutions solve the original Project Euler problem and have a perfect score of 100% at Hackerrank, too

yellow

solutions score less than 100% at Hackerrank (but still solve the original problem easily)

gray

problems are already solved but I haven't published my solution yet

blue

solutions are relevant for Project Euler only: there wasn't a Hackerrank version of it (at the time I solved it) or it differed too much

orange

problems are solved but exceed the time limit of one minute or the memory limit of 256 MByte

red

problems are not solved yet but I wrote a simulation to approximate the result or verified at least the given example - usually I sketched a few ideas, too

black

problems are solved but access to the solution is blocked for a few days until the next problem is published

[new]

the flashing problem is the one I solved most recently

I stopped working on Project Euler problems around the time they released 617.

The 310 solved problems (that's level 12) had an average difficulty of 32.6&percnt; at Project Euler and
I scored 13526 points (out of 15700 possible points, top rank was 17 out of &approx;60000 in August 2017)
at Hackerrank's Project Euler+.

My username at Project Euler is stephanbrumme while it's stbrumme at Hackerrank.

Copyright

I hope you enjoy my code and learn something - or give me feedback how I can improve my solutions.All of my solutions can be used for any purpose and I am in no way liable for any damages caused.You can even remove my name and claim it's yours. But then you shall burn in hell.

The problems and most of the problems' images were created by Project Euler.Thanks for all their endless effort !!!

more about me can be found on my homepage,
especially in my coding blog.
some names mentioned on this site may be trademarks of their respective owners.
thanks to the KaTeX team for their great typesetting library !