Skip to content

Instantly share code, notes, and snippets.

@stbuehler
Created June 4, 2015 19:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stbuehler/80501a17901b0902ce66 to your computer and use it in GitHub Desktop.
Save stbuehler/80501a17901b0902ce66 to your computer and use it in GitHub Desktop.
hacker evolution safegame checksum calculation
-- take all numbers from the 3rd until the second last line, multiply each
-- number with the associated multiplier from the list [10,5,6,7,8,9,11,13,14,15,16,2,3,17,18,19]
-- and sum everything up (modulo Int32) to get the checksum.
-- (hint: line 11, the 9th number in the list, is the cash amount)
-- in haskell:
import Data.Int
checksum :: [Int32] -> Int32
checksum nums = sum $ zipWith (*) nums [10,5,6,7,8,9,11,13,14,15,16,2,3,17,18,19]
-- or, in ghci: let checksum nums = sum $ zipWith (*) nums [10,5,6,7,8,9,11,13,14,15,16,2,3,17,18,19] :: Int32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment