programmers problem
 
Magnets