never executed always true always false
    1 {-|
    2 Module:      Y2015.D25
    3 Description: Advent of Code Day 25 Solutions.
    4 License:     MIT
    5 Maintainer:  @tylerjl
    6 
    7 Solutions to the day 25 set of problems for <adventofcode.com>.
    8 
    9 Implements a simple function to return the machine code at a position
   10 indicated by plaintext input for a row and column.
   11 -}
   12 
   13 module Y2015.D25 (manualCodeFrom) where
   14 
   15 type Point = (Int, Int)
   16 
   17 -- |Return the manual code found at the indicated row and column
   18 -- |from human-readable input.
   19 manualCodeFrom :: String  -- ^ Plaintext instruction input.
   20                -> Integer -- ^ Numerical code found at the indicated position.
   21 manualCodeFrom = (!!) manualSeq . toPos . toPoint
   22     where toPos (x, y) = (i - 1) * (i - 2) `div` 2 + i - x - 1
   23                        where i = x + y
   24 
   25 toPoint :: String -> Point
   26 toPoint = go . words
   27     where go s = (grab 15, grab 17)
   28                  where grab = read . init . (!!) s
   29 
   30 manualSeq :: [Integer]
   31 manualSeq = iterate f 20151125 where
   32     f = flip mod 33554393 . (*) 252533