[Haskell-beginners] GCJ 2015 - Round 1A Problem - Haircut
Sumit Sahrawat, Maths & Computing, IIT (BHU)
sumit.sahrawat.apm13 at iitbhu.ac.in
Sat Apr 18 09:59:00 UTC 2015
Take a look here: https://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl'
Foldr is not recommended in most cases, the above article explains it all.
On 18 April 2015 at 09:11, Sourabh <sourabh.s.joshi at gmail.com> wrote:
> So I decided to try the Google Code Jam this year, and decided to code in
> Haskell.
>
> I passed the qualifiers, and today was Round 1A. I managed to get the
> first problem right (both small and large input), and got the 2nd problem
> right (for the small input). However, for the large input, it ran out of
> stack space with the following error:
> Stack space overflow: current size 33632 bytes
> Use '+RTS -Ksize -RTS' to increase it.
>
> Can someone tell me how I could have avoided or fixed this?
>
> It is also very possible that I had an algorithmic issue (needed to
> optimize my code or have a different algorithm for the large input
> perhaps?).
>
> Here is the problem description:
> https://code.google.com/codejam/contest/4224486/dashboard#s=p1
>
> And here is my code:
>
> https://github.com/cbrghostrider/Hacking/blob/master/codeJam/2015/haircut/haircut_try2.hs
>
>
> I made sure to use foldr, which is supposedly more stack efficient I
> believe. I don't know if the list append (++) was causing issues.
>
> If anyone can spot any problems, or provide suggestions, I would really
> appreciate it! Even though the round is done, I'd like to optimize this to
> make it run within 8 minutes, as intended.
>
> Thanks in advance!
> --
> SSJ
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
--
Regards
Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150418/ee23b7c8/attachment.html>
More information about the Beginners
mailing list