Skip to main content
added 182 characters in body
Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

Nibbles, 7 bytes (14 nibbles)

/|``p$/!>>$@!*

Systematically (non-randomly) finds all permutations of the input without adjacent identical nuts, and then returns the first of these (or an empty list if there aren't any).

/|``p$/!>>$@!*
 |               # filter
  ``p            # all permutations of 
     $           # the input list
                 # by 
      /      *   # fold-by-multiplication
       !         #   zip together
        >>$      #     list without first element
           @     #     the same list
            !    #     are elements equal?
/                # finally get first element

enter image description here

Nibbles, 7 bytes (14 nibbles)

/|``p$/!>>$@!*
/|``p$/!>>$@!*
 |               # filter
  ``p            # all permutations of 
     $           # the input list
                 # by 
      /      *   # fold-by-multiplication
       !         #   zip together
        >>$      #     list without first element
           @     #     the same list
            !    #     are elements equal?
/                # finally get first element

enter image description here

Nibbles, 7 bytes (14 nibbles)

/|``p$/!>>$@!*

Systematically (non-randomly) finds all permutations of the input without adjacent identical nuts, and then returns the first of these (or an empty list if there aren't any).

/|``p$/!>>$@!*
 |               # filter
  ``p            # all permutations of 
     $           # the input list
                 # by 
      /      *   # fold-by-multiplication
       !         #   zip together
        >>$      #     list without first element
           @     #     the same list
            !    #     are elements equal?
/                # finally get first element

enter image description here

Source Link
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

Nibbles, 7 bytes (14 nibbles)

/|``p$/!>>$@!*
/|``p$/!>>$@!*
 |               # filter
  ``p            # all permutations of 
     $           # the input list
                 # by 
      /      *   # fold-by-multiplication
       !         #   zip together
        >>$      #     list without first element
           @     #     the same list
            !    #     are elements equal?
/                # finally get first element

enter image description here