edgeTile :: (Int, Int, Int, Int, Int) -> Int
edgeTile (tn, tw, te, ts, t)
  | (tn /= t) && (tw /= t) && (te /= t) && (ts /= t) = 19
  | (tn /= t) && (tw /= t) && (te /= t)              = 16
  | (tn /= t) && (tw /= t) &&              (ts /= t) = 18
  | (tn /= t) &&              (te /= t) && (ts /= t) = 20
  |              (tw /= t) && (te /= t) && (ts /= t) = 22
  | (tn /= t) && (tw /= t)                           = 6
  | (tn /= t) &&              (te /= t)              = 8
  | (tn /= t) &&                           (ts /= t) = 21
  |              (tw /= t) && (te /= t)              = 15
  |              (tw /= t) &&              (ts /= t) = 12
  |                           (te /= t) && (ts /= t) = 14
  | (tn /= t)                                        = 7
  |              (tw /= t)                           = 9
  |                           (te /= t)              = 11
  |                                        (ts /= t) = 13
  | otherwise                                        = 0
edgeTile :: (Int, Int, Int, Int, Int) -> Int
edgeTile (tn, tw, te, ts, t)
  | (tn /= t) && (tw /= t) && (te /= t) && (ts /= t) = 19
  | (tn /= t) && (tw /= t) && (te /= t)              = 16
  | (tn /= t) && (tw /= t) &&              (ts /= t) = 18
  | (tn /= t) &&              (te /= t) && (ts /= t) = 20
  |              (tw /= t) && (te /= t) && (ts /= t) = 22
  | (tn /= t) && (tw /= t)                           = 6
  | (tn /= t) &&              (te /= t)              = 8
  | (tn /= t) &&                           (ts /= t) = 21
  |              (tw /= t) && (te /= t)              = 15
  |              (tw /= t) &&              (ts /= t) = 12
  |                           (te /= t) && (ts /= t) = 14
  | (tn /= t)                                        = 7
  |              (tw /= t)                           = 9
  |                           (te /= t)              = 11
  |                                        (ts /= t) = 13
  | otherwise                                        = 0
edgeTile (tn, tw, te, ts, t)
  | (tn /= t) && (tw /= t) && (te /= t) && (ts /= t) = 19
  | (tn /= t) && (tw /= t) && (te /= t)              = 16
  | (tn /= t) && (tw /= t) &&              (ts /= t) = 18
  | (tn /= t) &&              (te /= t) && (ts /= t) = 20
  |              (tw /= t) && (te /= t) && (ts /= t) = 22
  | (tn /= t) && (tw /= t)                           = 6
  | (tn /= t) &&              (te /= t)              = 8
  | (tn /= t) &&                           (ts /= t) = 21
  |              (tw /= t) && (te /= t)              = 15
  |              (tw /= t) &&              (ts /= t) = 12
  |                           (te /= t) && (ts /= t) = 14
  | (tn /= t)                                        = 7
  |              (tw /= t)                           = 9
  |                           (te /= t)              = 11
  |                                        (ts /= t) = 13
  | otherwise                                        = 0