Biggest Consecutively Repeated Number X63041


Statement
 

pdf   zip

html

Write a function bigrep(ls) that receives a list ls of positive integers and reports the largest one that appears twice consecutively somewhere in the list.

Sample session
>>> bigrep( [5, 5, 4, 3, 3, 3, 2, 1, 1, 1, 1] )
5
>>> bigrep( [1, 1, 6, 1, 6, 2, 2, 3, 4, 4, 5] )
4
>>> bigrep( [1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1] )
0
>>> bigrep( [1234, 1234, 2000, 1234, 2000] )
1234
>>> bigrep( [1234, 1234, 1234, 2000, 2000] )
2000
Information
Author
José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python