Most efficient method of comparing elements of multiple arrays

11 views
Skip to first unread message

Jeremy Harris

unread,
Jan 8, 2016, 9:06:37 PM1/8/16
to Tasker
I have a compound array whose elements are all arrays each contain a comma separated list of random numbers 1-80.

So %arr() has 4 elements:
%arr1 = 8,24,29,41,62
%arr2 = 11,24,36,47,53,62,68,80
%arr3 = 3,8,22,40,44,62,75
%arr1 = 16,35,51

I need help figuring out how to compare these arrays to determine the most common number...in the example above...62.

Jeremy Harris

unread,
Jan 8, 2016, 9:11:35 PM1/8/16
to tas...@googlegroups.com

Oops, corrected to %arr4

So %arr() has 4 elements:
%arr1 = 8,24,29,41,62
%arr2 = 11,24,36,47,53,62,68,80
%arr3 = 3,8,22,40,44,62,75

%arr4 = 16,35,51

Rich D

unread,
Jan 8, 2016, 10:41:34 PM1/8/16
to Tasker Google Groups Post

Hi, Jeremy

Welcome back.... :)   hope all is well with the family.. 

Here is my take on this. You will just need replace A1 with a variable set %num TO: %arr()

Common Num (204)
A1: Variable Set [ Name:%num To:1,2,8,24,29,41,62,11,24,36,47,53,62,68,80,3,8,22,40,44,62,75,16,35,51 Do Maths:Off Append:Off ]
A2: Variable Set [ Name:%match_b To:0 Do Maths:Off Append:Off ]
A3: Variable Split [ Name:%num Splitter:, Delete Base:Off ]
A4: For [ Variable:%item Items:1:80 ]
A5: Variable Set [ Name:%index To:%num(#?%item) Do Maths:Off Append:Off ]
A6: Variable Split [ Name:%index Splitter:, Delete Base:Off ]
A7: [X] Flash [ Text:%item Long:Off ]
A8: Variable Set [ Name:%match_a To:%index(#) Do Maths:Off Append:Off ]
A9: [X] Flash [ Text:%match_a Long:Off ]
A10: Variable Set [ Name:%common To:%item Do Maths:On Append:Off ] If [ %match_a > %match_b ]
A11: Variable Set [ Name:%match_b To:%match_a Do Maths:On Append:Off ] If [ %match_a > %match_b ]
A12: End For
A13: Flash [ Text:%common Long:Off ]

Common_Num.tsk.xml

Jeremy Harris

unread,
Jan 8, 2016, 11:31:09 PM1/8/16
to tas...@googlegroups.com

Hi Rich! The family is doing well, thanks! :)

You have outdone yourself again, this works perfectly! Very much appreciated! Thank you!

Reply all
Reply to author
Forward
0 new messages