Reptorian's Combinatorics Library: Repeated Distinct Elements (RDE)
Description
Combinatorial structures formed from multisets where eachelement type has a fixed number of allowed occurrences.
Very much applicable in scenario where you need to restrict number of occurrences, or string-processing.
Examples:
rep_rde_permutation(s)_
Permutations of a multiset where each element can appear a fixed number of times. Think of it as all possible orderings of repeated elements$ +rep_rde_permutations 2,1,1 repeat w { e[0] {I[#-1,$>]} }
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1,2
[gmic]./ 0,0,2,1
[gmic]./ 0,1,0,2
[gmic]./ 0,1,2,0
[gmic]./ 0,2,0,1
[gmic]./ 0,2,1,0
[gmic]./ 1,0,0,2
[gmic]./ 1,0,2,0
[gmic]./ 1,2,0,0
[gmic]./ 2,0,0,1
[gmic]./ 2,0,1,0
[gmic]./ 2,1,0,0
[gmic]./ Display image [0] = '[unnamed]'.
[0] = '[unnamed]':
size = (12,1,1,4) [192 b of float32].
data = (0,0,0,0,0,0,1,1,1,2,2,2^0,0,1,1,2,2,0,0,2,0,0,1^1,2,0,2,0,1,0,2,0,0,1,0^2,1,2,0,1,0,2,0,0,1,0,0).
min = 0, max = 2, mean = 0.75, std = 0.829156, coords_min = (0,0,0,0), coords_max = (9,0,0,0).
[gmic]./ End G'MIC interpreter
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1,2
[gmic]./ 0,0,2,1
[gmic]./ 0,1,0,2
[gmic]./ 0,1,2,0
[gmic]./ 0,2,0,1
[gmic]./ 0,2,1,0
[gmic]./ 1,0,0,2
[gmic]./ 1,0,2,0
[gmic]./ 1,2,0,0
[gmic]./ 2,0,0,1
[gmic]./ 2,0,1,0
[gmic]./ 2,1,0,0
[gmic]./ Display image [0] = '[unnamed]'.
[0] = '[unnamed]':
size = (12,1,1,4) [192 b of float32].
data = (0,0,0,0,0,0,1,1,1,2,2,2^0,0,1,1,2,2,0,0,2,0,0,1^1,2,0,2,0,1,0,2,0,0,1,0^2,1,2,0,1,0,2,0,0,1,0,0).
min = 0, max = 2, mean = 0.75, std = 0.829156, coords_min = (0,0,0,0), coords_max = (9,0,0,0).
[gmic]./ End G'MIC interpreter
rep_rde_npr_permutation(s)_
Permutations of a multiset where each element can appear a fixed number of times, but only a subset of elements is selected.$ +rep_rde_npr_permutations 3,2,1,1,2 repeat w { e[0] {I[#-1,$>]} }
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1
[gmic]./ 0,0,2
[gmic]./ 0,0,3
[gmic]./ 0,1,0
[gmic]./ 0,1,2
[gmic]./ 0,1,3
[gmic]./ 0,2,0
[gmic]./ 0,2,1
[gmic]./ 0,2,3
.....
[gmic]./ 3,3,1
[gmic]./ 3,3,2
[gmic]./ Display image [0] = '[>begin( quantity_of_items_in...'.
[0] = '[>begin( quantity_of_items_in_group=vmin([2,1,1,2],3); const ...':
size = (42,1,1,3) [504 b of float32].
data = (0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3^0,0,0,1,1,1,2,2,2,3,3,3,3,0,0,0,2,2,3,3,3,0,0,0,1,1,3,3,3,0,0,0,0,1,1,1,2,2,2,3,3,3^1,2,3,0,2,3,0,1,3,0,1,2,3,0,2,3,0,3,0,2,3,0,1,3,0,3,0,1,3,0,1,2,3,0,2,3,0,1,3,0,1,2).
min = 0, max = 3, mean = 1.5, std = 1.21988, coords_min = (0,0,0,0), coords_max = (29,0,0,0).
[gmic]./ End G'MIC interpreter
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1
[gmic]./ 0,0,2
[gmic]./ 0,0,3
[gmic]./ 0,1,0
[gmic]./ 0,1,2
[gmic]./ 0,1,3
[gmic]./ 0,2,0
[gmic]./ 0,2,1
[gmic]./ 0,2,3
.....
[gmic]./ 3,3,1
[gmic]./ 3,3,2
[gmic]./ Display image [0] = '[>begin( quantity_of_items_in...'.
[0] = '[>begin( quantity_of_items_in_group=vmin([2,1,1,2],3); const ...':
size = (42,1,1,3) [504 b of float32].
data = (0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3^0,0,0,1,1,1,2,2,2,3,3,3,3,0,0,0,2,2,3,3,3,0,0,0,1,1,3,3,3,0,0,0,0,1,1,1,2,2,2,3,3,3^1,2,3,0,2,3,0,1,3,0,1,2,3,0,2,3,0,3,0,2,3,0,1,3,0,3,0,1,3,0,1,2,3,0,2,3,0,1,3,0,1,2).
min = 0, max = 3, mean = 1.5, std = 1.21988, coords_min = (0,0,0,0), coords_max = (29,0,0,0).
[gmic]./ End G'MIC interpreter
rep_rde_combination(s)_
Combinations from a multiset where each element has a fixed number of occurrences. Order does not matter.$ +rep_rde_combinations 3,2,1,1,2 repeat w { e[0] {I[#-1,$">"]} }
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1
[gmic]./ 0,0,2
[gmic]./ 0,0,3
[gmic]./ 0,1,2
[gmic]./ 0,1,3
[gmic]./ 0,2,3
[gmic]./ 0,3,3
[gmic]./ 1,2,3
[gmic]./ 1,3,3
[gmic]./ 2,3,3
[gmic]./ Display image [0] = '[>begin( items_count=[2,1,1,2...'.
[0] = '[>begin( items_count=[2,1,1,2]; const number_of_sets_of_items...':
size = (10,1,1,3) [120 b of float32].
data = (0,0,0,0,0,0,0,1,1,2^0,0,0,1,1,2,3,2,3,3^1,2,3,2,3,3,3,3,3,3).
min = 0, max = 3, mean = 1.5, std = 1.25831, coords_min = (0,0,0,0), coords_max = (6,0,0,1).
[gmic]./ End G'MIC interpreter.
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1
[gmic]./ 0,0,2
[gmic]./ 0,0,3
[gmic]./ 0,1,2
[gmic]./ 0,1,3
[gmic]./ 0,2,3
[gmic]./ 0,3,3
[gmic]./ 1,2,3
[gmic]./ 1,3,3
[gmic]./ 2,3,3
[gmic]./ Display image [0] = '[>begin( items_count=[2,1,1,2...'.
[0] = '[>begin( items_count=[2,1,1,2]; const number_of_sets_of_items...':
size = (10,1,1,3) [120 b of float32].
data = (0,0,0,0,0,0,0,1,1,2^0,0,0,1,1,2,3,2,3,3^1,2,3,2,3,3,3,3,3,3).
min = 0, max = 3, mean = 1.5, std = 1.25831, coords_min = (0,0,0,0), coords_max = (6,0,0,1).
[gmic]./ End G'MIC interpreter.
rep_rde_compsel_perm(s)_
All permutations of elements of a fixed size where each element appears at least once.$ +rep_rde_compsel_perm 4,3 repeat w { e[0] {I[#-1,$>]} }
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1,2
[gmic]./ 0,0,2,1
[gmic]./ 0,1,0,2
[gmic]./ 0,1,1,2
[gmic]./ 0,1,2,0
[gmic]./ 0,1,2,1
[gmic]./ 0,1,2,2
[gmic]./ 0,2,0,1
[gmic]./ 0,2,1,0
[gmic]./ 0,2,1,1
[gmic]./ 0,2,1,2
[gmic]./ 0,2,2,1
[gmic]./ 1,0,0,2
[gmic]./ 1,0,1,2
[gmic]./ 1,0,2,0
[gmic]./ 1,0,2,1
[gmic]./ 1,0,2,2
[gmic]./ 1,1,0,2
[gmic]./ 1,1,2,0
[gmic]./ 1,2,0,0
[gmic]./ 1,2,0,1
[gmic]./ 1,2,0,2
[gmic]./ 1,2,1,0
[gmic]./ 1,2,2,0
[gmic]./ 2,0,0,1
[gmic]./ 2,0,1,0
[gmic]./ 2,0,1,1
[gmic]./ 2,0,1,2
[gmic]./ 2,0,2,1
[gmic]./ 2,1,0,0
[gmic]./ 2,1,0,1
[gmic]./ 2,1,0,2
[gmic]./ 2,1,1,0
[gmic]./ 2,1,2,0
[gmic]./ 2,2,0,1
[gmic]./ 2,2,1,0
[gmic]./ Display image [0] = '[unnamed]'.
[0] = '[unnamed]':
size = (36,1,1,4) [576 b of float32].
data = (0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2^0,0,1,1,1,1,1,2,2,2,2,2,0,0,0,0,0,1,1,2,2,2,2,2,0,0,0,0, ... ,1,1,1,2,0,1,2,2,2,0,2,0,0,0,1,2,0,1,1,1,2,0,0,0,1,2,0,1^2,1,2,2,0,1,2,1,0,1,2,1,2,2,0,1,2,2,0,0,1,2,0,0,1,0,1,2,1,0,1,2,0,0,1,0).
min = 0, max = 2, mean = 1, std = 0.816497, coords_min = (0,0,0,0), coords_max = (24,0,0,0).
[gmic]./ End G'MIC interpreter.
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,1,2
[gmic]./ 0,0,2,1
[gmic]./ 0,1,0,2
[gmic]./ 0,1,1,2
[gmic]./ 0,1,2,0
[gmic]./ 0,1,2,1
[gmic]./ 0,1,2,2
[gmic]./ 0,2,0,1
[gmic]./ 0,2,1,0
[gmic]./ 0,2,1,1
[gmic]./ 0,2,1,2
[gmic]./ 0,2,2,1
[gmic]./ 1,0,0,2
[gmic]./ 1,0,1,2
[gmic]./ 1,0,2,0
[gmic]./ 1,0,2,1
[gmic]./ 1,0,2,2
[gmic]./ 1,1,0,2
[gmic]./ 1,1,2,0
[gmic]./ 1,2,0,0
[gmic]./ 1,2,0,1
[gmic]./ 1,2,0,2
[gmic]./ 1,2,1,0
[gmic]./ 1,2,2,0
[gmic]./ 2,0,0,1
[gmic]./ 2,0,1,0
[gmic]./ 2,0,1,1
[gmic]./ 2,0,1,2
[gmic]./ 2,0,2,1
[gmic]./ 2,1,0,0
[gmic]./ 2,1,0,1
[gmic]./ 2,1,0,2
[gmic]./ 2,1,1,0
[gmic]./ 2,1,2,0
[gmic]./ 2,2,0,1
[gmic]./ 2,2,1,0
[gmic]./ Display image [0] = '[unnamed]'.
[0] = '[unnamed]':
size = (36,1,1,4) [576 b of float32].
data = (0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2^0,0,1,1,1,1,1,2,2,2,2,2,0,0,0,0,0,1,1,2,2,2,2,2,0,0,0,0, ... ,1,1,1,2,0,1,2,2,2,0,2,0,0,0,1,2,0,1,1,1,2,0,0,0,1,2,0,1^2,1,2,2,0,1,2,1,0,1,2,1,2,2,0,1,2,2,0,0,1,2,0,0,1,0,1,2,1,0,1,2,0,0,1,0).
min = 0, max = 2, mean = 1, std = 0.816497, coords_min = (0,0,0,0), coords_max = (24,0,0,0).
[gmic]./ End G'MIC interpreter.
rep_rde_compsel_comb(s)_
All combinations of elements of a fixed size where each element appears at least once.$ +rep_rde_compsel_comb 6,3 repeat w { e[0] {I[#-1,$>]} }
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,0,0,1,2
[gmic]./ 0,0,0,1,1,2
[gmic]./ 0,0,0,1,2,2
[gmic]./ 0,0,1,1,1,2
[gmic]./ 0,0,1,1,2,2
[gmic]./ 0,0,1,2,2,2
[gmic]./ 0,1,1,1,1,2
[gmic]./ 0,1,1,1,2,2
[gmic]./ 0,1,1,2,2,2
[gmic]./ 0,1,2,2,2,2
[gmic]./ Display image [0] = '[>begin( const k=$k; const dk...'.
[0] = '[>begin( const k=$k; const dk=k-1; const P=s; cn=(1<<dk)-1; )...':
size = (10,1,1,6) [240 b of float32].
data = (0,0,0,0,0,0,0,0,0,0^0,0,0,0,0,0,1,1,1,1^0,0,0,1,1,1,1,1,1,2^0,1,1,1,1,2,1,1,2,2^1,1,2,1,2,2,1,2,2,2^2,2,2,2,2,2,2,2,2,2).
min = 0, max = 2, mean = 1, std = 0.816497, coords_min = (0,0,0,0), coords_max = (9,0,0,2).
[gmic]./ End G'MIC interpreter.
[gmic]./ Start G'MIC interpreter (v.3.7.3).
[gmic]./ 0,0,0,0,1,2
[gmic]./ 0,0,0,1,1,2
[gmic]./ 0,0,0,1,2,2
[gmic]./ 0,0,1,1,1,2
[gmic]./ 0,0,1,1,2,2
[gmic]./ 0,0,1,2,2,2
[gmic]./ 0,1,1,1,1,2
[gmic]./ 0,1,1,1,2,2
[gmic]./ 0,1,1,2,2,2
[gmic]./ 0,1,2,2,2,2
[gmic]./ Display image [0] = '[>begin( const k=$k; const dk...'.
[0] = '[>begin( const k=$k; const dk=k-1; const P=s; cn=(1<<dk)-1; )...':
size = (10,1,1,6) [240 b of float32].
data = (0,0,0,0,0,0,0,0,0,0^0,0,0,0,0,0,1,1,1,1^0,0,0,1,1,1,1,1,1,2^0,1,1,1,1,2,1,1,2,2^1,1,2,1,2,2,1,2,2,2^2,2,2,2,2,2,2,2,2,2).
min = 0, max = 2, mean = 1, std = 0.816497, coords_min = (0,0,0,0), coords_max = (9,0,0,2).
[gmic]./ End G'MIC interpreter.


Home
Download
News
Mastodon
Bluesky
X
Summary - 18 Years
Summary - 17 Years
Summary - 16 Years
Summary - 15 Years
Summary - 13 Years
Summary - 11 Years
Summary - 10 Years
Resources
Technical Reference
Scripting Tutorial
Video Tutorials
Wiki Pages
Image Gallery
Color Presets
Using libgmic
G'MIC Online
Community
Discussion Forum (Pixls.us)
GimpChat
IRC
Report Issue