Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Question about problem "KAMIL" from SPOJ (Nadav Chernin)
2. Re: Question about problem "KAMIL" from SPOJ (Frerich Raabe)
----------------------------------------------------------------------
Message: 1
Date: Thu, 18 Jul 2013 18:32:10 +0300
From: Nadav Chernin <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Question about problem "KAMIL" from SPOJ
Message-ID:
<cae80g0+iabugayyqn7dabnv+5hp0vw87ceth7bcjuylnvud...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi,
I'm trying to solve problem "KAMIL" on SPOJ site
The target is to write as small as possible code.
My first solution was:
main=interact$unlines.map(show.(2^).length.filter(`elem`"TDLF")).lines
This code = 70 bytes and it accepted on SPOJ
My second solution was:
main=getLine>>=print.(2^).length.filter(`elem`"TDLF")>>main
This code = 60 bytes, but i get Run-Time error on SPOJ
I don't understand how this code can create RTE?
Please help me
Nadav
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130718/56cca73a/attachment-0001.html>
------------------------------
Message: 2
Date: Thu, 18 Jul 2013 18:17:39 +0200
From: Frerich Raabe <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Question about problem "KAMIL" from
SPOJ
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 2013-07-18 17:32, Nadav Chernin wrote:
> My second solution was:
>
> main=getLine>>=print.(2^).length.filter(`elem`"TDLF")>>main
>
> This code = 60 bytes, but i get Run-Time error on SPOJ
>
> I don't understand how this code can create RTE?
I think it's because getLine will try to read something even if you're
at the end of the input. Try guarding the call with 'isEOF', e.g.
main=isEOF>>=flip
unless(getLine>>=print.(2^).length.filter(`elem`"TDLF")>>main)
--
Frerich Raabe - [email protected]
www.froglogic.com - Multi-Platform GUI Testing
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 61, Issue 22
*****************************************