grep!$s{$_}&!($s&8&&~$s&$_&7)&!(~$s&8&&$s&~$_&7)&&($z=$s^$_)&8&&(($z&=7)<3|$z==4),15,grep$_%3,1..14
####
0-8 11-1 7-15
\ / \ /
10-2 13-5
\ /
14-4
##
##
grep
!$s{$_} # we have not been at $_ already
&!($s&8 # prohibit the boat is on the right bank initially
&&~$s&$_&7) # and a move from left to right
&!(~$s&8 # prohibit the boat is on the left bank initially
&&$s&~$_&7) # and a move from right to left
&&($z=$s^$_)&8 # the boat moves
&&(($z&=7)<3|$z==4), # with at most one passenger
15,grep$_%3,1..14 # possible choices for moves