Given a non-empty list items of positive integers in strictly ascending order, find and return the longest arithmetic progression whose all values exist somewhere in that sequence. Return the answer as a tuple (start, stride, n) of the values that define the progression. To ensure unique results to facilitate automated testing, if there exist several progressions of the same length, this function should return the one with the lowest start. If several progressions of equal length emanate from the lowest start, return the progression with the smallest stride. INTRUCTIONS: Input a comment or a solution on how you solve the problem, write a psuodocode and flow chart about th problem
Given a non-empty list items of positive integers in strictly ascending order, find and return the
longest arithmetic progression whose all values exist somewhere in that sequence. Return the answer as a tuple (start, stride, n) of the values that define the progression. To ensure unique results to facilitate automated testing, if there exist several progressions of the same length, this function should return the one with the lowest start. If several progressions of equal length emanate from the lowest start, return the progression with the smallest stride.
INTRUCTIONS:
Input a comment or a solution on how you solve the problem, write a psuodocode and flow chart about th problem
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images