DjProg 3 Posted November 19, 2011 Report Share Posted November 19, 2011 Hello again I am having a really hard time trying to find a way to generate words permutations... By this I mean I have a string : ubot studio software And i'm trying to generate all uniques permutations (word level) to have at the end: ubot software studiostudio ubot softwarestudio software ubot...etc How can I do such thing with Ubot ? I really have no clue how to proceed, maybe the solution would be with javascript but I still don't know how... Any suggestion ? Cheers, Quote Link to post Share on other sites
Kreatus (Ubot Ninja) 422 Posted November 19, 2011 Report Share Posted November 19, 2011 Something like this? add list to list(%randomization, $list from text("ubot software studio", " "), "Delete", "Global") set(#random, "{$random list item(%randomization)} {$random list item(%randomization)} {$random list item(%randomization)}", "Global") load html(#random) Quote Link to post Share on other sites
DjProg 3 Posted November 20, 2011 Author Report Share Posted November 20, 2011 Something like this? add list to list(%randomization, $list from text("ubot software studio", " "), "Delete", "Global") set(#random, "{$random list item(%randomization)} {$random list item(%randomization)} {$random list item(%randomization)}", "Global") load html(#random) Hi Kreatus, I'm not sure I understand exactly how I should interpret this code. Is it version 4 ? To be honest I'm still using version 3.5.something as the last time I tried version 4 there was too much issues. If you have the visual interpretation of you code it would really help Thanks a lot, Cheers, Quote Link to post Share on other sites
Dutch 4 Posted November 25, 2011 Report Share Posted November 25, 2011 Or, if you're really trying to spin the results without duplicating the words in the phrase you might want to try something like this (v4.x): ui text box("Word 1", #w1)ui text box("Word 2", #w2)ui text box("Word 3", #w3)set(#Result, $spin("\{{#w1} {#w2} {#w3}|{#w1} {#w3} {#w2}|{#w2} {#w1} {#w3}|{#w2} {#w3} {#w1}|{#w3} {#w1} {#w2}|{#w3} {#w2} {#w1}\}"), "Global")load html(#Result) Dutch Quote Link to post Share on other sites
JohnB 255 Posted November 25, 2011 Report Share Posted November 25, 2011 Dj, this issue can become quite complex depending on the scope of the phrase you are working with...are you interested in a script that handles any number of words, or just three? It makes a huge difference in the approach, and realistically anything more than 4 will become a coding nightmare simply due to the shear number of possibilities that will exist. If it's just three, both of the posted codes will work fine for you. I would suggest you give v4 another try. I do all of my coding in it now, and rarely have any issues anymore. John Quote Link to post Share on other sites
UBotBuddy 331 Posted November 25, 2011 Report Share Posted November 25, 2011 Way back in the olden days I used to be pretty good at statistics. Especially, when it came to this stuff. There are actually two kinds of permutations (with replacements and without replacements). One gets you a boat load more data. Check this bot out. clear list(%permutations)clear list(%list1)clear list(%list2)clear list(%list3)add list to list(%list1, $list from text(#wgrp1, $new line), "Delete", "Global")add list to list(%list2, $list from text(#wgrp2, $new line), "Delete", "Global")add list to list(%list3, $list from text(#wgrp3, $new line), "Delete", "Global")loop($list total(%list1)) { set(#grp1, $next list item(%list1), "Global") set list position(%list2, 0) loop($list total(%list2)) { set(#grp2, $next list item(%list2), "Global") set list position(%list3, 0) loop($list total(%list3)) { set(#grp3, $next list item(%list3), "Global") set(#var, "{#grp1} {#grp2} {#grp3}", "Global") add item to list(%permutations, #var, "Delete", "Global") } }}save to file("{$special folder("Desktop")}/permutations.txt", %permutations)dividerstop scriptui block text("Word Group 1", #wgrp1)ui stat monitor("Total Words ", $list total(%list1))ui stat monitor("____________________", "")ui block text("Word Group 2", #wgrp2)ui stat monitor("Total Words ", $list total(%list2))ui stat monitor("____________________", "")ui block text("Word Group 3", #wgrp3)ui stat monitor("Total Words ", $list total(%list3))ui stat monitor("____________________", "")ui stat monitor("Total Combinations", $list total(%permutations)) Took me a few minutes but it will produce combinations for you in an absurd way. LOL Place your first group of unique words in the first text box. Your second group of unique words in the 2nd box and do the same for the third textbox. Run it. If you put 3 words into each box then you would get 3 * 3 * 3 = 27 phrases. Now. If you put ALL of the three word groups into all of the three textboxes and run it you would get 9 * 9 * 9 = 729 phrases This was a fun exercise. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.