<div dir="ltr">The link doesn't work because the hyperlink doesn't include the apostrophe at the end.<div>Also, I'm sorry for having written off foldr as being worthless, I didn't think much about it when I replied.</div><div><br></div><div>Foldl is the bad one here, whereas foldr and foldl' are both good and recommended options.</div><div>Foldr can cause stack overflow as it also creates unevaluated thunks, but then you can use foldl' to get over that.</div><div><br></div><div>How did it go with strict foldl?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 18 April 2015 at 21:04, Sourabh <span dir="ltr"><<a href="mailto:sourabh.s.joshi@gmail.com" target="_blank">sourabh.s.joshi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks Sumit, I changed my folds to a strict foldl'. I'll check how long it runs now.<div><br></div><div>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 ;)</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 18, 2015 at 7:29 AM, Doug McIlroy <span dir="ltr"><<a href="mailto:doug@cs.dartmouth.edu" target="_blank">doug@cs.dartmouth.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>> Can someone tell me how I could have avoided or fixed this?<br>
<br>
</span>The trouble manifested as stack overflow on solving<br>
<br>
> <a href="https://code.google.com/codejam/contest/4224486/dashboard#s=p1" target="_blank">https://code.google.com/codejam/contest/4224486/dashboard#s=p1</a><br>
<br>
For efficiency, you'll probably need more cleverness in math than<br>
in Haskell. You can predict an approximate start time for the Nth<br>
customer's service from the average per-customer service time M,<br>
where 1/M = sum 1/M_k.<br>
Starting from that estimate, one can skip over almost the entire<br>
service simulation.<br>
<span><font color="#888888"><br>
Doug McIlroy<br>
</font></span></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div>