Grasshopper

algorithmic modeling for Rhino

Retrieving data based on same character combination

Hi everyone,

 

I'd like to ask for help on the following problem. I have a set of 4 digit numbers stored in a list, and i was wondering if there is a way to retrieve certain numbers if it uses the same combination of digits within it?

 

For example, the number '0011' would be grouped with:

 

1001

0110

1100

0101

1010

etc.

 

Basically, the new list would retrieve every number which has two '1' digits & two '0' digits.

 

Any help would be greatly appreciated.

 

Cheers,

Alex

Views: 402

Replies to This Discussion

Hi Alex


I'm thinking of an addition of all characters, and then testing if the results are equal to 0, 1, 2, 3 or 4, for example.

In the file I enclose, I did that for 2, but it is easy to duplicate that for all the possibilities.

Is it what you want to achieve ?

Attachments:

Here's my approach,

Split the Characters up --> Sort them --> Then Join the results back together so that they match the Search Pattern and then do a cull Pattern on the original list.

Thanks for your suggestions Rhydro & Danny.

Rhydro, your method works for numbers that use two types of digits, but I start running into problems when i go on to using more types of digits (E.g. 0123 can be grouped with 0006).

Danny, I used your definition and it works perfectly!

Thanks again for your suggestions!

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service