P
P
Polina2020-01-16 13:46:54
Python
Polina, 2020-01-16 13:46:54

How to parse a two-dimensional cyclically updated list into separate elements in python?

For example, such a list
list = . .. and it is replenished cyclically
When I have a match on the composition of the block (but not on the sequence), for example
[[30, 15, 25], ...........[15,25,30]. ...] I need to fix it.
How can I do that?
After receiving them, you need to be able to compare all the numbers, taking into account their order according to
the condition X(n)>=X(ne1)

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
V
Vladimir Kuts, 2020-01-16
@fox_12

It's not entirely clear what you need, but you can parse a two-dimensional list into individual elements like this:

arr = 
sum(arr, [])

[0, 0, 0, 30, 15, 25, 20, 5, 15, 10, -5, 5, 0, -15, -5]

T
tsarevfs, 2020-01-16
@tsarevfs

To compare by the composition of the block, sort it or use set:

>>> set([1, 4, 3]) == set([4, 3, 1])
True

UPD: As rightly pointed out Umpiro set will throw out duplicate elements. So if you consider [1, 2, 1] and [1, 2] equal in composition, then use set. If not, then sort.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question