[Tutor] python programmin problem
Alan Gauld
alan.gauld at yahoo.co.uk
Wed Jul 20 19:11:24 EDT 2016
On 20/07/16 22:11, monikajg at netzero.net wrote:
> ... if not in python, then in pseudo code.
The first question to ask is can you do it without a computer?
In other words given
input [1,7,2,3,5,4,6]
Can you first of all produce a list of all valid runs?
[1,2,3,5,6] and [1,2,3,4,6] both have length 5
I also see shorter runs:
[7] and [4,6] for example.
Can you manually create a list of all valid runs?
Once you can do that can you write a program to
generate that as a list of lists in Python?
If so then the answer to your question is a matter of
finding the length of the longest valid run which
should be fairly easy.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list