fork download
  1. g b|a<-[b!!0..last b]=last$0:[c|c<-a,b==filter(/=c)a]
  2. f=maximum.map(g.map read.words.concat).mapM(\c->[[c],c:" "])
  3.  
  4. main = print $ map f ["123467",
  5. "911",
  6. "123125",
  7. "123",
  8. "121314"]
Success #stdin #stdout 0.04s 6760KB
stdin
Standard input is empty
stdout
[5,10,124,0,0]