Home

# PureScript solution to Project Euler problem 29

`2020-Feb-02 17:45`

Problem details at Project Euler problem 29 page.

## Test

 123456789101112131415 `module` `Euler029Test (euler29suite) ``where` `import` `Prelude` `import` `Euler029 (euler29)``import` `Test``.``Unit (TestSuite, suite, test)``import` `Test``.``Unit``.``Assert ``as` `Assert` `euler29suite ``::` `TestSuite``euler29suite ``=``  ``suite ``"Euler 29"` `do``    ``test ``"Warmup"` `do``      ``Assert``.``equal ``15` `(euler29 ``5``)``    ``test ``"Real"` `do``      ``Assert``.``equal ``9183` `(euler29 ``100``)`

## Solution

 123456789101112131415 `module` `Euler029 ``where` `import` `Prelude` `import` `Data``.``Array` `(``length``, nub, range)``import` `Data``.``BigInt (BigInt, fromInt, pow)` `powers ``::` `Int` `-``> ``Array` `BigInt``powers n ``=` `do``  ``a <``-` `range ``2` `n``  ``b <``-` `range ``2` `n``  ``pure` `\$` `pow (fromInt a) (fromInt b)` `euler29 ``::` `Int` `-``> ``Int``euler29 ``=` `powers >>> nub >>> ``length`