The Quiz

You have these numbers at your disposal:

1, 3, 5, 7, 9, 11, 13, 15

use them, with repetition, to make the following expression evaluate to true:

__ + __ + __ + __ + __ = 30

Solution

What I naturally did was:

def all_combos(arr, result):
    """"""

    if len(result) == 5:
        if sum(result) == 30:
            print result
    else :
        for x in arr:
            new_result = result[:]
            new_result.append(x)

            all_combos(arr, new_result)


available_numbers = range(1, 16)[::2]

all_combos(available_numbers, [])

Which gave no solutions at all…

So I raged at the person who gave the question, and they replied:

Dude, there is no way you can add odd numbers an odd number of times, and get an even number. That’s the real solution.

image

Conclusion

Ever heard of the “Helicopter Approach”? Well, you should read about it.