Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Find the max and min of sum of all permutations of [1..9] satisfying the following condition:

    sum
    == a[1] + a[2] + a[3]
    == a[3] + a[4] + a[5]
    == a[5] + a[6] + a[7]
    == a[7] + a[8]
    where sum = a[0] + a[1]

A permutation satisfying that condition is a = [9,4,1,8,3,2,5,6,7], and sum is 13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment