Precisely 7 boards are arranged in a straight line. Their colors are:
blue, brown, green, orange, purple, red, and yellow - albeit not necessarily in that order.
It is known that:
- Red is next to blue.
- Purple is somewhere to the left of green.
- There is precisely one board between yellow and red.
- There are exactly two boards between brown and blue.
- Blue is the 4th board from the left.
- Orange is directly between yellow and purple.
Determine the precise order of these seven boards.
boards=["bl" "br" "gr" "or" "pu" "re" "ye"];
boards=perms(boards);
for i=1:length(boards)
board=boards(i,:);
red=find(board=="re");
blue=find(board=="bl");
if abs(red-blue)==1
purple=find(board=="pu");
green=find(board=="gr");
if purple<green
yellow=find(board=="ye");
if abs(yellow-red) == 2
brown=find(board=="br");
if abs(brown-blue)==3
if blue==4
orange=find(board=="or");
if abs(orange-yellow)==1 && abs(orange-purple)==1
board
end
end
end
end
end
end
end
finds
board =
1×7 string array
"pu" "or" "ye" "bl" "re" "gr" "br"
as the sequence of boards' colors.
Edited on September 13, 2022, 9:33 am
|
Posted by Charlie
on 2022-09-13 09:31:32 |