Euler 205

16 views
Skip to first unread message

Douglas

unread,
Mar 25, 2012, 7:06:14 AM3/25/12
to brisfun...@googlegroups.com
Having a look at the solutions posted in the forum, this Haskell implementation by glguy stands out: 

http://projecteuler.net/thread=205;page=4

import Data.List (transpose)

d n s = map (/ fromIntegral (s^n)) (iterate roll [1] !! n)
 where roll = map sum . transpose . take s . tail . iterate (0:)

beats a b = sum $ zipWith (*) (tail a) $ scanl1 (+) b

p205 = peter `beats` colin
colin = 6 `d` 6
peter = 9 `d` 4

Arwyn

unread,
Mar 25, 2012, 1:46:25 PM3/25/12
to brisfun...@googlegroups.com
I like it; especially the last 3 lines.

Arwyn
Reply all
Reply to author
Forward
0 new messages