Re: [Haskell-cafe] why these two are not equivalent?

2009-09-14 Thread Diego Souza
On Sun, Sep 13, 2009 at 09:57:50PM -0700, Iavor Diatchki wrote: (argh, sorry about that, I pressed something and gmail sent my unfinished email!) On Sun, Sep 13, 2009 at 9:54 PM, Iavor Diatchki iavor.diatc...@gmail.com wrote: Hi, It seems that the problem is the site is using GHC 6.6.1,

Re: [Haskell-cafe] why these two are not equivalent?

2009-09-13 Thread Max Rabkin
On Sat, Sep 12, 2009 at 9:52 PM, Diego Souza dso...@bitforest.org wrote: I assumed Data.Map was a tree internally and keep elements ordered, so the following would sort the input and print duplicates in O(n log n), as the C++ version does: sbank :: [B.ByteString] - [(B.ByteString,Int)] sbank

Re: [Haskell-cafe] why these two are not equivalent?

2009-09-13 Thread Diego Souza
On Sun, Sep 13, 2009 at 11:34:16AM +0200, Max Rabkin wrote: That is part of the contract of toAscList (the Asc stands for ascending order), but because of the way Map is implemented, the result of toList is also sorted. Cool. It is good to know that toAscList and toList would produce the same

Re: [Haskell-cafe] why these two are not equivalent?

2009-09-13 Thread Iavor Diatchki
Hi, It seems that the problem is the site is using GHC 6.6.1, and something was broken at the time (I have not looked into what that is). Here are the outputs that I get for the little example on the site that you posted: GHC 6.10.3 and C++: On Sun, Sep 13, 2009 at 10:15 AM, Diego Souza

Re: [Haskell-cafe] why these two are not equivalent?

2009-09-13 Thread Iavor Diatchki
(argh, sorry about that, I pressed something and gmail sent my unfinished email!) On Sun, Sep 13, 2009 at 9:54 PM, Iavor Diatchki iavor.diatc...@gmail.com wrote: Hi, It seems that the problem is the site is using GHC 6.6.1, and something was broken at the time (I have not looked into what that

[Haskell-cafe] why these two are not equivalent?

2009-09-12 Thread Diego Souza
Hi, I was trying to solve a simple problem in SPOJ, however, after two weeks trying almost everything I could think of, I was still getting WrongAnswer. Then I decided to do the same thing in C++ and I really got puzzled when I got ACcepted. I tried to understand what was different without

Re: [Haskell-cafe] why these two are not equivalent?

2009-09-12 Thread Jason Dagit
On Sat, Sep 12, 2009 at 12:08 PM, Diego Souza dso...@bitforest.org wrote: Hi, I was trying to solve a simple problem in SPOJ, however, after two weeks trying almost everything I could think of, I was still getting WrongAnswer. Then I decided to do the same thing in C++ and I really got

Re: [Haskell-cafe] why these two are not equivalent?

2009-09-12 Thread Jason Dagit
On Sat, Sep 12, 2009 at 12:46 PM, Jason Dagit da...@codersbase.com wrote: On Sat, Sep 12, 2009 at 12:08 PM, Diego Souza dso...@bitforest.orgwrote: Hi, I was trying to solve a simple problem in SPOJ, however, after two weeks trying almost everything I could think of, I was still getting

Re: [Haskell-cafe] why these two are not equivalent?

2009-09-12 Thread Diego Souza
Looks like the output should be sorted. The C++ version does this with the iterator over mapstring, int implicitly. I don't spot where your haskell version sorts the output. There could be other problems, that's just what I can notice in 2 minutes of looking. Good luck! Jason, I