[Haskell-beginners] GCJ 2015 - Round 1A Problem - Haircut

Sourabh sourabh.s.joshi at gmail.com
Sat Apr 18 15:34:42 UTC 2015


Thanks Sumit, I changed my folds to a strict foldl'. I'll check how long it
runs now.

Doug, I think you are absolutely correct. Taking the harmonic mean probably
factored into the solution, in order to make it algorithmically feasible
for the large input! Lesson learnt, next time I'll probably think harder
about the problem than the code ;)

On Sat, Apr 18, 2015 at 7:29 AM, Doug McIlroy <doug at cs.dartmouth.edu> wrote:

> > Can someone tell me how I could have avoided or fixed this?
>
> The trouble manifested as stack overflow on solving
>
> > https://code.google.com/codejam/contest/4224486/dashboard#s=p1
>
> For efficiency, you'll probably need more cleverness in math than
> in Haskell. You can predict an approximate start time for the Nth
> customer's service from the average per-customer service time M,
> where 1/M = sum 1/M_k.
> Starting from that estimate, one can skip over almost the entire
> service simulation.
>
> Doug McIlroy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150418/0c5ba600/attachment.html>


More information about the Beginners mailing list