Created
February 21, 2017 22:57
-
-
Save vaibhavsagar/9822cdd7e5daf68de67590cd8e6a4a31 to your computer and use it in GitHub Desktop.
Code Dojo 35 with @dalecr
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
import Data.List | |
count8s number = let | |
len = length $ filter (\string -> (read string :: Int) `mod` 8 == 0) $ tail $ subsequences number | |
in len `mod` (10^9+7) |
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
def count8s(number): | |
final = 0 | |
for i in range(1, len(number)): | |
combos = combinations(number,i) | |
filtered = [int(''.join(j)) for j in combos if int(''.join(j)) % 8 == 0] | |
final += len(filtered) | |
if int(number) % 8 == 0: final += 1 | |
return final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment