-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sony?
committed
May 9, 2014
1 parent
bbe39f9
commit 6c0db90
Showing
4 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 2 3 4 5 6 7 8 9 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import System.IO (getLine) | ||
|
||
toInt :: [String] -> [Int] | ||
toInt = map read | ||
|
||
-- Get every nth element in a list | ||
every :: Int -> [Int] -> [Int] | ||
every _ [] = [] | ||
every n (x:xs) = x : every n (drop (n-1) xs) | ||
|
||
main = do | ||
stdin <- getLine | ||
let numbers = toInt $ words stdin | ||
let total = sum [foldl (\acc x -> acc + x*3) 0 (every 2 numbers), | ||
foldl (\acc x -> acc + x*7) 0 (every 2 (tail numbers))] | ||
|
||
print $ total `mod` 10 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from sys import stdin | ||
|
||
data = stdin.read().split(); | ||
data = map(int, data); | ||
sum = 0; | ||
|
||
for s in data[::2]: | ||
sum = sum + 3*s; | ||
|
||
for s in data[1::2]: | ||
sum = sum + 7*s; | ||
|
||
print sum % 10 |