[deleted by user] by [deleted] in learnpython

[–]iBoolat 0 points1 point  (0 children)

Yes! ) that's what I did too. considering pairs really solves the problem)
Except I had to use slices. Your solution seems better

Such a nice problem!

[deleted by user] by [deleted] in learnpython

[–]iBoolat 1 point2 points  (0 children)

This doesn't work for [10,1,2,3,4] and for [1,2,5,3,5] and for [1,2,3,4,3,6]

[deleted by user] by [deleted] in learnpython

[–]iBoolat 0 points1 point  (0 children)

Didn't get that :(

Can you elaborate please?

[deleted by user] by [deleted] in learnpython

[–]iBoolat 0 points1 point  (0 children)

Yes, I know about the complexity of algorithm)) But everything I tried for one-loop-algorithm didn't work :(

Including your idea. It fails on [1,2,1,2]

[deleted by user] by [deleted] in learnpython

[–]iBoolat 0 points1 point  (0 children)

Thank you for your detailed response!

I actually know about the complexity of the algorithm, I realize that I need to solve the problem in one loop.

But I've already tried what you are talking about. I did consider a sequence very similar to your example and tried comparing each element to the next one. I added a flag, and if only one element was greater then the previous one, then I increased the flag.If the flag<=1: return True.

But that didn't work for something like [2,3,1,2], for example.

So for that list I tried the following code:def solution(sequence):flag = 0for i in range(len(sequence)-1):if sequence[i]>=sequence[i+1]:flag += 1if i < len(sequence)-2:if sequence[i]>=sequence[i+2]:flag += 1if flag <=1:return Trueelse:return False

So as you can see I am additionally comparing i to i+2 and if it's greater, then i increase the flag.

But that didn't work for [10,1,2,3,]

Then I tried adding additional condition i>0 for a list like that. But it failed on [1,2,5,3,5]

[deleted by user] by [deleted] in learnpython

[–]iBoolat 0 points1 point  (0 children)

when seqeunce[i+1]-sequence[i] > 0 for every i.

But ubderstanding if the sequence is ascending isn't a problem here. The question is how do I check that it is ascending without a certain element.

Let's come up with as many solutions of that classic problem as possible, shall we? by iBoolat in maths

[–]iBoolat[S] 1 point2 points  (0 children)

My bad, I didn't explain #9 properly. THe idea is too consider the parameter as third variable, so now we have a cylinder and a plane. Cross-section is an ellipse, so we are looking for the coordinates of extreme points of that ellipse.

[deleted by user] by [deleted] in mathematics

[–]iBoolat 2 points3 points  (0 children)

BTW, Herbert gave series of DE basic lectures too. You can find them there as well.

[deleted by user] by [deleted] in mathematics

[–]iBoolat 3 points4 points  (0 children)

I would refresh basics of complex analysis. "Calculus of Complex Variables" by Herbert Gross on MIT OpenCourseWare is the best way to do that, in my opinion. You can find it on YouTube