Skip to content

Instantly share code, notes, and snippets.

@sifue
Created November 11, 2014 11:22
Show Gist options
  • Select an option

  • Save sifue/e5175459d6b28ae9f47a to your computer and use it in GitHub Desktop.

Select an option

Save sifue/e5175459d6b28ae9f47a to your computer and use it in GitHub Desktop.
Haskell勉強会宿題
-- (1)
manlen :: (Int, Int) -> (Int, Int) -> Int
manlen (a, b) (c, d) = abs(a - c) + abs(b - d)
-- (2)
points :: Int -> [(Int, Int)]
points x = [ (a, b) | a <- [(-1 * x)..x], b <-[(-1 * x)..x]]
-- (3)
mancircle :: Int -> [(Int, Int)]
mancircle x = [(a, b) | (a, b) <- points(x), manlen (0, 0) (a, b) == x]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment