Created
August 17, 2019 02:59
-
-
Save vipzero/447e79f8fb17273c896314acc7d1a5b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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