User Tag List

Results 1 to 9 of 9

Thread: Find some kind of pattern in array (sequence of the numbers)

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    anatol's Avatar
    Join Date
    Jun 2016
    Posts
    140
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Question Find some kind of pattern in array (sequence of the numbers)

    Hello ! it`s me again
    Today my new challenge is "find pattern in numbers"
    Situation :
    I`ve got numbers stored in LIST object, random but nonrepeating and sorted . For example 1.2.12.17.19.21.25.26.36
    I need to find in this numbers some kind of pattern. For example A.A+1.A+10. In my example i would have found two patterns - 1.2.12 and 25.26.36

    How to do this in CF ?
    Thank you

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Think you'll have to tackle those patterns one by one,
    like checking them in a fastloop through the list

    i.e.
    assuming your different numbers are stored one for each row of the list:

    on triggering action
    >>> start loop "find pattern" List Nb Lines( "List" ) times

    on loop "find pattern"
    + val(listlinetext$("list", loopindex("find pattern") +1 )) = val(listlinetext$("list", loopindex("find pattern"))) +1
    + val(listlinetext$("list", loopindex("find pattern") +2 )) = val(listlinetext$("list", loopindex("find pattern"))) +10
    >>> pattern found starting from line: loopindex("find pattern")

    (pseudocode from top of the mind - be warned! )

    and of course you can check as many patterns you need by adding other on loop "find pattern" events

  3. #3
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    anatol's Avatar
    Join Date
    Jun 2016
    Posts
    140
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    Think you'll have to tackle those patterns one by one,
    like checking them in a fastloop through the list

    i.e.
    assuming your different numbers are stored one for each row of the list:

    on triggering action
    >>> start loop "find pattern" List Nb Lines( "List" ) times

    on loop "find pattern"
    + val(listlinetext$("list", loopindex("find pattern") +1 )) = val(listlinetext$("list", loopindex("find pattern"))) +1
    + val(listlinetext$("list", loopindex("find pattern") +2 )) = val(listlinetext$("list", loopindex("find pattern"))) +10
    >>> pattern found starting from line: loopindex("find pattern")

    (pseudocode from top of the mind - be warned! )

    and of course you can check as many patterns you need by adding other on loop "find pattern" events
    Damn... It is WORKS !! Thank you man ! really appreciate your help !

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    anatol's Avatar
    Join Date
    Jun 2016
    Posts
    140
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Hm... everything cool , exept one thing - This worked only in "linear bruteforce".
    if i need to check something about A. A+10. A+12 in 1.2.6.7.8.9.10.11.12.17.18 it will receive nothing.
    although all numbers that i need is here = 1.10.12

    is there any ideas ?

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    mm yeah thought you had to search for patterns
    (repeating elements in same "configuration" you specified)

    if you need to search all of those elements in any position
    I would suggest saving your list of elements in a string,
    just as you write it in your post, but with additional start and end delimiter
    (this will be needed for find string later):

    .1.2.6.7.8.9.10.11.12.17.18.

    let's call it "my_string"

    and then:

    1) use the string tokenizer to split my_string at "."

    2) fire loop "my_loop" numberofelements times

    3)

    on loop "my_loop"
    Find(my_string, "."+Str$( Val( Element$( "String tokenizer", LoopIndex("my_loop") ) )+10 )+".", 0) >= 0
    Find(my_string, "."+Str$( Val( Element$( "String tokenizer", LoopIndex("my_loop") ) )+12 )+".", 0) >= 0
    >>> pattern found for number: Element$( "String tokenizer", LoopIndex("my_loop") )

    (real code above so you can plug and play in "compare two general values, pattern in red)

    not tested, but should work, hopefully..


    (btw, the numbers are not there, it should be 1.11.13, change pattern or string for testing )

  6. #6
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    anatol's Avatar
    Join Date
    Jun 2016
    Posts
    140
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    mm yeah thought you had to search for patterns
    (repeating elements in same "configuration" you specified)

    if you need to search all of those elements in any position
    I would suggest saving your list of elements in a string,
    just as you write it in your post, but with additional start and end delimiter
    (this will be needed for find string later):

    .1.2.6.7.8.9.10.11.12.17.18.

    let's call it "my_string"

    and then:

    1) use the string tokenizer to split my_string at "."

    2) fire loop "my_loop" numberofelements times

    3)

    on loop "my_loop"
    Find(my_string, "."+Str$( Val( Element$( "String tokenizer", LoopIndex("my_loop") ) )+10 )+".", 0) >= 0
    Find(my_string, "."+Str$( Val( Element$( "String tokenizer", LoopIndex("my_loop") ) )+12 )+".", 0) >= 0
    >>> pattern found for number: Element$( "String tokenizer", LoopIndex("my_loop") )

    (real code above so you can plug and play in "compare two general values, pattern in red)

    not tested, but should work, hopefully..


    (btw, the numbers are not there, it should be 1.11.13, change pattern or string for testing )
    Brilliant idea ! completely forgot about stringtokenizer !

  7. #7
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    anatol's Avatar
    Join Date
    Jun 2016
    Posts
    140
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    ... well. It doesn`t work . Spend several hours to understand why ... but .. i give up
    Everything should work . But it is not working

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,159
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    odd, it works for me, with just the events I wrote above:

    find_pattern.mfa

    did you fix your test string as stated here?

    (btw, the numbers are not there, it should be 1.11.13, change pattern or string for testing )
    did you add start and ending "." in the string?

  9. #9
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    anatol's Avatar
    Join Date
    Jun 2016
    Posts
    140
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by schrodinger View Post
    odd, it works for me, with just the events I wrote above:

    find_pattern.mfa

    did you fix your test string as stated here?



    did you add start and ending "." in the string?
    Hmmm... I tried yesterday with string parser, but not string tokenizer. may be this is the problem .
    Thank you ! Look like i finally got ideal algorithm.

Similar Threads

  1. Array tutorial - Save and Load Data / Strings n Numbers
    By Sparckman in forum Guides, Tutorials, Examples, Widgets
    Replies: 13
    Last Post: 4th April 2015, 01:19 PM
  2. Save Real Numbers with an INI EASY no array, no floats
    By Sparckman in forum Guides, Tutorials, Examples, Widgets
    Replies: 0
    Last Post: 12th March 2015, 08:36 PM
  3. Random Numbers and expiring the result numbers.
    By Corlen in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 26th April 2013, 04:11 PM
  4. Pattern
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 17th September 2008, 04:30 PM
  5. Dynamic Array- find row index?
    By crugh in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 11th May 2007, 04:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •