mukesh tiwari <mukeshtiwari.iiitm@gmail.com> wrote:
> I am trying to solve this problem:
> http://projecteuler.net/index.php?se...roblems&id=103
> After solving I looked into the forum but no one solved it using
> brute force algorithm in Haskell so my question is " is it possible
> to solve this problem in Haskell using brute force algorithm ?".
While it's possible to write fast brute force programs in Haskell,
it takes quite a bit of experience. And it's not really Haskell's
strength. Haskell's strength is to be able to write down complex
algorithms quickly and correctly.
And nearly all of the problems at Project Euler can be solved a lot
faster if you invest some thought. So actually Haskell is a good match
for Project Euler (but not if you try do everything with brute force).
If you really need brute force, my strategy back then for Project
Euler on my old and slow computer with too little memory was to first
write the algorithm in Haskell, verify that it works for small n. Then
rewrite it in C, compare the results with the Haskell for small n, and
finally do the brute force in C.
(BTW, I solved problem 103 in the toplevel without even compiling the
program. I still used trial and error, but I did some preprocessing
with pen and paper to narrow down the ranges for which I had to do
trial and error, and that was enough to make it quite fast even on
that outdated machine).
- Dirk