Created
November 4, 2012 15:03
-
-
Save oker1/4012203 to your computer and use it in GitHub Desktop.
haskell házi 1
This file contains hidden or 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
rotate :: String -> [String] | |
rotate l = rotate_recursive l [] | |
rotate_recursive :: String -> String -> [String] | |
rotate_recursive [] list = [] | |
rotate_recursive list1 list2 = | |
let (h1:t1) = list1 | |
in [list1 ++ list2] ++ rotate_recursive t1 (list2 ++ [h1]) | |
-- http://code.google.com/codejam/contest/1460488/dashboard#s=p2 | |
is_recycled :: String -> String -> Bool | |
is_recycled l1 l2 = length [ x | x <- rotate l1, x /= l1, x == l2] >= 1 | |
recycled_numbers :: Int -> Int -> Int | |
recycled_numbers from to = length [ (x,y) | | |
x <- [from..to], y <- [from..to], x < y, is_recycled (show x) (show y) ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment