Grasshopper

algorithmic modeling for Rhino

Hi guys,

Could you please advise me, what is the cleverest way to find sequence in a list? I have got a list, randomly filled with 0 and 1, where I need to find a sequence of 10 “1” or zeros. And if the list has this sequence, to get True as answer, or multiple True booleans if there are multiple sequences in target list.

Views: 563

Replies to This Discussion

Turn your sequence into Text, then Find/Replace "1111111111" with "AAAAAAAAA". Then the difference in length will be the number of times the string of 1's occurred.

Clever

Great, thank you, David. This solution could be so useful in many cases.

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service