fork download
  1. m"K"=[1,2]
  2. m"Q"=m"B"++m"R"
  3. m"R"=[1,4,9]
  4. m"B"=[2,8,18]
  5. m"N"=[5]
  6. m"P"=[2]
  7. l%x=[z|z<-l,fst z/=x]
  8. f[_]=[[]]
  9. f l=[(i,j):r|(i@(s,t),a)<-l,(j@(u,v),_)<-l%i,r<-f$(j,a):l%i%j,(s-u)^2+(t-v)^2`elem`m a]
  10.  
  11. main = readLn >>= (mapM_ print . f)
Success #stdin #stdout 0.01s 5280KB
stdin
[((1, 2), "B"), ((0, 2), "R"), ((2, 1), "P"), ((3, 0), "K"), ((0, 0), "B")]
stdout
[((1,2),(2,1)),((2,1),(3,0)),((0,2),(0,0)),((0,0),(3,0))]
[((1,2),(2,1)),((0,2),(0,0)),((0,0),(3,0)),((2,1),(3,0))]
[((1,2),(2,1)),((0,2),(0,0)),((2,1),(3,0)),((0,0),(3,0))]
[((1,2),(3,0)),((0,2),(0,0)),((0,0),(3,0)),((2,1),(3,0))]
[((1,2),(3,0)),((0,2),(0,0)),((2,1),(3,0)),((0,0),(3,0))]
[((1,2),(3,0)),((2,1),(3,0)),((0,2),(0,0)),((0,0),(3,0))]
[((0,2),(0,0)),((0,0),(3,0)),((1,2),(3,0)),((3,0),(2,1))]
[((0,2),(0,0)),((0,0),(3,0)),((1,2),(3,0)),((2,1),(3,0))]
[((0,2),(0,0)),((0,0),(3,0)),((1,2),(2,1)),((2,1),(3,0))]
[((0,2),(0,0)),((0,0),(3,0)),((2,1),(3,0)),((1,2),(3,0))]
[((0,2),(0,0)),((1,2),(2,1)),((2,1),(3,0)),((0,0),(3,0))]
[((0,2),(0,0)),((1,2),(2,1)),((0,0),(3,0)),((2,1),(3,0))]
[((0,2),(0,0)),((1,2),(3,0)),((0,0),(3,0)),((2,1),(3,0))]
[((0,2),(0,0)),((1,2),(3,0)),((2,1),(3,0)),((0,0),(3,0))]
[((0,2),(0,0)),((2,1),(3,0)),((0,0),(3,0)),((1,2),(3,0))]
[((0,2),(0,0)),((2,1),(3,0)),((1,2),(3,0)),((0,0),(3,0))]
[((2,1),(3,0)),((1,2),(3,0)),((0,2),(0,0)),((0,0),(3,0))]
[((2,1),(3,0)),((0,2),(0,0)),((0,0),(3,0)),((1,2),(3,0))]
[((2,1),(3,0)),((0,2),(0,0)),((1,2),(3,0)),((0,0),(3,0))]