Skip to content

Instantly share code, notes, and snippets.

@vipzero
Created August 17, 2019 02:59
Show Gist options
  • Save vipzero/447e79f8fb17273c896314acc7d1a5b4 to your computer and use it in GitHub Desktop.
Save vipzero/447e79f8fb17273c896314acc7d1a5b4 to your computer and use it in GitHub Desktop.
import Data.List
commas = map (* 111) [0 .. 9]
diff1000 v c | d <= 500 = d
| otherwise = 1000 - d
where
d = a - b
a = max c v
b = min c v
calc n = (n, s) where s = sum $ map (\c -> diff1000 n c) commas
main = print $ sortBy (\(a, b) (a2, b2) -> compare b b2) $ map calc [0 .. 999]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment