[Haskell-cafe] Is this haskelly enough? -- errm but every answer is wrong(?)

Anthony Clayden anthony_clayden at clear.net.nz
Tue Jul 17 20:36:45 EDT 2007


(Or at least the problem is under-specified.)

1. There may be several sub-sequences having the maximum
sum.
   So the type for the solution should be :: Num a => [a] ->
[[a]]
   (Note that the problem didn't ask for the maximum
itself.)

2. The inits . tails approach adds a fault:
   It introduces a sprinkling of empty sub-sequences. These
have sum zero.
   So in case the input list is all negative numbers ...

Being a software tester for my day job, I looked first not
for an elegant and/or efficient solution; but for where to
stretch the boundaries of the problem.


> However, the key point is that this is a TRICK QUESTION.

<snip>




More information about the Haskell-Cafe mailing list