Skip to content

Instantly share code, notes, and snippets.

@albertnetymk
Created December 9, 2017 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albertnetymk/64ee2ef160010fff73b028865e022507 to your computer and use it in GitHub Desktop.
Save albertnetymk/64ee2ef160010fff73b028865e022507 to your computer and use it in GitHub Desktop.

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