Orderings IMPROVED
This is spring cleaning day in the Cartan Node Library. Another improved node: orderings.
The orderings node returns a list of all the possible ways you could reorder n items where n varies from 1 to 7. There are 5040 ways of reordering 7 items. Original description of this node here:
http://support.nodebox.net/discussions/show-your-work/689-orderings...
I have added two improvements:
- You can now change the delimiter for each ordering string from a comma to something else (or nothing at all)
- You can optionally replace indices (from 0 to n-1) with some other set of symbols
Orderings now takes 3 parameters:
- Items. The number of items (n) from 1 to 7. Ignored if you supply a list of symbols.
- Delimiter. The character used to separate the indices in each ordering (e.g. comma, dash, space, or nothing).
- Symbols. OPTIONAL - a list of up to 7 strings to use in place of the indices. If provided, the number of symbols will determine the number of items to be reordered. If more than 7 provided, only the first 7 will be used.
Previously, orderings would return a list of orders where each order was a comma-separated list of indices (e.g. 0,2,1). These orders could then be disassembled using a make_numbers node and fed into a slice node to pull out items from some other list in a particular order.
Often, though, what you REALLY want is a list of symbols (e.g. ABCDE or 12345) in all possible orders. So instead of forcing you to make a subnetwork each time to slice those symbols, I now give you the option of simply inputting them. Allowing you to use something other than a comma as a separator between each symbol in an order gives you even more flexibility.
EXAMPLE
Yesterday I used this node to solve a puzzle looking for a particular 6 digit number containing the digits from 1 to 6 with no duplicates. So I wanted to start with a list of all possible such numbers from 123456 to 654321. Before this would have required converting orders like "0,3,2,5,4,1" into 143652. With the improved node all I had to do was set the delimiter to nothing and provide 1 through 6 as my list of symbols.
DEMO
The attached demo is my original demo with two additions. The original demo created a display of six "trigrams" composed of all possible orderings of a triangle, square, and pentagon arranged from the inside out. For that one (orderings2) I use the same comma delimiter as before, set items to 3, and do not provide any symbols. The trigram subnetwork uses each set comma-separated indices to generate the trigrams.
I then use orderings2 to add labels for each trigram indicating the number of sides in the center, middle and edges: 345, 354, 435, 453, 534, and 543. To do this all I had to do was set the delimiter to nothing and provide 3,4,5 as my symbols.
You can also use colors as symbols. To do this I just feed four colors from my color_brewer node into the symbols port of orderings3. I use a comma as a delimiter and as the separator in the make_strings2 node. This produces a list of 96 hex codes (24 possible orders of 4 colors each). I pass these hex code strings through a color node and use them to colorize 96 rectangles which I then stack into a band using my stack2D node. After rotating, each column in the band represents a different ordering of the four colors.
I also include an additional demonstration, not rendered, that shows how you can use a frame node to create an animation of color orderings changing over time.
An interesting little node, now even better!
-
orderings_3.7_screenshot.png 648 KB
- orderings_3.7_demo.ndbx.zip 42.4 KB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac