Maximum of a list X40606


Statement
 

pdf   zip

The maximum of a list tt is the largest element that it contains. For example, the maximum of [1,2,3][1, 2, 3] is 3, the maximum of [1,[2,3],4][1, [2, 3], 4] is 4, and the maximum of [[[1]]][[[1]]] is 1. The maximum of [][] is defined to be 0.

Write a program that prints the maximum of every given list.

Define and use a recursive function

maximum(t)

that returns the maximum of a list tt.

Hint

Using the @ast@ package, you can extract the list tt encoded in a string ss with @t = ast.literal_eval(s)@.

Input

The input consists of several lists of non-negative numbers.

Output

Print the maximum of every given list.

Public test cases
  • Input

    []
    [1, 2, 3]
    [1, [2, 3], 4]
    [[[1]]]
    

    Output

    0
    3
    4
    1
    
  • Information
    Author
    Gabriel Valiente
    Language
    English
    Official solutions
    Python
    User solutions
    Python