DavidLago Posted January 18, 2016 Share Posted January 18, 2016 (edited) Hey. Bogosort: https://en.wikipedia.org/wiki/Bogosort Useless, but fun. Global $Var1, $Var2, $Var3, $Var4, $Var5, $Var6, $count = "" Global $Value = $Var1 + $Var2 + $Var3 + $Var4 + $Var5 + $Var6 Global $Number = 10000 Global $Flag = False While Not $Flag = True $count = $count + 1 $Var1 = Random(0, 2000, 1) $Var2 = Random(0, 2000, 1) $Var3 = Random(0, 2000, 1) $Var4 = Random(0, 2000, 1) $Var5 = Random(0, 2000, 1) $Var6 = Random(0, 2000, 1) $Value = $Var1 + $Var2 + $Var3 + $Var4 + $Var5 + $Var6 If $Value = $Number Then $Flag = True WEnd MsgBox(64, "Bogosort", "Bogosort took " & $count & " tries to guess 6 numbers!") Is anyone able to improve it in any way? Edited January 18, 2016 by DavidLago Link to comment Share on other sites More sharing options...
TheSaint Posted January 18, 2016 Share Posted January 18, 2016 Hi DavidLago, welcome to the General Chat forum. If you are asking for improvements to code, then really this topic should be in Examples or GH&S. Most of us come here to escape from code ... fun though your finished code might be. Or perhaps even the Scripting & Development section of the forum, in Developer General Discussion Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
DavidLago Posted January 18, 2016 Author Share Posted January 18, 2016 Hi, not asking for anything Just showing up a really fun code, and if someone else wants to have fun, adding some stupid stuff in the code within the topic, that would be even more fun If you think it would fit better there, could you move it? Link to comment Share on other sites More sharing options...
TheSaint Posted January 18, 2016 Share Posted January 18, 2016 (edited) 32 minutes ago, DavidLago said: Hi, not asking for anything Just showing up a really fun code, and if someone else wants to have fun, adding some stupid stuff in the code within the topic, that would be even more fun The original description of the Chat Forum, used to say no code, and as far as I know, that still stands. To get around that, you could perhaps talk about Bogosort here, and provide a link to your code at wherever it gets relocated to. Quote If you think it would fit better there, could you move it? Report the topic and ask, as it requires a MOD to do it. Or just take up my suggestion and split your code off. Edited January 18, 2016 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
DavidLago Posted January 18, 2016 Author Share Posted January 18, 2016 Reported, Sir! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 18, 2016 Moderators Share Posted January 18, 2016 Moved per request. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
TheDcoder Posted January 18, 2016 Share Posted January 18, 2016 5 hours ago, DavidLago said: Is anyone able to improve it in any way? #include <MsgBoxConstants.au3> Global Const $NUMBER_TO_SORT = 10000 Global Const $DIFFICULTY = 2000 Global Const $NO_OF_ITERATIONS = 6 Global $iCount = 0 Global $iSum = 0 Do $iSum = 0 $iCount = $iCount + 1 For $i = 1 To $NO_OF_ITERATIONS $iSum += Random(0, $DIFFICULTY, 1) Next Until $iSum = $NUMBER_TO_SORT MsgBox($MB_OK + $MB_ICONINFORMATION, "Bogosort", "Bogosort took " & $iCount & " tries to guess " & $NUMBER_TO_SORT & " out of " & $NO_OF_ITERATIONS & " randomly added up numbers (each not exceeding " & $DIFFICULTY & ')') P.S Its not AutoIT, Its AutoIt EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
DavidLago Posted January 18, 2016 Author Share Posted January 18, 2016 I wonder how long it would get to guess 12000... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now