Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Say that a stair in a list is a series of 3 or more adjacent elements with equal distance between them, e . g .

Say that a "stair" in a list is a series of 3 or more adjacent elements with equal distance between them, e.g.[1,2,3] or [10,12,14,16]. So given an input list [1,2,3,4,5,1,4,7], there are two stairs: [1,2,3,4,5] and [1,4,7].
Print the number of stairs in an input list. (You can hard-code the input list instead of reading it from the keyboard, e.g., setting the input list to be [1,2,3,4,5,1,4,7]).
Examples:
Input list =[1,2,3,4,5,3,4,5,4]
Output: 2
Input list =[1,1,3,5,1]
Output: 1
input list =[1,1,2,1]
Output: 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions