Skip to main content
deleted 1 character in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 43 bytes

'['#x=x-1
']'#x=x+1
_#x=x
maximum.scanr(#)0

Usage example: maximum.scanr(#)0 $ "[1, [[3]], [5, 6], [[[[8]]]], 1]" -> 5.

Haskell doesn't have mixed lists (Integer mixed with List of Integer), so I cannot exploit some list detection functions and I have to parse the string.

Im starting at the right with 0 and add 1 for every ], subtract 1 for every [ and keep the valuesvalue otherwise. scanr keeps all intermediate results, so maximum can do it's work.

Haskell, 43 bytes

'['#x=x-1
']'#x=x+1
_#x=x
maximum.scanr(#)0

Usage example: maximum.scanr(#)0 $ "[1, [[3]], [5, 6], [[[[8]]]], 1]" -> 5.

Haskell doesn't have mixed lists (Integer mixed with List of Integer), so I cannot exploit some list detection functions and I have to parse the string.

Im starting at the right with 0 and add 1 for every ], subtract 1 for every [ and keep the values otherwise. scanr keeps all intermediate results, so maximum can do it's work.

Haskell, 43 bytes

'['#x=x-1
']'#x=x+1
_#x=x
maximum.scanr(#)0

Usage example: maximum.scanr(#)0 $ "[1, [[3]], [5, 6], [[[[8]]]], 1]" -> 5.

Haskell doesn't have mixed lists (Integer mixed with List of Integer), so I cannot exploit some list detection functions and I have to parse the string.

Im starting at the right with 0 and add 1 for every ], subtract 1 for every [ and keep the value otherwise. scanr keeps all intermediate results, so maximum can do it's work.

Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 43 bytes

'['#x=x-1
']'#x=x+1
_#x=x
maximum.scanr(#)0

Usage example: maximum.scanr(#)0 $ "[1, [[3]], [5, 6], [[[[8]]]], 1]" -> 5.

Haskell doesn't have mixed lists (Integer mixed with List of Integer), so I cannot exploit some list detection functions and I have to parse the string.

Im starting at the right with 0 and add 1 for every ], subtract 1 for every [ and keep the values otherwise. scanr keeps all intermediate results, so maximum can do it's work.