1. the five pens

A computer nerd likes to keep five pens in his shirt pocket.
the pens are of five different colors and their caps,seen below,are of the same five colors but not a single cap is correctly situated on its color pen!
given the visible arrangement below and the following clues,can you determine the order of each colored pen?
first pen is red,second pen is blue,third pen is green,fourth pen is black,fifth pen is yellow.
the black pen is next to the pen with the blue cap?
the green pen is two pens away from the black pen?
the red and blue pens are not adjacent?
the yellow pen is second from the left?

2. Originally Posted by dianna
A computer nerd likes to keep five pens in his shirt pocket.
the pens are of five different colors and their caps,seen below,are of the same five colors but not a single cap is correctly situated on its color pen!
given the visible arrangement below and the following clues,can you determine the order of each colored pen?
first pen is red,second pen is blue,third pen is green,fourth pen is black,fifth pen is yellow.
the black pen is next to the pen with the blue cap?
the green pen is two pens away from the black pen?
the red and blue pens are not adjacent?
the yellow pen is second from the left?
Hello, dianna,

make a table of the visible caps and the possible positions of the pens:
Code:
visible   |   red    blue    green    black    yellow
--------------------------------------------------------
position  |   blue   yell.   black    red      green
The way I've done this problem:
1. yellow fixed position #2
2. possible position black #1 or #3, If #1 then green #3 which isn't possible because cap and pen must differ in colour. Thus black #3.
3. green #5. If green #1 (which is possible then red and blue would be adjacent)
4. blue #1. If blue #4 then red #1 which isn't possible because cap and pen must differ in colour.
5. red #4 no choice possible