Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.Digits
- import Data.List
- intToBin = map (`mod` 2) . takeWhile (>0) . iterate (`div` 2)
- replaceByCode l code d = let
- cs = intToBin code
- targetDs = map fst $ filter ((==1) . snd) $ zip l cs
- in
- if length (group targetDs) == 1
- then unDigits 10 $ zipWith (\(dOld, c) -> if c == 1 then 5 else dOld) l cs
- else 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement