Skip to main content
deleted 13 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
extractGridLengths = 
  Map[l |-> Max[Length[#]Length @ # / Min @ Counts[#[[All, l]]]]]l]]]] @ Range @ #2 &;

extractGridLengths[tuples, ngrids]
extractGridLengths = 
  Map[l |-> Max[Length[#] / Counts[#[[All, l]]]]] @ Range @ #2 &;

extractGridLengths[tuples, ngrids]
extractGridLengths = 
  Map[l |-> Length @ # / Min @ Counts[#[[All, l]]]] @ Range @ #2 &;

extractGridLengths[tuples, ngrids]
deleted 13 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
extractGridLengths = 
  Map[l |-> Total @ Normalize[#, Min] &Max[Length[#] @/ Counts[#[[All, l]]]]l]]]]] @ Range @ #2 &;

extractGridLengths[tuples, ngrids]
extractGridLengths = 
  Map[l |-> Total @ Normalize[#, Min] & @ Counts[#[[All, l]]]] @ Range @ #2 &;

extractGridLengths[tuples, ngrids]
extractGridLengths = 
  Map[l |-> Max[Length[#] / Counts[#[[All, l]]]]] @ Range @ #2 &;

extractGridLengths[tuples, ngrids]
added 27 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

If we know that

  1. tuples is constructed from ngrids grids, and
  2. each grid has at least one unique element

then tuples is constructed from ngrids input grids and if each grid has at least one non-repeating element, we can extractget the lengthsduplicates and their counts in each of the grids using:

extractGridLengthsextractDuplicates = 
  Map[l |-> TotalSelect[GreaterThan[1]] @ Normalize[#, Min] & @ Counts[#[[All, l]]]] @
  Range @ #2 &;

ngrids = 3;

extractGridLengths[tuplesextractDuplicates[tuples, ngrids]
 {6<|0.2 -> 2|>, 6<||>, 5<|0.35 -> 2|>}

ToWe can get the duplicatesinput grids and their counts in each of the gridslengths as follows:

extractDuplicatesextractGridLengths = 
  Map[l |-> Select[GreaterThan[1]]Total @ Normalize[#, Min] & @ Counts[#[[All, l]]]] @
  Range @ #2 &;
 

extractDuplicates[tuplesextractGridLengths[tuples, ngrids]
 {<|0.2 -> 2|>6, <||>6, <|0.35 -> 2|>5}

If we know that

  1. tuples is constructed from ngrids grids, and
  2. each grid has at least one unique element

then, we can extract the lengths using:

extractGridLengths = 
  Map[l |-> Total @ Normalize[#, Min] & @ Counts[#[[All, l]]]] @ Range @ #2 &;

ngrids = 3;

extractGridLengths[tuples, ngrids]
{6, 6, 5}

To get the duplicates and their counts in each of the grids:

extractDuplicates = 
  Map[l |-> Select[GreaterThan[1]] @ Normalize[#, Min] & @ Counts[#[[All,l]]]] @
  Range @ #2 &;
 

extractDuplicates[tuples, ngrids]
 {<|0.2 -> 2|>, <||>, <|0.35 -> 2|>}

If we know that tuples is constructed from ngrids input grids and if each grid has at least one non-repeating element, we can get the duplicates and their counts in each of the grids using

extractDuplicates = 
  Map[l |-> Select[GreaterThan[1]] @ Normalize[#, Min] & @ Counts[#[[All,l]]]] @
  Range @ #2 &;

ngrids = 3;

extractDuplicates[tuples, ngrids]
 {<|0.2 -> 2|>, <||>, <|0.35 -> 2|>}

We can get the input grids and their lengths as follows:

extractGridLengths = 
  Map[l |-> Total @ Normalize[#, Min] & @ Counts[#[[All, l]]]] @ Range @ #2 &;

extractGridLengths[tuples, ngrids]
{6, 6, 5}
added 99 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 314 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 53 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
Post Undeleted by kglr
Post Deleted by kglr
added 35 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 1048 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 111 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 37 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 4 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 229 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
added 61 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
Loading