Puzzles/No Average Spanned

From J Wiki
Jump to navigation Jump to search

Puzzle posed and solved by Boyko Bantchev in the J programming forum on 2005-11-29.

Arrange a list of distinct positive integers so that no two numbers have their average between them in the sequence. For example, 6 2 10 8 5 is a correct ordering while 6 2 10 5 8 is not, since 5=-:+/2 8 and 5 is placed between 2 and 8 .

Solutions below.


































Solutions

/:~&.(|."1@#:)
/: |."1@#: