language: Haskell (ghc-6.8.2)
date: 115 days 21 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import Data.List
import Data.Function
 
readArray [] _ acc = concat acc
readArray (line:rest) n acc = readArray rest (n+1) ((readLine n line):acc)
  where readLine y line = map (\(x, s) -> ((x, y), read s::Int))
                          $ zip [0..]
                          $ words line
 
filterArray acc [] = reverse acc
filterArray acc (val@((x,y), _):rest) = filterArray (val:acc)
                                        $ filter ((/=x).fst.fst)
                                        $ filter ((/=y).snd.fst)
                                        $ rest
 
main = do
  content <- getContents
  print $ filterArray []
       $ reverse
       $ sortBy (compare `on` snd)
       $ readArray (lines content) 0 []
 
  • upload with new input
  • result: Success     time: 0.02s    memory: 3724 kB     returned value: 0

    1 2 3
    4 5 6
    7 8 9
    [((2,2),9),((1,1),5),((0,0),1)]