~rootmos/AoC

52bb1306cd2687b76a3f5c1eb18b062d47213c25 — Gustav Behm 1 year, 4 months ago 0d911bd
Add solution to AoC 2015 #25a
1 files changed, 30 insertions(+), 0 deletions(-)

A 2015/25.hs
A 2015/25.hs => 2015/25.hs +30 -0
@@ 0,0 1,30 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Main where

import Qulude

--import Data.Array ( (!) )
import qualified Data.Array as Array
import qualified Data.Either as Either
import qualified Data.List as List
--import Data.Array ( (!) )
import qualified Data.Map as Map
import qualified Data.Maybe as Maybe
import qualified Data.Sequence as Seq
import qualified Data.Set as Set

code :: (Int, Int) -> Integer
code p = go 20151125 (1,1)
  where go !i q | p == q = i
        go !i q = go (f i) (g q)
        f i = i * 252533 `mod` 33554393
        g (x,1) = (1,x+1)
        g (x,y) = (x+1,y-1)

main :: IO ()
main = do
  putStrLn . show $ code (3075,2981) -- 9132360